I want to generate excel report using EPPlus library. Here is my code for loading file in initialization:
ExcelPackage pkg = new ExcelPackage(new FileInfo(filePath));
I face the OutOfMemoryException
because of large data in my report. An codeproject article describes how to create large excel report. The author approach is to save report for portion of data into Excel file, close the package and then reopen the excel file and add another portion of data to it and so on... . I applied this to my project:
//Going to save log package.
pkg.Save();
//Package saved and Disposed.
var fileInfo = pkg.File;
//Again loading file into package...
pkg.Load(new FileStream(fileInfo.FullName, FileMode.Open));
The point here is that when I Save package, it will be disposed automatically. After disposing I suppose that memory will be released, but when I see the task manager it does not happens. After that I again load excel file as discribed in another post in stackoverflow.