Hi everyone
I write screen scraping in a loop to ouput column name for each column in a new datatable
I know how to write each row by use write cell (“A”+i.ToString) i=i+1 in loop
but I don’t know how to select cell from A1 to B1 since string cannot use (plus) function
Is there anyway to solve it? or convert the string to ASCII code? or any better appoarch?
Thanks
Mightsuccess
Hi @mightsuccess
Convert.ToChar(65+ i )
to convert number to letter.
Regards,
Karthik
what if more than 26 rows
“AA” to “AAA”
how to deal with it?
or I need 2 loop run together to get the value?
Unfortunately it works only up to Z.
For your requirement, you can make use of the following code -
variable, Integer value
variable, String Result
for example, if value = 28, the following code returns “AB”
while (--value >= 0)
{
Assign Activity, result = Convert.ToChar('A' + value % 26) + result;
Assign Activity, value /= 26;
}
The result contains the column name.
Regards,
Karthik Byggari
system
(system)
Closed
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.