Xlsx file open with error 'Excel found unreadable content' in .NET

Hi,
I am using aspse.cell for .net version: v7.7.1.0.

my xlsx template have one pivot table which refer to one table in other tab.
see GBLU.xlsx file first.

my requirement is to filled in table content and refresh pivot table second.

my issue is that when I insert at least one record in the table and saved it out.
when Excel open this file, it will popup some error message.

I search some stuff in this forum, it seems this issue found out before.
but in my aspose.cell version, it seems it still encounter this issue.

Please advise how to avoid this error message popup, thx.
I am afraid Pivot Table always encountered this issue.

first excel is my template, second one is my output excel.
error message will popu when I open second one.
My office is Excel 2010, 64 bit. my code is simple as below:

[HttpGet]
public void ExportGBLUReport(string Region, int CountryId, string Year)
{
var excelFilePath = System.Web.HttpContext.Current.Server.MapPath(GBLUFileName);
FileStream stream = new FileStream(excelFilePath, FileMode.Open,FileAccess.ReadWrite,FileShare.ReadWrite);
Workbook workbook = new Workbook(stream);

//populate lu tab
var luGrid = this.RetrieveGBLUGrid(Region, CountryId, Year);
Worksheet luSheetView = workbook.Worksheets[“Legislative Updates”];
int startRowIndex = 1;
foreach (var item in luGrid)
{
luSheetView.Cells[startRowIndex, 0].Value = GetCountryName(item.CountryId);
luSheetView.Cells[startRowIndex, 1].Value = string.Format("{0}-{1}", item.Year, item.Month);
luSheetView.Cells[startRowIndex, 2].Value = item.EmployerActionRequiredByLaw;
luSheetView.Cells[startRowIndex, 3].Value = item.Summary;
luSheetView.Cells[startRowIndex, 4].Value = item.HRArea;
luSheetView.Cells[startRowIndex, 5].Value = item.LawInForce;
luSheetView.Cells[startRowIndex, 6].Value = item.NewLaw;
luSheetView.Cells[startRowIndex, 7].Value = item.ImpactByEmployers;

startRowIndex++;
break;//only populate one row
}

////Save file and send to client browser using selected format
workbook.SaveOptions.ClearData = true;
string CurrectDate = System.DateTime.Now.Date.ToString(“dd-MMM-yyyy”);
workbook.Save(System.Web.HttpContext.Current.Response, ReportType.GlobalBenefitsLegislativeUpdates + " (" + CurrectDate + “).” + “XLSX”,
ContentDisposition.Attachment, new XlsSaveOptions(Aspose.Cells.SaveFormat.Xlsx));
//end response to avoid unneeded html
System.Web.HttpContext.Current.Response.End();
}

Hi,

Thanks for your posting and using Aspose.Cells.

Mostly this issue occurs because of some bug in your older version. Please note, we cannot fix issues in older versions. We can only fix issues if they are found in latest versions. So, please give a try to latest version: Aspose.Cells
for .NET v8.3.2.3
and let us know your feedback.

If the issue is still occurring with the latest version, we will log it in our database so that it could be fixed in the newer versions.

Also please use OoxmlSaveOptions instead of XlsSaveOptions if you want to save your file in XLSX format. XlsSaveOptions is used for XLS format.

Here is the proper way to save your output in XLSX format in response stream.

workbook.Save(HttpContext.Current.Response, “output.xlsx”, ContentDisposition.Attachment, New OoxmlSaveOptions(SaveFormat.Xlsx))