使用C#将单元格地址更改为Excel工作表中的行,列

时间:2022-02-20 20:53:19

I would like to convert an excel cell eg : A1 to 1,1 G6 to 7,6 etc

我想转换一个excel单元格,例如:A1到1,1 G6到7,6等

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

有没有人有这个想法?注意:这是C#应用程序所必需的。

3 个解决方案

#1


1  

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

您应该能够将字母部分视为基数26中的数字,A = 0(在Excel中,列名最终重复,如“AA”中所示)。

#2


3  

If I understand you correctly try

如果我理解你正确的尝试

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

This will return

这将返回

7,6

#3


0  

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

如果您想将此作为Excel公式执行,那么这将起作用

=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

但是,如果您在字符串中有单元格引用,则需要使用INDIRECT函数,如下所示

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

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

这给出了标题中指定的6,7(行,列)的结果。

#1


1  

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

您应该能够将字母部分视为基数26中的数字,A = 0(在Excel中,列名最终重复,如“AA”中所示)。

#2


3  

If I understand you correctly try

如果我理解你正确的尝试

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

This will return

这将返回

7,6

#3


0  

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

如果您想将此作为Excel公式执行,那么这将起作用

=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

但是,如果您在字符串中有单元格引用,则需要使用INDIRECT函数,如下所示

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

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

这给出了标题中指定的6,7(行,列)的结果。