If you have Excel spreadsheets generated from .NET Standard 2.0 applications, you may find it useful to store your files in a PDF format.

Why do I need to convert an Excel spreadsheet to PDF?

Several reasons include:

  • You want to store Excel spreadsheets for long-term preservation.
  • You do not have MS Office installed on your system, but you still want to print or distribute your Excel spreadsheets.
  • You want your Excel spreadsheets to look consistent when opened on different systems.

Alternatively, you may need to create and distribute the following company reports:

  • Profit & Loss Statement
  • Company Budget
  • Sales Forecast
  • Income Statement

GrapeCity Documents for Excel (GcExcel) is a high-speed, small-footprint spreadsheet API that requires no dependencies on Excel. With full .NET Standard 2.0 support, you can generate, load, modify, and convert spreadsheets in .NET Framework, .NET Core, Mono, and Xamarin. Apps using this spreadsheet API can be deployed to cloud, Windows, Mac, or Linux.

Convert Excel Spreadsheets to PDF

Download the latest version of GrapeCity Documents for Excel

Download Now!

Exporting Excel Spreadsheets to PDF in .NET

In this demo we will cover the following:

  • How to create an Excel Spreadsheet and save to PDF
  • How to load an Excel Spreadsheet and save to PDF

Note: When working with GcExcel on MAC, Linux, you need to specify the Workbook.FontFolderPath and place the necessary fonts in it, before exporting spreadsheets to PDF.

For more information, visit: Configure Fonts and Set Style.

Step 1: Create an Excel Spreadsheet:

Follow this link to create a basic Excel spreadsheet on Windows, MAC or Linux.

After end of this tutorial, your Spreadsheet would look like this:

Create an Excel Spreadsheet

Step 2: Convert Excel Spreadsheets to PDF

In Step 1, we created an Excel spreadsheet using GcExcel workbook and saved it to Excel file. Instead of saving to Excel, you can directly save the workbook to PDF using following code:

 workbook.Save(@"SimpleBudget.pdf",SaveFileFormat.Pdf);

Your PDF would look like this:

Convert Excel Spreadsheets to PDF

Step 3: Load Excel spreadsheet and save to PDF

If you want to convert any of your Excel files, (whether created with GcExcel or from another third-party tool) you can do so in just three steps using GcExcel.

Suppose you want to convert an Excel file, that calculates the summary of the total account data (as per different age groups in a region) to a PDF.

Convert Excel Spreadsheets to PDF

You can follow these steps:

Create an empty workbook

var workbook = new GrapeCity.Documents.Excel.Workbook();

Load Excel file into the workbook

var fileStream = new FileStream("AgingReport.xlsx", FileMode.Open);
workbook.Open(fileStream);

Save To PDF

workbook.Save("AgingReport.pdf", SaveFileFormat.Pdf);

You have converted your excel spreadsheet to PDF!

Convert Excel Spreadsheets to PDF

Convert Excel Spreadsheets to PDF

Supported PDF export features include:
  • Set page setup
  • Text
  • Number formats
  • Overflow text
  • Font effects
  • Borders
  • Conditional formatting
  • Picture
  • Fills
  • Sparklines
  • Table
  • Save the workbook to PDF
  • Save worksheet to PDF
  • Set font's folder

Try the demo here.

If you are looking for additional features or if you have a request for a demo, please leave a comment below!

Custom Code Your Spreadsheets in .NET

Download the latest version of GrapeCity Documents for Excel

Download Now!