在Excel / VSTO中的列号到列号使用C# [英] Column No to Column Letter in Excel/VSTO using C#

查看:172
本文介绍了在Excel / VSTO中的列号到列号使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到列的名称或标题?

How to find column's name or header?

例如,如果我选择5列在Excel意味着我要的结果为E。
如何获得字母或对应列字母没有。

For example if i select column 5 in excel means i want the result as "E". How to get the alphabet or letter corresponding to column no.

请帮助我的代码

推荐答案

有关使用什么 Application.ActiveCell.get_Address(真实的,真实的,Excel.AlReferenceStyle.xlA1,失踪,失踪),然后?解析结果字符串或使用正则表达式来获取列标题

What about using Application.ActiveCell.get_Address(true, true, Excel.AlReferenceStyle.xlA1, missing, missing) and then parse the result string or use a RegEx to get the column heading?

我只是用:

string location = Application.ActiveCell.get_Address(true, true, Excel.AlReferenceStyle.xlA1, missing, missing);
string tokens = x.Split("$".ToCharArray());
MessageBox.Show(String.Format("Column {0}", result[0]));

这篇关于在Excel / VSTO中的列号到列号使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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