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

Free Support Forum - aspose.com

Convert Worksheet to PDF


I am trying to convert excel output to pdf. The content is generated programmatically and then I am trying to get the output as pdf. I am using the below code. (NOTE: excel is Worksheet object. )

excel.Save(outputStream, Aspose.Cells.FileFormatType.AsposePdf)

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()

pdf.BindXML(outputStream, Nothing)


excel = Nothing

outputStream.Seek(0, SeekOrigin.Begin)

Response.AddHeader("Content-Disposition", "attachment; filename=report.PDF")

Response.ContentType = "application/pdf"



The promt to open PDF file is coming, but when I click on Open I get the error message: "Adobe Reader could not open 'report.PDF' because it is either not a supported file type or because the file has been damaged."

Can anyone help. Thanks in advance.


Thanks for the post. Can you please try the attached version of Aspose.Cells for .NET? Also please give a try to the following code after creating the Workbook through the attached version:

     'Save Xls File to PDF
book.Save(“Xls2Pdf.pdf”, FileFormatType.Pdf, SaveType.OpenInExcel, System.Web.HttpContext.Current.Response)

'End response to avoid unneeded html after xls
Where book is Workbook object. If the problem persists, please provide a sample project exhibiting the problem so that we can reproduce the issue.

Best Regards


Thanks for the above reply.

I tried as you said but unfortunately, it is not working. I am getting the same error again.

Also, as I said above in the told, is it possible to use System.IO.Filestream (outpuStream) object instead of saving as Xls2Pdf.pdf

Thank you.


Yes, it should work as well.

Can you please provide some sample project in order to investigate the issue you are facing?

Best Regards


With the below code it is working.

excel.Save("Xls2Pdf.pdf", FileFormatType.Pdf, SaveType.OpenInExcel, System.Web.HttpContext.Current.Response)

As said in earlier threads I was creating Aspose.pdf.pdf object. Now I removed the code to create Aspose.pdf.pdf object and it is working now.

Thank you.