问题
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