Quiero intentar obtener y escribir una cadena en un archivo de Excel
, pero me muestra una excepción cuando intento ejecutarlo.
El código es este:
Excel.Application excelApp = new Excel.Application();
excelApp.Visible = true;
string workbookPath = "c:/Libro1.xlsx";
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Sheet1";
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet); //en esta instruccion me sale la excepcion
Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1");