Convert XLS File to PDF in C# and VB.NET
This technical tip shows how an Excel XLS document can be converted to PDF file. Aspose.Cells component is designed to provide a fast and convenient way to convert any type of Excel spreadsheet into PDF format.
The purpose of this article is to demonstrate step by step process to do the conversion into PDF format. Since we all know the great essence of Excel files remains in: the cells are organized in rows and columns into different worksheets, and contain all types of data or formulas with relative or absolute references to other cells. The Intuitive interface related formatting and capable calculation and graphing ability which have made it the dominant spreadsheet in the market today. It not only has editing options, but also possesses the versatility of spreadsheet management. This makes it easier to perform statistical analyses and manipulations on any type of data of any volume.Similarly, PDF (Portable Document Format) has its own advantages. The file format represents documents in a manner that is independent of the original application software, hardware, and operating system used to create those documents.
Aspose.Cells is an ExcelŽ spreadsheet reporting component that enables you to read and write ExcelŽ spreadsheets without utilizing Microsoft ExcelŽ installed either on the client or server side. Aspose.Cells is a feature rich component that offers much more than just basic exporting of data. With Aspose.Cells , developers can export data, format spreadsheets in every detail and at every level, import images, import charts, create charts, manipulate charts, stream ExcelŽ data, save in various formats including XLS, CSV, PDF, SpreadsheetML, TabDelimited, TXT, XML ( Aspose.Pdf integrated) and many more. Aspose.Cells has a huge list of features.Please take a look over the following code snippet for this approach.
/// Use Aspose.Cells to perform the task
/// The main entry point for the application.
static void Main(string args)
// Uncomment the code below when you have purchased
// license for Aspose.Cells. You need to
// deploy the license in the same folder as your
// executable, alternatively you can add the license
// file as an embedded resource to your project.
// // Set license for Aspose.Cells
// Aspose.Cells.LicensecellsLicense = new
//Get the path of the Application folder.
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "..\\..");
//Get the template excel file path.
stringdesignerFile = path + @"\Files\PurchasingReport.xls";
//Specify the pdf file path.
stringpdfFile = path + @"\Files\PurchasingReport.pdf";
//Create a new Workbook.
//Open the template excel file which you have to
Aspose.Cells.Workbookwb = new Aspose.Cells.Workbook(designerFile);
//Save the pdf file.
catch (Exception e)
'Use Aspose.Cells to perform the task
' Uncomment the code below when you have purchased license
' forAspose.Cells. You need to deploy the
' license in the same folder as your executable, alternatively
' you can add the license file as an embedded resource to your
' ' Set license for Aspose.Cells
' DimcellsLicense As Aspose.Cells.License = New
'Get the path of the Application folder.
Dim path As String = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "..\")
'Get the template excel file path.
Dim designerFile As String = path + "\Files\PurchasingReport.xls"
'Specify the pdf file path.
Dim pdfFile As String = path + "\Files\PurchasingReport.pdf"
'Create a new Workbook.
'Open the template excel file which you have to convert
Dim wb As Aspose.Cells.Workbook = New Aspose.Cells.Workbook(designerFile)
'Save the pdf file.
Catch e As Exception