0

I am using EPPlus to export an excel file to a path. However, the export feels like it may be too slow, although I don't exactly have anything to compare it to. For a 7.5mb file (50,000 records and ~60 columns) it takes around 7 seconds for the pck.Save() line to execute.

How could I make it faster?

I'm not really sure what to try here to improve it, unless there's some faster ways I could go about exporting the file to a path.

public void ExportTableToGivenPath(DataTable DataTable, string Path)
{
    FileInfo File = new FileInfo(Path);

    //Before continuing make sure file that matched passed in is delete to prevent Exceptions
    if (File.Exists)
    {
        File.Delete();
    }

    using (ExcelPackage pck = new ExcelPackage(File))
    {
        ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Test");

        ws.Cells["A1"].LoadFromDataTable(DataTable, true);

        pck.Save(); //slow process here
    }
}
Lukas
  • 1,699
  • 1
  • 16
  • 49
  • I think 7 seconds should not be too slow for such a large data, you can refer to this discussion:https://stackoverflow.com/a/28220127/12884742 – LouraQ Apr 21 '20 at 08:57
  • Try doing a simple `for` loop instead of using `LoadFromDataTable`. The built in methods in Epplus can come with a performance hit since they are designed to handle all scenarios. – Ernie S Apr 22 '20 at 00:03

0 Answers0