将单元格位置字符串解析成行&柱 [英] Parse Cell Location String into Row & Column

查看:136
本文介绍了将单元格位置字符串解析成行&柱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i have string col= "AB21" which is an excel cell location.

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

I would like to parse it as 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));

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

Of course, you should guarantee that input string will be in correct format.

这篇关于将单元格位置字符串解析成行&柱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆