We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Excel found unreadable content in the file


I have created a excel file in the 2007 xlsx format. Below is the code I u

Dim workSheet As Cells.Worksheet = workbook.Worksheets(0)

workSheet.Name = "Test"

workSheet.Cells.ImportDataTable(dtInput, True, "A1")

'dtInput is the dataset that contains data.


Dim stream As New System.IO.MemoryStream

workbook.Save(stream, Cells.SaveFormat.Excel97To2003)


HttpContext.Current.Response.AddHeader("cache-control", "private")

HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=Test.xlsx;")

HttpContext.Current.Response.AddHeader("Content-type", "application/vnd.ms-excel")



When I try and open the workbook. Excel displays the following message box:

Excel found unreadable content in 'Test.xlsx'. Do you want to recover the contents of
this workbook? If you trust the source of this workbook, click Yes.

I tried saving the same file in xls format and tried opening the file , then there is no error message getting displayed.

It is happening only when I save it as 2007 xlsx format.

Could you please help me in this..I am using Aspose.Cells version



I can see one obvious error in your code. Please change your line of code:
workbook.Save(stream, Cells.SaveFormat.Excel97To2003)
workbook.Save(stream, Cells.SaveFormat.Xlsx)

Thank you.

Hi Amjad,

Thanks for you reply. Yes, that was error in the code that was posted.But even after the change there is the same error message that is coming up.

Could you please look into this.



The following works fine and should work fine there.
'......... Your code goes here
Dim stream As New System.IO.MemoryStream
workbook.Save(stream, SaveFormat.Xlsx)
Response.ContentType = "application/vnd.openxmlformats"
Response.AddHeader("Content-Disposition", "attachment; filename=" + "Test.xlsx")
Dim buffer As Byte() = stream.ToArray()

By the way, you need to have Excel 2007/2010 installed on your PC to view the file on the fly.

Moreover, you may also try Workbook.Save() method instead of your manually Response object to streaming the Excel file to the client. The following methods works the same way as your manual code.

Sample code:


'Save in xlsx format and send the file to user so that he may open the file in

'some application or save it to some location

workbook.Save(Me.Response, "Test.xlsx", ContentDisposition.Attachment, New OoxmlSaveOptions())


Add the above line of code just after "workSheet.AutoFitColumns()" and delete all your existing code after that. The above code works fine with new versions. See the document for reference:

Thank you.