How to convert Excel files to PDF inside .NET?

Our developer’s group have got interesting query from a customer. They have to create an online converter of excel files to PDF on the corporate website!
By: Yana
 
Sept. 23, 2011 - PRLog -- Our developer’s group have got interesting query from a customer. They have to create an online converter of excel files to PDF on the corporate website!
The problem was this: client’s company keeps on its server statistics reports in xls/xlsx, which had to be displayed on browser by customer's request. User which sees report must have no possibility of making any changes and editing. Therefore they decided to export Excel files into PDF format, since most modern browsers have the ability to display it. To solve the exporting problem, we offered to our client «Excel to PDF .Net» component which can convert at server side. The component has satisfied customer requirements: to be independent of MS Office Automation and works at Medium trust level.
Our developer’s group has prepared this code to the customer:
    SautinSoft.ExcelToPdf x = new SautinSoft.ExcelToPdf();

       byte[] excelBytes = … //get Excel byte stream here
       byte[] pdfBytes = null;

       int i = x.ConvertBytes(excelBytes, ref pdfBytes);        
       
       //show PDF
       if (pdfBytes != null)
       {
           Response.Buffer = true;
           Response.Clear();
           Response.ContentType = "application/PDF";
           Response.AppendHeader("content-disposition", "attachment; filename=Result.pdf");
           Response.BinaryWrite(pdfBytes);
           Response.Flush();
           Response.End();
       }

By clicking the button «Print to PDF», server gets a query to convert corresponding xls/xlsx file. Next the component makes conversion to PDF at server side and returns PDF document to client’s browser. Browser displays this PDF to user or offer to save it on HDD.
The problem is solved!
End
Source:Yana
Email:***@sautinsoft.com Email Verified
Tags:Excel To Pdf, Net
Industry:Software
Location:Votkinsk - Udmurt Republic - Russian Federation
Account Email Address Verified     Account Phone Number Verified     Disclaimer     Report Abuse
Sautinsoft News
Trending
Most Viewed
Daily News



Like PRLog?
9K2K1K
Click to Share