PDF Documents can be avoided and prevented ⽌ He ⼈⽆ Touch the keyboard to modify ⽂ It's about . But in avoiding others ⽆ At the same time, it also hinders the normal modification . If you want to process or modify PDF Data in documents , Try it Excel To achieve .Excel It has powerful data processing function , Rich chart drawing functions , Rich automation functions . This article will be divided into two parts to introduce you in detail how to C#/VB.NET Code will PDF To Excel Format . You can do this in a few simple steps , Please read the following for details .
take PDF To Excel
Add multiple pages PDF Convert to a Excel Worksheet
Class library introduction and code ideas
Method 1:
Introduce... Into the program Spire.PDF.dll file ; take Free Spire.PDF for .NET Download to local , decompression , find BIN Under folder Spire.PDF.dll. And then in Visual Studio Open in “ Solution explorer ”, Right click “ quote ”,“ Add reference ”, The local path BIN Under folder dll Add a reference to the program .
Method 2:
adopt NuGet install . This can be done by 2 Methods of installation :
1. Can be in Visual Studio Open in “ Solution explorer ”, Right click “ quote ”,“ management NuGet package ”, And then the search “Free Spire.PDF”, Click on “ install ”. Wait for the program installation to complete .
2. Copy the following to PM Console installation .
Install-Package FreeSpire.PDF -Version 8.2.0
take PDF To Excel
Specific steps :
establish PdfDocument Class object .
call PdfDocument.LoadFromFile() Method loading PDF file .
adopt PdfDocument.SaveToFile() Method as Excel File format to specified path .
Complete code :
【C#】
using Spire.Pdf; using Spire.Pdf.Conversion; namespace ConvertPdfToExcel { class Program { static void Main(string[] args) { // establish PdfDocument Class object PdfDocument pdf = new PdfDocument(); // load PDF file pdf.LoadFromFile("TableSample2.pdf"); // preservation PDF by XLSX file pdf.SaveToFile("PdfToExcel2.xlsx", FileFormat.XLSX); } } }
【VB.NET】
Imports Spire.Pdf Imports Spire.Pdf.Conversion Namespace ConvertPdfToExcel Class Program Private Shared Sub Main(ByVal args() As String) ' establish PdfDocument Class object Dim pdf As PdfDocument = New PdfDocument ' load PDF file pdf.LoadFromFile("TableSample2.pdf ") ' preservation PDF by XLSX file pdf.SaveToFile("PdfToExcel2.xlsx", FileFormat.XLSX) End Sub End Class End Namespace
Document effects :
Original file
Output document
Add multiple pages PDF Convert to a Excel Worksheet
Here is how to add multiple pages PDF Convert to a Excel The specific steps of the worksheet :
- establish PdfDocument Class object .
- call PdfDocument.LoadFromFile() Method loading PDF file .
- initialization XlsxLineLayoutOptions An instance of a class , In the class constructor , Put the first parameter convertToMultipleSheet Set to false.
- call PdfDocument.ConvertOptions.SetPdfToXlsxOptions() Method setting PDF turn XLSX Options .
- use PdfDocument.SaveToFile() Methods will PDF Save as Excel file .
Complete code :
【C#】
using Spire.Pdf; using Spire.Pdf.Conversion; namespace ConvertPdfToExcel { class Program { static void Main(string[] args) { // establish PdfDocument Class object PdfDocument pdf = new PdfDocument(); // load PDF file pdf.LoadFromFile("TableSample.pdf"); // initialization XlsxLineLayoutOptions An instance of a class , In the class constructor , Put the first parameter convertToMultipleSheet Set to false. // The four parameters represent :convertToMultipleSheet、showRotatedText、splitCell、wrapText XlsxLineLayoutOptions options = new XlsxLineLayoutOptions(false, true, true, true); // Set up PDF turn XLSX Options pdf.ConvertOptions.SetPdfToXlsxOptions(options); // preservation PDF by Excel file pdf.SaveToFile("PdfToOneExcelSheet.xlsx", FileFormat.XLSX); } } }
【VB.NET】
Imports Spire.Pdf Imports Spire.Pdf.Conversion Namespace ConvertPdfToExcel Class Program Private Shared Sub Main(ByVal args() As String) ' establish PdfDocument Class object Dim pdf As PdfDocument = New PdfDocument pdf.LoadFromFile("TableSample.pdf") ' initialization XlsxLineLayoutOptions An instance of a class , In the class constructor , Put the first parameter convertToMultipleSheet Set to false. ' The four parameters represent :convertToMultipleSheet、showRotatedText、splitCell、wrapText Dim options As XlsxLineLayoutOptions = New XlsxLineLayoutOptions(false, true, true, true) ' Set up PDF turn XLSX Options pdf.ConvertOptions.SetPdfToXlsxOptions(options) ' preservation PDF by Excel file pdf.SaveToFile("PdfToOneExcelSheet.xlsx", FileFormat.XLSX) End Sub End Class End Namespace
Document effects :
Original file
Output document
notes : The file path in the test code is program Debug route , File paths can be customized to other paths .