Convert an XLS File to PDF Format

Converting Excel to PDF

This example uses an Excel file (SampleInput.xlsx) as a template. The workbook contains worksheets with charts and image. Each worksheet contains different types of formats using fonts, attributes, colors, shading effects and borders. There’s a column chart on the first worksheet and an image on the last.

The Template Excel File

The template file has three worksheets, including charts and image as Media. The first worksheet has charts and last worksheet has an image as shown below in the screenshots.

todo:image_alt_text todo:image_alt_text
The first worksheet (Sales Forecast) The second worksheet (Sales Report)
todo:image_alt_text todo:image_alt_text
The third worksheet (Data Entry) The last worksheet (Image)

Conversion Process

  1. Download and install Aspose.Cells:
    1. Download Aspose.Cells for .NET.
    2. Install it on your development computer.
  2. Create a project and add references:
    1. Start Visual Studio.Net.
    2. Create a new console application.
    3. Add a reference to …\Program Files\Aspose\Aspose.Cells\Bin\Net1.0\Aspose.Cells.dll
  3. Add the conversion code to the project:

Result

when the above code has been run, a PDF file is created in the Files folder in your application directory. The following screenshots show the PDF pages. Note that headers and footers are also retained in the output PDF file.

todo:image_alt_text todo:image_alt_text
The first worksheet (Sales Forecast) The second worksheet (Sales Report)
todo:image_alt_text todo:image_alt_text
The third worksheet (Data Entry) The last worksheet (Image)