访问excel单元格名称 [英] Access excel cell by its name

查看:140
本文介绍了访问excel单元格名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将excel的单元格名称设置为某些自定义名称,然后以其名称访问该单元格。
是否有一些开箱即用的API调用来执行此操作,或者如果我有访问单元格和
工作表和单元格地址(即C2)的工作表和单元格名称的信息,该怎么办?在命名单元格的情况下。

I'm trying to set excel's cell name to some custom name and to later access that cell by its name. Is there some out of the box API call to do this, or how should I do this if I have information of worksheet and cell name in case of accessing cell and worksheet and cell address (i.e. C2) in case of naming the cell.

还要问,有没有办法获取绑定到该特定单元格的格式化信息?
(即当我按名称访问单元格时,我想要返回单元格的值和这个单元格的某些格式化属性,如果单元格是数字或文本,是否突出显示,等等)

Also to ask, is there a way to acquire formatting information that is bound to that specific cell? (i.e. When I'm accessing cell by name I want to return cell value and some formatting properties of this cell, if cell is number or text, is it highlighted, etc...)

敬意,

Vladimir Vajda

Vladimir Vajda

推荐答案

我想你可能正在寻找 Range(C2)

关于格式化信息,这可以通过Excel对象模型的各种属性来获得。请参阅 http://msdn.microsoft.com/en-us/library/ff197454 .aspx 获取更多信息。

As to formatting information, this is available through various properties of the Excel object model. See http://msdn.microsoft.com/en-us/library/ff197454.aspx for more information.

范围类型(而不是范围上面引用的索引属性)还暴露了一个名称属性,您可以在代码中设置:

The Range type (as opposed to the Range indexed property referenced above) also exposes a Name property, which you can set in code:

worksheet.get_Range("C2").Name = "fdafdfs"
worksheet.get_Range("fdafdfs").Select();

这篇关于访问excel单元格名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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