Setting FirstPageNumber property of PageSetup of Worksheet corrupts XLSX in .NET

This is the code I am using.

excelDocument.Worksheets[worksheetIter].PageSetup.FirstPageNumber = 7;
excelDocument.Save(m_MemoryStream, Aspose.Cells.SaveFormat.Auto);


Then I write the memory stream to the output of the HTTP Response.

When I open the Excel file it saves it is corrupted but if I save it as a Excel97To2003 explicitly then it opens fine.

Hi Rebecca,

Many thanks for providing the code information. Please send us the original template file in order invetigate the issue. The file which you have attached contains errors. The error message shows up when tries to open with MS Excel.

Thanks,

Hi,

I think you may change the code line:

excelDocument.Save(this.Response, Report.xlsx”, ContentDisposition.Attachment, new OoxmlSaveOptions());


Response.End();


If you still find the issue, kindly let us know.

Make sure that you have installed MS Excel viewer or MS Excel 2007 to view xlsx file format.

Thank you.

Hi,

Also, which version of the product you are using, kindly try the attached latest version v5.2.0.2

If you still find the issue, kindly give us a sample solution, zip it and post it here to show the issue, we will check it soon.

Thank you.