-1

I am using EPPlus for reading excel file and I got all excel rows and columns where data is present as Object[,]

enter image description here

I tried to access individual values using data[0,0] but it fails.

How can I access the individual values in this Object[,] ?

SimpleGuy
  • 2,764
  • 5
  • 28
  • 45
  • Has any of this topics answer your question: https://stackoverflow.com/questions/12567329/multidimensional-array-vs, https://stackoverflow.com/questions/597720/what-are-the-differences-between-a-multidimensional-array-and-an-array-of-arrays – Peter Csala Dec 04 '20 at 13:23
  • @PeterCsala I got it from the answer below. Thanks – SimpleGuy Dec 04 '20 at 14:18

1 Answers1

0

You can access it like

var data = worksheet.Cells[0,0].Value;

So you need to define the index at cell level, not at value level.

Since ExcelWorksheet.Cells.Value is of type object, you first need to cast to object[,] if you are trying to access on value level:

var data = ((object[,])worksheet.Cells.Value)[0,0];
Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49