---
title: "Convert Excel to PDF in Just 5 Steps Using C#"
published_at: "2024-04-04T13:57:24+00:00"
modified_at: "2025-10-29T09:57:06+00:00"
url: "https://www.syncfusion.com/blogs/post/convert-excel-to-pdf-in-csharp"
excerpt: "Convert Excel to PDF with Syncfusion’s Excel Library in .NET Core using C#. No Office needed! Customize output, ensure PDF/UA compliance. Learn how in this guide!"
taxonomy_category:
  - "C#"
  - "Document Processing"
  - "Excel"
  - "Excel Library"
  - "File Formats"
  - "XlsIO"
taxonomy_post_tag:
  - ".NET Excel Library"
  - "C#"
  - "C# document automation"
  - "C# PDF conversion"
  - "C# programming"
  - "Document Processing"
  - "Essential XlsIO"
  - "Excel"
  - "Excel to PDF conversion"
  - "Excel-to-PDF"
  - "Export Excel to PDF"
  - "File Conversion"
  - "File Formats"
  - "Office Automation"
  - "PDF generation in C#"
  - "Syncfusion Excel Library"
  - "XLSX to PDF"
---

# Convert Excel to PDF in Just 5 Steps Using C#

[Mohan Chandran](https://www.syncfusion.com/blogs/author/mohan-chandran)

![Convert Excel to PDF in Just 5 Steps Using C#](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Convert-Excel-to-PDF-in-Just-5-Steps-Using-C.png)


**TLDR:** Learn how to build a .NET Core console app to convert Excel files to PDF using Syncfusion’s Excel Library (XlsIO) with C#, without Microsoft Office dependencies. Follow simple steps to create, configure, and execute the conversion, with customizable options like layouts, fonts, and PDF/UA compliance.

[Microsoft Excel](https://en.wikipedia.org/wiki/Microsoft_Excel)
 is a trusted tool for organizing, visualizing, and managing complex data. However, when you need to share data from an Excel workbook with other users, they will require Excel or an Excel file viewer to access it. To make sharing easier, you can convert Excel workbooks into the universal PDF format, allowing seamless access across various devices without the need for Excel.

The [Syncfusion® Excel Library](https://www.syncfusion.com/document-sdk/net-excel-library)
, also known as Essential XlsIO, is a powerful tool for creating, reading, and editing Excel documents using C# without any Microsoft Office dependencies. Its extensive capabilities include support in creating Excel workbooks from scratch, modifying existing ones, importing and exporting data, handling formulas, applying conditional formatting, managing data validations, and much more.

Let’s see how to convert an Excel workbook to a PDF document with the help of the Syncfusion® Excel Library using C#!


## Excel-to-PDF conversion

Our Excel Library can convert an [entire workbook or a single worksheet into a PDF document](https://www.syncfusion.com/document-sdk/net-excel-library/excel-to-pdf-conversion)
 using the built-in [Excel-to-PDF converter](https://help.syncfusion.com/file-formats/xlsio/overview-of-excel-to-pdf)
. With this, you can convert Excel formats such as XLSX, XLS, XLTM, XLSM, XLTX, CSV, TSV, and XML Spreadsheet to PDF.

You can customize the conversion process by using different layouts, embedding fonts, ignoring empty pages or worksheets, and managing the visibility of headers and footers. The Excel Library also supports [converting workbooks with charts to PDF](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-conversion#excel-with-chart-to-pdf)
, [substituting fonts](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-conversion#substitute-font-in-excel-to-pdf-conversion)
, [fallback fonts](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/excel-to-pdf-conversion#fallback-fonts)
during conversion, and many useful [conversion options](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-converter-settings)
. It supports creating [tagged PDFs](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/excel-to-pdf-converter-settings#tagged-pdf)
 from the Excel document conforming to the PDF/UA standard, along with the [PDF conformance level](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/excel-to-pdf-converter-settings#pdf-conformance-level)
.

The Excel to PDF conversion is fast, reliable, and compatible with hosting environments such as [AWS](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-aws)
, [Google Cloud Platform](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-gcp)
, and [Microsoft Azure Web Services](https://help.syncfusion.com/document-processing/excel/conversions/excel-to-pdf/net/convert-excel-to-pdf-in-azure)
.

## Steps to convert Excel to PDF using C#

Put simply, this is the procedure:

1. [Create a new .NET Core console application.](#Create)
2. [Install and configure the Excel Library.](#Install)
3. [Add namespaces.](#Add)
4. [Add Excel to PDF conversion code.](#Add%20Excel)
5. [Convert an XLSX file to PDF.](#Convert)

Let’s dig into these steps in detail.

### Step 1: Create a new .NET Core console application

First, create a new [.NET Core console application](https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio)
 in [Visual Studio](https://visualstudio.microsoft.com/vs/)
, as shown in the following figure:![Create a .NET Core Console application](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Create-a-.NET-Core-Console-application.png)

### Step 2: Install and configure the Excel Library

Add the [Syncfusion.XlsIORenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIORenderer.Net.Core)
 NuGet package to your application.![Install Syncfusion XlsIORenderer Net Core NuGet package](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Install-Syncfusion-XlsIORenderer-Net-Core-NuGet-package.png)


### Step 3: Add namespaces

Next, add the following namespaces to the **Program.cs** file.

```
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;
using Syncfusion.Pdf;
```

### Step 4: Add Excel to PDF conversion code

After that, implement the following code in the **Program.cs** file to convert an Excel document stream into a PDF stream of data.

```
static Stream ConvertExcelToPDF(Stream inputExcelData)
{
    MemoryStream pdfStream = new MemoryStream();

    //Instantiate the spreadsheet creation engine.
    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Instantiate the Excel application object.
        IApplication application = excelEngine.Excel;

        //Set the default application version.
        application.DefaultVersion = ExcelVersion.Xlsx;

        //Load the existing Excel file into IWorkbook.
        IWorkbook workbook = application.Workbooks.Open(inputExcelData);

        //Settings for Excel to PDF conversion.
        XlsIORendererSettings settings = new XlsIORendererSettings();
                
        //Set the layout option to fit all columns on one page.
        settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;

        //Initialize the XlsIORenderer.
        XlsIORenderer renderer = new XlsIORenderer();

        //Initialize the PDF document.
        PdfDocument pdfDocument = new PdfDocument();

        //Convert the Excel document to PDF.
        pdfDocument = renderer.ConvertToPDF(workbook, settings);

        //Save the PDF file.
        pdfDocument.Save(pdfStream);

        //Close the PDF document.
        pdfDocument.Close();

        //Close the workbook.
        workbook.Close();
    }

    return pdfStream;
}
```


### Step 5: Convert an XLSX file to PDF

Finally, add the following code to the **Main** method to pass the XLSX document to the ** ConvertExcelToPDF** method to convert to PDF format in the ** Program.cs** file.

```
static void Main(string[] args)
{
    string filePath = "../../../Data/Invoice.xlsx";
    Stream inputExcelData = File.OpenRead(filePath);
    Stream outputPDFData = ConvertExcelToPDF(inputExcelData);
    File.WriteAllBytes("../../../Output/Invoice.pdf", ((MemoryStream)outputPDFData).ToArray());
}
```

The following image shows the input Excel document:

![Input Excel Document](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Input-Excel-Document.png)

Input Excel Document

After executing the previous code example, the output PDF document will resemble the following image:

![Excel Workbook Converted to PDF Format Using Syncfusion® Excel Library and C#](https://www.syncfusion.com/blogs/wp-content/uploads/2024/04/Excel-Workbook-Converted-to-PDF-Format-Using-Syncfusion-Excel-Library-and-C.png)

Excel Workbook Converted to PDF Format Using Syncfusion® Excel Library and C#

**Note:** For more details, explore the [various Excel-to-PDF conversion settings](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-converter-settings)
.

## Reference

For more details, refer to the [documentation on converting an Excel workbook to a PDF document using C#](https://help.syncfusion.com/file-formats/xlsio/overview-of-excel-to-pdf)
 and [GitHub demos](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Real%20Time%20Examples%20in%20Excel/ExcelToPDF)
. Explore the online demo of [Excel to PDF](https://document.syncfusion.com/demos/excel/exceltopdf#/tailwind)
 conversion.


## Conclusion

Thanks for reading! In this blog, we explored how to convert Excel documents to PDF format in C# with the [Syncfusion Excel Library](https://www.syncfusion.com/document-sdk/net-excel-library)
. With it, you can also export Excel data to [images](https://help.syncfusion.com/file-formats/xlsio/worksheet-to-image-conversion)
, [data tables](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table)
, [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-html-table-to-excel-worksheet)
, [CSV](https://www.syncfusion.com/kb/9092/convert-excel-file-to-csv-in-c-vb-net)
, [TSV](https://www.syncfusion.com/kb/8556/does-xlsio-support-tsv-files)
, [collections of objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-clr-objects)
, [ODS](https://help.syncfusion.com/file-formats/xlsio/excel-to-ods-conversion)
, [JSON](https://help.syncfusion.com/file-formats/xlsio/excel-to-json-conversion)
, and more file formats.

Try out these conversions and share your feedback in the comment section of this blog post!

If you are new to our .NET Excel library, it is highly recommended that you follow our [Getting Started guide](https://help.syncfusion.com/file-formats/xlsio/getting-started-create-excel-file-csharp-vbnet)
.

Are you already a Syncfusion® user? You can download the product setup [here](https://www.syncfusion.com/account/downloads)
. If you’re not yet a Syncfusion® user, you can download a free, [here](https://www.syncfusion.com/downloads)
.

If you have any questions or require clarification about these features, please let us know in the comments below. You can also contact us through our [support forum](https://www.syncfusion.com/forums)
, [support portal](https://support.syncfusion.com/)
, or [feedback portal](https://www.syncfusion.com/feedback/)
. We are happy to assist you!

## Related blogs

- [Print Excel Documents in Just 4 Steps Using C#](https://www.syncfusion.com/blogs/post/print-excel-in-csharp.aspx)
- [Converting XLS to XLSX Format in Just 3 Steps Using C#](https://www.syncfusion.com/blogs/post/convert-xls-to-xlsx-csharp.aspx)
- [Merge Multiple Excel Files into One in Just 3 Steps Using C#](https://www.syncfusion.com/blogs/post/merge-multiple-excel-csharp.aspx)
- [6 Easy Ways to Export Data to Excel in C#](https://www.syncfusion.com/blogs/post/6-easy-ways-to-export-data-to-excel-in-c-sharp.aspx)
- [Seamlessly Import and Export CSV Data in Excel Using C#](https://www.syncfusion.com/blogs/post/import-export-csv-data-in-excel-csharp.aspx)
- [Easy Steps to Export HTML Tables to Excel in C#](https://www.syncfusion.com/blogs/post/easy-steps-to-export-html-tables-to-an-excel-worksheet-in-c.aspx)
