Aspose Excel To Pdf. Open in Browser Issue?

Hello,
I am trying the Excel to Pdf convert feature. Although it works fine when i try to save it to a file as shown below, if I try to save it using the browser then the generated pdf file is corrupted and does not open. Is this a known issue ? Any fixes ?
Thanks for the great product,
Anirudh

ps : this is the code

excel.Save(path + “\MySpreadsheet.xml”, FileFormatType.AsposePdf);

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();

pdf1.BindXML(path + “\MySpreadsheet.xml”, null);

// THIS IS NOT WORKING

//pdf1.Save( “MySpreadsheet.pdf”, Aspose.Pdf.SaveType.OpenInBrowser , this.Response);

pdf1.Save( path + “\MySpreadsheet.pdf” ) ;

Hi,

Thank you for considering Aspose.

Please try adding this line at the end:
Response.End();

If it still won’t work, please send a complete example to me and let me test it.

That worked great ! Thanks a lot.
We might now end up buying both the Excel and the Pdf.
Good work !
Thanks
Anirudh

@anirudh,
Aspose.Cells has replaced Aspose.Excel that is discontinued and no more available for download now. This new product Aspose.Cells supports all the features in its predecessor as well as support for the latest features in different versions of MS Excel. You can save the file to response object and also there are lot of options available to convert Excel file to PDF using PdfSaveOptions. Here is a simple example that can be used to save file to response object.

HttpResponse Response = null;

// Creating a Workbook object
Workbook workbook = new Workbook();

if (Response != null)
{
    Aspose.Cells.PdfSaveOptions pdfSaveOpt = new Aspose.Cells.PdfSaveOptions();

    pdfSaveOpt.Compliance = PdfCompliance.PdfA1b;
    pdfSaveOpt.EmbedStandardWindowsFonts = true;
    pdfSaveOpt.DefaultFont = "Arial";
    pdfSaveOpt.OutputBlankPageWhenNothingToPrint = false;

    // Save in Pdf format
    workbook.Save(Response, dataDir + "output.pdf", ContentDisposition.Attachment, pdfSaveOpt);
    Response.End();
} 

You may refer to the following article for more information:
Saving File to Response Object

The latest free trial version can be downloaded here:
Aspose.Cells for .NET(Latest version)

For detailed testing of this new product download a runnable solution here.