Home » excel » excel file created with EPPlus, displaying message while opening that file has to repair, click yes

excel file created with EPPlus, displaying message while opening that file has to repair, click yes

Posted by: admin March 9, 2020 Leave a comment

Questions:

After click yes, it is showing:

Repaired Records: String properties from /xl/sharedStrings.xml part(Strings)

Repaired Records: Table from /xl/tables/table.xml part(Table)

I think there is no problem in code, but still here is my code what I am using to create Excel.

using (var package = new ExcelPackage(newFile)) {
     ExcelWorksheet worksheet = null;
     worksheet = package.Workbook.Worksheets.Add(dataToExcelExport.TableName);
     worksheet.Cells["A1"].LoadFromDataTable(dataToExcelExport, true, 
                                             OfficeOpenXml.Table.TableStyles.None);
     worksheet.Row(1).Style.Font.Bold = true;
     worksheet.Column(4).Width = 55.00;
     worksheet.Column(4).Style.WrapText = true;
     worksheet.Cells[1, 1, worksheet.Dimension.End.Row, 3].AutoFitColumns();
     package.Save();
     worksheet.Dispose();
}
How to&Answers:

When I encountered this issue while using EPPlus it was because I was trying to exceed limits imposed by Excel.

In my case I was trying to insert more than 32,767 characters in a cell.

Limits for Excel are given here:
https://support.office.com/en-MY/article/Excel-specifications-and-limits-16c69c74-3d6a-4aaf-ba35-e6eb276e8eaa