Unreadable content in Excel file generated with EPPlus

前端 未结 7 981
谎友^
谎友^ 2021-01-04 02:57

I\'m having a little problem when I generate an Excel file from a template, using the EPPlus library. The file has a first spreadsheet that contains data that is used for po

7条回答
  •  日久生厌
    2021-01-04 03:28

    Different setup (returning a stream), but same problem (corrupted table record). In my case the problem was the explicit call to ExcelPackage.Save():

    using (var excelPackage = new ExcelPackage())
    {
        /* ... removed code for clarity */
    
        // caused the stream to contain the file 2 times, 
        // save is already called by GetAsByteArray()                
        //excelPackage.Save(); 
    
        return new MemoryStream(excelPackage.GetAsByteArray());
    }
    

提交回复
热议问题