I'm using EPPlus to create and save an Excel file.
The method looks like this:
public static void CreateAnnuityExcelSheet(List<Calculation> cList, FormCollection form, int DTCyear, string path)
{
var StartValue = cList[0].StartValue;
var radio = form["advanceOrArrears"];
string fileName = cList[0].CalculationName;
FileInfo info = new FileInfo(path);
using (ExcelPackage package = new ExcelPackage(info))
{
ExcelWorksheet ws = package.Workbook.Worksheets.Add(fileName);
//Styles for the sheet
package.Save();
}
}
I have also tried using .SaveAs(info) but the result is the same for me.
Well, I now have the file saved under C:\ExcelFiles\ and let's say it's about 6kb, but when I open it in Excel and try to close it Excel want's me to save it. When I do, the size doubles (~12kb).
I did try open the unsaved, and the saved file, in notepad++ and I can see there is some difference in the files.
They really don't make much sense buy looking at them in notepad++, but here is how it looks:
The picture above is from the unsaved version. The saved one is looking pretty much the same (unreadable) just a lot bigger.
I now wonder if anyone could identify the problem? Have you had the same problem before?
It's not making a big trouble for me but it would be nice if the file was created "as it should" right away. Because when I try to upload and read the file, it has to be the saved version or everything crashes...