Getting error after saving Excel file (.Xlsm)

Hi am getting error while open a excel file,
the file is saved on my db as memory and and file containing some pivot table and conditional formatting.

Error is: Removed Part: /xl/pivotTables/pivotTable1.xml part with XML error. (PivotTable view) Load error
and code is:
workbook.Save(HttpContext.Current.Response, HttpUtility.UrlPathEncode(erg.FileName), ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsm));

please help!

@vijayman,

We need a standalone simulation application (preferably a console application) that should be executed seamlessly using your template files (if any). So, please do the needful and create a separate application (runnable), zip the project and post us here, we will check it soon.

PS. Please remove any inter dependencies for external data source and use only dynamic dataset/datatable in code, so we could evaluate and execute your code to reproduce it first before we figure it out soon.