开发者

Change a cell address to row,column in Excel sheet using C#

开发者 https://www.devze.com 2022-12-14 13:40 出处:网络
I would like to convert an 开发者_开发知识库excel cell eg : A1 to 1,1 G6 to 7,6 etc Does any one have idea for it?

I would like to convert an 开发者_开发知识库excel cell eg : A1 to 1,1 G6 to 7,6 etc

Does any one have idea for it? Note : This is required for a C# application.


If I understand you correctly try

=COLUMN(G6) & "," & ROW(G6)

This will return

7,6


You should be able to just treat the alphabetic portion as a number in base 26, with A = 0 (in Excel, the column names eventually repeat, as in "AA").


If you want to do this as an Excel formula then this will work

=CONCATENATE(ROW(G6),",",COLUMN(G6))

However if you have the cell reference in a string then you will need to use the INDIRECT function as follows

=CONCATENATE(ROW(INDIRECT("G6")),",",COLUMN(INDIRECT("G6")))

This gives a result of 6,7 (Row,Column) as specified in the title.

0

精彩评论

暂无评论...
验证码 换一张
取 消