gpt4 book ai didi

c# - 将单元格位置字符串解析为行和列

转载 作者:太空狗 更新时间:2023-10-29 20:55:11 25 4
gpt4 key购买 nike

我有 string col= "AB21" 这是一个 excel 单元格位置。

我想将其解析为 string column = "AB" & int row = 21;

我该怎么做?

最佳答案

string col = "AB21";
int startIndex = col.IndexOfAny("0123456789".ToCharArray());
string column = col.Substring(0, startIndex);
int row = Int32.Parse(col.Substring(startIndex));

当然,你应该保证输入的字符串格式正确。

关于c# - 将单元格位置字符串解析为行和列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10073710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com