How to Convert PDF to Excel in C# .NET – PDF to XLS or XLSX

PDF to Excel in C# .NET

PDF to Excel conversion is an important use case when you need to export the tabular data from PDF documents to Excel spreadsheets. Copying/exporting the data from PDF to Excel manually could be a time-consuming task when you are dealing with a bunch of documents. So why not automate this process and minimize the time and effort? In this article, you will learn how to convert PDF to Excel programmatically using C# .NET.

Converting PDF to Excel in C# .NET

This article covers the following PDF to Excel conversions using C#.

  • Converting PDF to XLS format.
  • Converting PDF to XLSX format.
  • Inserting a blank first column in converted Excel worksheet.
  • Minimizing the number of worksheets in the converted Excel spreadsheet.

For PDF to Excel conversion in C#, we’ll use Aspose.PDF for .NET API that supports creating and manipulating PDF documents as well as converting PDF files to other formats. You can either download DLL of the API or install it using one of the following ways.

Install via NuGet Package Manager

  • Open/create the project in Visual Studio.
  • Go to NuGet Package Manager and search Aspose.PDF.
  • Install the API.

Install via Package Manager Console

PM> Install-Package Aspose.PDF

Converting PDF to XLS in C#

In order to convert a PDF document to the XLS spreadsheet, you can simply load the PDF file and save it with the “.xls” extension. The following code sample shows how to convert PDF to Excel in XLS format using C#.

PDF Document

Converted Excel Spreadsheet

Converting PDF to XLSX in C#

By default, Aspose.PDF converts the PDF document to XLS format. In case you want to get the converted Excel spreadsheet in XLSX format, you can specify it using ExcelSaveOptions class. The following code sample shows how to convert a PDF document to Excel with XLSX format using C#.

Convert PDF to Excel with a Blank First Column

You can also insert a blank first column in the converted Excel spreadsheet. This can be done using ExcelSaveOptions.InsertBlankColumnAtFirst option as shown in the following code sample.

Convert PDF to Excel with Minimized Number of Worksheets

By default, every page in the input PDF document is converted into a separate worksheet. For the large PDF documents with a number of pages, the converted Excel spreadsheet will also contain a number of worksheets. In such a case, you can customize the PDF to Excel conversion and minimize the number of worksheets in the converted spreadsheet using ExcelSaveOptions.MinimizeTheNumberOfWorksheets option.

The following code sample shows how to minimize the number of worksheets in PDF to Excel conversion using C#.

Read more about Aspose.PDF for .NET here.

Related Article(s)