Free Support Forum - aspose.com

ASP.NET code to generate pdf file by calling an Excel file

Hi,

This is ajay asthana.I am working in e-enable technologies. I have problem to generate pdf file from excel file at run time.

First i generate Excel file then convert it to pdf file. I need solution to directly generate pdf file at run time.

Please sent a code in asp.net to generate pdf file at run time.

ajayasthana@hotmail.com

09335461938

Thanks & regards

from

Ajay Asthana

To convert an Excel file to pdf file in an asp.net app, please try this piece of sample code:

Excel excel = new Excel();
excel.Worksheets[0].Cells["a1"].PutValue("hello");

// or you can call following piece of code to open an Excel file in memory

//excel.Open(excelStream, FileFormatType.Default);

MemoryStream stream = new MemoryStream();
excel.Save(stream, FileFormatType.AsposePdf);

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(stream, null);
pdf.Save("d:\\test\\abc.pdf"); // you can change this line of code to save the file to stream