如何使用C#在Excel工作表中获取当前或聚焦的单元格值

ven*_*kat 7 c# excel vsto

请帮我看一下VSTO Excel中的C#代码.无论我在哪里选择一个单元格,相应的列都会聚焦,我需要在我关注的任何地方获取Excel工作表上的Column值(列)和Row值(行号).

我怎么能通过代码做同样的事情?如何使用C#在VSTO excel中获取聚焦或当前单元格的列值?

此外,我想学习使用C#的VSTO Excel,因此欢迎一些好的免费/可下载电子书和/或任何网站链接建议.

bur*_*ide 21

Excel.Range rng = (Excel.Range) this.Application.ActiveCell;

//get the cell value
object cellValue = rng.Value;

//get the row and column details
int row = rng.Row;
int column = rng.Column;
Run Code Online (Sandbox Code Playgroud)

这是一个快速入门的演练.