Posted 16 February 2021, 10:53 am EST
I’m using Active Reports 15 to export a code based section report to xlsx in .net MVC.
I use the following code to do that which exports a .xlsx file but when I open it in Excel I get a “We found a problem with some content in Report.xlsx. Do you want us to try recover as much as we can?” error.
If I press yes the file opens in Excel with this message “Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.”
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;fileName=Report.xlsx");
var export = new XlsExport();
export.FileFormat = FileFormat.Xlsx;
var memStream = new MemoryStream();
export.Export(theReport.Document, memStream);
Response.BinaryWrite(memStream.GetBuffer());
Response.End()