We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert Excel to PDF in C#, VB.NET

Syncfusion Excel (XlsIO) library is the .NET Excel library used to create, read, and edit Excel documents. Excel helps in daily life to manage records, analyze data, calculations, analytical tool for business and visualization. PDF (Portable Document Format) is one of the file formats like Excel and it can capture all the elements of a printed document as an electronic image that you can view, navigate, and print. Syncfusion Excel (XlsIO) library helps you to convert Excel file to PDF in C# and VB.NET.

XlsIO helps to convert Excel to PDF by loading the workbook or worksheet into ExcelToPDFConverter and converts the loaded document using Convert method. This conversion is supported in the platforms like Windows Forms, WPF, ASP.NET, ASP.NET MVC, ASP.NET Core, Xamarin and Azure.

This article shows you how to convert Excel to PDF in C#, VB.NET.

Steps to convert an Excel file to PDF programmatically:

Step 1: Create a new C# console application project.

Create a new C# console application

Create a new C# console application

Step 2: Install Syncfusion.ExcelToPdfConverter.WinForms NuGet package as a reference to your .NET Framework applications from the NuGet.org.

Install NuGet package

Install NuGet package

Step 3: Include following namespaces in the Program.cs file.


using Syncfusion.ExcelToPdfConverter;
using Syncfusion.Pdf;
using Syncfusion.XlsIO;
using System.IO;
using System.Reflection;



Imports System.IO
Imports System.Reflection
Imports Syncfusion.ExcelToPdfConverter
Imports Syncfusion.Pdf
Imports Syncfusion.XlsIO


Step 4: Open an existing Excel document or create a new document and load it into IWorkbook instance.


//Initialize Application
IApplication application = excelEngine.Excel;
//Set the default application version as Xlsx
application.DefaultVersion = ExcelVersion.Xlsx;
//Open existing workbook with data entered
Assembly assembly = typeof(Program).GetTypeInfo().Assembly;
Stream fileStream = assembly.GetManifestResourceStream("ExcelToPDFConversion.Sample.xlsx");
IWorkbook workbook = application.Workbooks.Open(fileStream);



'Initialize Application
Dim application As IApplication = excelEngine.Excel
'Set the default application version as Xlsx
application.DefaultVersion = ExcelVersion.Xlsx
'Open existing workbook with data entered
Dim assembly As Assembly = GetType(Program).GetTypeInfo.Assembly
Dim fileStream As Stream = assembly.GetManifestResourceStream("ExcelToPDFConversion.Sample.xlsx")
Dim workbook As IWorkbook = application.Workbooks.Open(fileStream)


Step 5: Convert the Excel file to PDF.


//Initialize ExcelToPDF Converter
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
//Initialize PDF document
PdfDocument pdfDocument = new PdfDocument();
//Convert Excel document into PDF document
pdfDocument = converter.Convert();
//Save the PDF file



'Initialize ExcelToPDF Converter
Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)
'Initialize PDF document
Dim pdfDocument As PdfDocument = New PdfDocument
'Convert Excel document into PDF document
pdfDocument = converter.Convert
'Save the PDF file


A complete working example to convert Excel file to PDF along with the input file used for conversion can be downloaded from Convert-Excel-to-PDF-Sample.zip.

By executing the program, you will get the PDF file as below.

Convert an Excel file to PDF

Output PDF document

Know more about Syncfusion Excel (XlsIO) library through the documentation, where you can find the supported features like Excel file with worksheets, charts and chart sheets to PDF conversion and different printer settings along with Worksheet to Image conversion, Chart to Image conversion and Excel to ODS conversion.

An online sample link for Excel to PDF conversion.

To learn more about the Syncfusion Excel (XlsIO) library, refer to the documentation where you will find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheet or workbook, organizing and analysing data through Tables and Pivot Tables, appending multiple records to worksheet using Template Markers with code examples.

See Also:

How to convert the PDF document into Excel

Convert Excel to PDF with Azure function in .NET Standard application

Convert Excel to PDF in Azure platform

How to convert an Excel file to CSV

How to convert Excel worksheet to image


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile