Why do I get an error when trying to assign a value to an excel column using the interop library?

0

I want to generate reports with the information of the BD, in fact everything is fine except when I want to start adding the information I get inside the excel.

Excel setting code:

ExcelCreate.Application excelApp = new ExcelCreate.Application();
excelApp.Visible = true;
string workbookPath = "C:\xxx\xxxx\xxx\xxxx xxx\xxxx\xxxxx\xxxx\Excel.xlsx";
ExcelCreate.Workbook book = excelApp.Workbooks.Open(workbookPath, 0, true, 5, "", "", true, ExcelCreate.XlPlatform.xlWindows, "\t", true, false, 0, true);
ExcelCreate.Sheets excelSheets = book.Worksheets;
string currentSheet = "Hoja1";
ExcelCreate.Worksheet excelWorksheet = (ExcelCreate.Worksheet)excelSheets.get_Item(currentSheet);
ExcelCreate.Range excelCell = (ExcelCreate.Range)excelWorksheet.get_Range("A1", "A20");

Excel Assignment Information Code:

List<tb_uploadexcel> tbUpload = new List<tb_uploadexcel>();
        tbUpload = LoadTable();
        int RowCounter=0;

        foreach (var elemento in tbUpload)
        {
            excelWorksheet.Cells[RowCounter, 1] = elemento.UserUpload; --- ERROR
            RowCounter++;
        }
  

Error Message:

     

Exception from HRESULT: 0x800A03EC

    
asked by David 05.10.2018 в 18:07
source

0 answers