When you run the following code on a file that has any VBA macro's whatsoever:
using (ExcelPackage xlPackage = new ExcelPackage(new FileInfo("Test.xlsm")))
{
xlPackage.Workbook.Worksheets.Add("TestTab");
xlPackage.Save();
}
You get the following issue(upon opening the edited file):
We found a problem with some content in 'Test.xlsm'. Do you want us to recover as much as we can? If you trust the source of this workbook, click Yes.
(if you click yes)
Removed Part: /xl/vbaProject.bin part. (Visual Basic for Applications (VBA))
Then your VBA Marco is gone... I also have received:
The Visual Basic for Applications (VBA) macros in the workbook are corrupted and have been deleted. The macro corruption most likely exists in the current file. To recover the macros, open a backup copy of this file if you have one.
I only see this issue on the latest update(Office 365 Excel 1708 - 8431.2079). When I test on older versions of excel or on versions that have not been upgraded to the latest version I do not experience this issue.
It appears the latest office update has introduced this issue into the opening of files that have been modified(specifically when a new worksheet in inserted) by EPPlus(Latest 4.5.0).
Has anybody else experienced this issue? Maybe someone has a work around of some sort. I was hoping not to have to dig into the source code :(
Edit: Took Mr. Pie's advise and cloned the ticket, maybe someone clever than me has some insight into source: GitHub