Get range (entire column) in C#

  • Thread starter Thread starter sweetpotatop
  • Start date Start date
S

sweetpotatop

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.
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top