Can't open excel file generated with excelLibrary

后端 未结 3 2016
粉色の甜心
粉色の甜心 2020-12-17 15:19

I\'m using excelLibrary to programatically create excel files but I get a file format error when I try to open the generated files in Microsoft Office Excel.

I\'ve s

相关标签:
3条回答
  • 2020-12-17 15:33

    Unfortunately excel file exported with excelLibrary are not compatible with office 2010 Excel, this is an already reported issue but seems that the library development is no longer active .

    I've switched to NPOI .

    0 讨论(0)
  • 2020-12-17 15:40

    Found a solution :

    string filename = "c:\Test.xls";
    Workbook workbook = new Workbook();
    Worksheet sheet = new Worksheet("Test")
    workbook.Worksheets.Add(sheet)
    
    for(int i = 0;i < 100; i++)
          sheet.Cells[i,0] = new Cell("");
    
    workbook.save(filename);
    

    The problem is that Office 2010 doesn't support it unless there are 100 or more Cells Filled.

    My work around was to have it fill 100 cells in a for loop with "". That way it gets it's 100 cell count in and then it works just fine.

    Reference : here

    0 讨论(0)
  • 2020-12-17 15:41

    Since the sheet name is not given properly, it was throwing that error.

    Once we give the sheet a name, it will work properly.

    0 讨论(0)
提交回复
热议问题