Convert Excel XLSX to PDF csharp

Convert Excel XLSX to PDF csharp

Enhance the readability and usability of your Excel files by converting them into PDF file formats. Excel to PDF conversion process is now quick and efficient due to this .NET Excel library. This library lets you convert multiple Excel sheets to one PDF page or multiple PDF pages. Moreover, you can configure the API calls as per your requirements. In the recent past, we published an article that demonstrates the PDF to Excel conversion. However, in this blog post, we will learn how to convert Excel XLSX or XLS to PDF in C# programmatically.

We will cover the following points:

.NET Excel Library Installation

The installation process of this API is simple as you can find comprehensive documentation regarding installation and its usage.

So, there are two ways that you can integrate this library with your .NET project.

Therefore, you can either download the DLL files or run the following command in the NuGet package manager.

Install-Package Aspose.Cells

Convert Excel to PDF in C#

Once the installation is done, you are ready to write code snippets to meet your business requirements regarding Excel to PDF conversion.

You can follow the following steps and the code snippet to convert the Excel sheet to PDF file format:

  1. Create an object of the WorkBook class and load the source Excel file.
  2. Convert XLSX to PDF format by calling the Save method.

You can see the output in the image below:

Excel to PDF in C#

XLSX/XLS to PDF Converter - Advance Options

In the above section, we have seen that just two lines of code do all magic. However, there are many other methods and properties available that you may check out.

We will explore some of the prominent properties:

  1. Initialize an instance of the WorkBook class and load the source Excel file.
  2. Create an object of the PdfSaveOptions class to access PDF options.
  3. If true and the directory does not exist, CreateDirectory will create the directory before saving the file.
  4. Access the first worksheet in the Excel file by creating an object of the Worksheet class.
  5. Invoke the HideRow method to hide the 3rd row of the worksheet.
  6. Hiding the 2nd column of the worksheet by calling the HideColumn method.
  7. Invoke the Save method to convert Excel XLSX to PDF format.

Get a Free License

You can get a free temporary license to try the API without evaluation limitations.

Summing up

This brings us to the end of this blog post. We have learned how to convert Excel to PDF in C# programmatically. We also have explored some advanced methods and properties to export XLSX or XLS Excel spreadsheets to PDF in .NET applications. There are many other properties and methods available that you can check in the documentation. Moreover, you can find some relevant topics in the “See Also” section below. Finally, conholdate.com is writing new blog posts on other exciting topics. Therefore, please stay in touch for the latest updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

How to convert Excel to PDF using the C# library?

Install this powerful library .NET Excel library to achieve the Excel to PDF conversion. It offers a huge stack of methods that help you automate this conversion and manipulation.

How do you convert an Excel sheet to PDF?

You can convert an Excel sheet to PDF file format using the following steps and the code snippet:

  1. Create an object of the WorkBook class and load the source Excel file.
  2. Save the document in PDF format by calling the save method.

How do I convert XLSX to PDF for free?

You can automate this conversion process by installing this .NET library. It offers various subscription plans and also comes with a free plan.

See Also