PDF to XLS Converter
The Documentize PDF to XLS Converter for .NET is a versatile and powerful tool for converting PDF documents into Excel spreadsheets (XLS/XLSX). By leveraging this plugin, developers can seamlessly transform static PDF data into dynamic and editable spreadsheets, simplifying data manipulation, analysis, and sharing.
Key Features:
- Flexible Conversion Options: Convert PDF files into XLSX, XLS, CSV, or other formats.
- Content Preservation: Maintain the original structure, layout, and formatting.
- Customizable Output: Configure page ranges, worksheet names, and output formats.
- Batch Processing: Handle multiple PDF files simultaneously for high efficiency.
- Advanced Formatting: Insert blank columns or minimize the number of worksheets.
How to Convert PDF to Excel
To convert a PDF document into an Excel file (XLS/XLSX), follow these steps:
- Create an instance of the
XlsConverter
class. - Configure the conversion settings using the
PdfToXlsOptions
class. - Add input PDF files using the
AddInput
method. - Specify the output file path using the
AddOutput
method. - Execute the
Process
method to initiate the conversion.
1var converter = new XlsConverter();
2var options = new PdfToXlsOptions();
3
4// Add input and output file paths
5options.AddInput(new FileDataSource(@"C:\Samples\input.pdf"));
6options.AddOutput(new FileDataSource(@"C:\Samples\output.xlsx"));
7
8// Perform the conversion
9converter.Process(options);
Customizing the PDF to Excel Conversion
The PdfToXlsOptions
class allows you to customize the conversion process. For example, to convert the PDF to an XLSX file, set a worksheet name, and enable advanced formatting options:
1var options = new PdfToXlsOptions
2{
3 Format = PdfToXlsOptions.ExcelFormat.XLSX, // Specify XLSX format
4 WorksheetName = "MySheet", // Name the worksheet
5 InsertBlankColumnAtFirst = true // Insert a blank column at the start
6};
7
8// Add input and output files
9options.AddInput(new FileDataSource(@"C:\Samples\input.pdf"));
10options.AddOutput(new FileDataSource(@"C:\Samples\output.xlsx"));
11
12// Process the conversion
13converter.Process(options);
Batch Processing PDF to XLS Conversion
With batch processing, you can convert multiple PDF files into Excel spreadsheets in one go. Here’s an example:
1var converter = new XlsConverter();
2var options = new PdfToXlsOptions();
3
4// Add multiple input files
5options.AddInput(new FileDataSource(@"C:\Samples\file1.pdf"));
6options.AddInput(new FileDataSource(@"C:\Samples\file2.pdf"));
7
8// Specify output file paths
9options.AddOutput(new FileDataSource(@"C:\Samples\output1.xlsx"));
10options.AddOutput(new FileDataSource(@"C:\Samples\output2.xlsx"));
11
12// Perform the batch conversion
13converter.Process(options);
Handling Conversion Results
After the conversion process, the Process
method returns a ResultContainer
object that contains the details of the operation. Here’s how to retrieve the converted file path:
1var resultContainer = converter.Process(options);
2
3// Access the output file path
4var result = resultContainer.ResultCollection[0];
5Console.WriteLine("Converted file path: " + result.Data.ToString());
Supported Output Formats
The PdfToXlsOptions.ExcelFormat
enum provides a range of output formats:
- XLSX: Office Open XML (.xlsx) File Format (default).
- XLSM: Macro-enabled Excel format.
- CSV: Comma-separated values.
- ODS: Open Document Spreadsheet.
- XMLSpreadSheet2003: Excel 2003 XML format.