How to get current or focussed cell value in Excel worksheet using C#

自古美人都是妖i 提交于 2019-12-04 22:31:35

问题


Please help me through a C# code that in VSTO Excel. Wherever I selected a cell the respective column gets focused, I need to get the Column value (column) and Row value(row no) on excel worksheet wherever I focus.

How can I do the same through code? How do I get the focused or current cell's column value in VSTO excel using C#?

Also, I would like to learn VSTO Excel using C# so some good free/downloadable ebooks and/or any web links suggestions are welcomed.


回答1:


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;

and here's a quick start walkthrough.



来源:https://stackoverflow.com/questions/2378206/how-to-get-current-or-focussed-cell-value-in-excel-worksheet-using-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!