Excel.Range range = excelWorksheet.get_Range("A2", "B300");
int j = range.Columns.Count;
j = 3;
int i = range.Rows.Count;
string text = range.Cells[i, j].ToString();
string[,] list = new string[i, j];
In your
foreach
, you cycle through all worksheets, but inside the nested
for
loops you copy the variable
text
into every element of the array.
Your code is not copying the cell contents to the array, and that is why you are getting an empty text file at the end.