473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Get range (entire column) in C#

Hi,

I would like to know the syntax in C# of getting a few colums in Excel
through range
e.g, I want the 45 to 50th column, what will be the syntax?

sheet.get_Range("45:50", Missing.Value)? But I guess that just give me
row 45 to 50 instead.

I know I can do sheet.get_Range("B:K", Missing.Value), but what
happens to anything "Z", since I will be looping through the ranges
e.g 45-50 then 60-70 then 75-90...I wonder what the best way is to do
this

Thanks in advance. Your help would be greatly appreciated.

Jan 10 '08 #1
2 5734
Well, you could write an algorithm which will convert the column index
into a letter address. It's pretty simple, really. The mapping is as
follows:

A-Z = 1-26
AA-AZ = 27-52
BA-BZ = 53-78

And so on.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<sw**********@yahoo.comwrote in message
news:89**********************************@v67g2000 hse.googlegroups.com...
Hi,

I would like to know the syntax in C# of getting a few colums in Excel
through range
e.g, I want the 45 to 50th column, what will be the syntax?

sheet.get_Range("45:50", Missing.Value)? But I guess that just give me
row 45 to 50 instead.

I know I can do sheet.get_Range("B:K", Missing.Value), but what
happens to anything "Z", since I will be looping through the ranges
e.g 45-50 then 60-70 then 75-90...I wonder what the best way is to do
this

Thanks in advance. Your help would be greatly appreciated.

Jan 10 '08 #2
sw**********@yahoo.com wrote:
Hi,

I would like to know the syntax in C# of getting a few colums in Excel
through range
e.g, I want the 45 to 50th column, what will be the syntax?

sheet.get_Range("45:50", Missing.Value)? But I guess that just give me
row 45 to 50 instead.

I know I can do sheet.get_Range("B:K", Missing.Value), but what
happens to anything "Z", since I will be looping through the ranges
e.g 45-50 then 60-70 then 75-90...I wonder what the best way is to do
this
Convert the letter values into number values? The alphabet is really just a base
26 numbering system, so all you have to do is convert the letters to a numeric
value and then pull the column label off of that.

IE: 45 to 50 is "AS to AX", 60 to 70 is "BH to BR", and so on.

Easiest way to verify this stuff is to check out how excel treats the columns >
"Z" yourself.

Chris.
Jan 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: GG | last post by:
Have this code but does not delete right columns. When I ran the folllowing code only columns 14, and 15 is deleted.Col 12 and 13 are still there. Any ideas? Thanks for (int colDel = 12;...
2
by: DeWitt Phillips | last post by:
First let me say thank you. I am trying to extract the last value entered into a database column without having to read through every value stored in the column. Is that something that is easy to...
1
by: svaradan | last post by:
Hi Is it possible to associate a datasource in a datagridview combobox to one cell and not to the entire column? If so how would I go about doing it? Sonny
3
by: Sheau Wei | last post by:
when the result print out , i want to make hyperlink for entire column of ID. what should i do?Below was my php code. //And we display the results while($result = mysql_fetch_array( $data )) ...
2
by: shara | last post by:
Hello there, I am working on macros and now i am calculating the value of columns cell by cell based on the previous cells of the corresponding row in that column.Do i have any method where i can...
1
antonopn
by: antonopn | last post by:
Hello there, In a table, with a field which type is float (lets say MYFLOAT from MYTABLE) I have this value 6.0949997901916504 It it a value that was imported from an excel sheet. when I...
1
by: olgagjor | last post by:
how can i change column in gridview with css in visual studio 2005. my table has 5 rows and 4 columns.if i want to change 3 rd column can i change entire column or i must change separately. because i...
0
by: Mariappan E | last post by:
I have two workbook, one is master file, i want some data pick up from master file how i can use find, if the data is available, copy of entire column & past another work if its not there i want...
1
by: shalskedar | last post by:
I need to copy data from 1 workbook & paste to another workbook which i could do.. but i m not able to paste the data starting from the specific cell... Below is my code Dim wbk As Workbook...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.