当前位置:网站首页>C#/VB. Net to convert PDF to excel
C#/VB. Net to convert PDF to excel
2022-06-28 22:15:00 【51CTO】
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 .
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);
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
【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
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
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);
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
【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
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
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 .
边栏推荐
猜你喜欢

Lumiprobe non fluorescent alkyne research - dbco NHS ester

Use of dynamic panels

Architecture design of e-commerce secsha system

How to analyze the relationship between enterprise digital transformation and data asset management?

Lumiprobe protein labeling research scheme

6月底了,让我康康有多少准备跳槽的
![[width first search note] BFS output shortest path](/img/b5/553ca241ae571daecabd282f33f20a.jpg)
[width first search note] BFS output shortest path

直播预告|SQL也能玩转工业级机器学习?MLOps meetup V3带你一探究竟!

If you are a C developer, look at these three explicit programming techniques
![[webapi] return dynamic list dynamic](/img/83/b0b36ddab6d74ccd89811cbb58d051.jpg)
[webapi] return dynamic list dynamic
随机推荐
6年心得,从功能测试到测试开发,送给在测试路上一路走到黑的你
Zero foundation self-study SQL course | complete collection of date functions in SQL
Sword finger offer:[day 2 linked list (simple)] --- > reverse linked list
IPv6 comprehensive experiment
彪马携手10KTF Shop启动其迄今为止规模首屈一指的Web3合作项目
犹豫的根音
关于杠杆的思考
Introduction to wrk pressure test tool
给朋友的忠告
SqlTransaction
初识阿里云(云计算)—发展历程和技术架构、地域和可用区!
10、标准I/O输入输出重定向及管道
How can the sports app keep the end-to-side background alive to make the sports record more complete?
How to use the style label of jade template- How to use the style tag with jade templates?
重磅!CDA认证考试备考答疑上线
apipost脚本使用讲解一~全局变量
Ctrip will push the "3+2" working mode: 3 days a week on duty and 2 days of free choice of office space. Do you envy it?
#yyds干货盘点# 解决剑指offer: 连续子数组的最大和(二)
Hardware development notes (VII): basic process of hardware development, making a USB to RS232 module (VI): creating 0603 package and associating principle graphic devices
Multinomial distribution (a discrete distribution)