Home » excel » c# – How to fix slow performance with epplus?

c# – How to fix slow performance with epplus?

Posted by: admin May 14, 2020 Leave a comment


I am loading in an Excel file for bulk updating data in master data. I have 4 sheets. Export, counties, organizations, settings. Only export is visible. Everything else is hidden.

The loading of the file was really slow. Takes up to 2-3 minutes.

I have already found the issue. When I unhide every sheet, and load the file, then there is no performance issue at all. We do not want to show the sheets, to avoid confusion to our customers. I have made a small console app to test this behavior.

private static void Main(string[] args)
            using (var package = new ExcelPackage(new FileInfo(@"")))
                var wb = package.Workbook;
                var wsheets = wb.Worksheets;
                var settings = wsheets["Settings"];


wb is fast
wsheets is really slow when my sheets are hidden, really fast when not.
getting settings one wsheets is loaded is fast.

What should I do, besides unhiding my sheets?


We debugged the issue further down, the hidden/unhidden columns was a false positive. When we stop debugging and start it again, the debugger is still somehow able to pick up the old result because of the huge timeout.

I have now found the real culprit. When we export a file using EPPLUS, the end user is supposed to edit data, upload it back to the UI for validation. When the user uploads the same file, as the one being exported without editing the file, this long operation occurs.

It is a pretty weird behavior, but since everyone is supposed to edit the file and save it, I will no longer put time in trying to solve this.

How to&Answers:

You can update your worksheets in unhide mode and then hide them by using this property

worksheet.Hidden = OfficeOpenXml.eWorkSheetHidden.Hidden;


worksheet.Hidden = OfficeOpenXml.eWorkSheetHidden.VeryHidden;

You can also unhide them via code using

worksheet.Hidden = OfficeOpenXml.eWorkSheetHidden.Visible;