Why does this work:
((Excel.Worksheet)Application.ActiveSheet).get_Range("A1", "A1").Value2 = text;
But this doesn't:
Excel.Worksheet activeSheet = ((Excel.Worksheet)Application.ActiveSheet);
activeSheet.Cells[0, 0] = text;
I need to do it the second way as I need to loop with rowIndex and colIndex. How can I do that?
I get the error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Exception from HRESULT: 0x800A03EC