-1

I am trying to get the cell name like A1,B1,A2,B2 from an excel sheet.

Here is my code

object objCellText = Cells.GetType().InvokeMember("Item", 
                        BindingFlags.GetProperty,null,Cells, 
                        new object[] { RowIndex, ColIndex });

var CellText = objCellText.GetType().InvokeMember("Value",
                        BindingFlags.GetProperty, null, objCellText, null);

var CellName = objCellText.GetType().InvokeMember("Name",
                        BindingFlags.GetProperty, null, objCellText, null);

In the code, Name property is not working.

Thanks in advance for any help!

ughai
  • 9,830
  • 3
  • 29
  • 47

1 Answers1

0

That's because a Cell's name is not its address. You can name a cell or range of cells with a descriptive name, eg "Expenses". A2 or A2:B2 are the addresses of a single cell or range of cells. A named range can be used in a formula, eg SUM(Expenses) just like a range address SUM(A1:B2).

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236