C#PDF转Excel

組件 Spire.Pdf.dll, v7.8.9.0 【注意:版本太低的没有此功能】

在Visual Studio中找到参考,鼠标右键点击"引用","添加引用",将本地路径debug文件夹下的dll文件添加引用至程序。

界面图:

1个label,1个TextBox文本框(属性Multiline改为ture可以拖动改变文本框大小),2个Botton按钮

【PDF转Excel】

转换时,可通过以下步骤来实现,仅需要三行代码:

  • 创建 PdfDocument类的对象。
  • 调用 PdfDocument.LoadFromFile(string filename) 方法加载PDF文档。
  • 通过 PdfDocument.SaveToFile(string filename, FileFormat fileFormat) 方法将文件保存为Excel格式到指定路径。
cs 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Spire.Pdf;
using excelToPdf;


namespace PdfToExcel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        DialogOperate openfile = new DialogOperate();
        public void pdfCovertExcel(string path)
        {
            //加载PDF文档
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile(path);//pdf文件路径
            //保存为Excel文档
            pdf.SaveToFile("demo.xlsx", FileFormat.XLSX);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pdfCovertExcel(textBox1.Text);
            MessageBox.Show("转换完成");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text=openfile.OpenFile();
        }
    }
}

测试结果:

相关推荐
UR的出不克4 小时前
使用 Python 爬取 Bilibili 弹幕数据并导出 Excel
java·python·excel
wtsolutions4 小时前
Understanding Excel Data Formats - What Excel to JSON Supports
ui·json·excel
ぁず5 小时前
excel想生成一列随机数并删除公式保留值
excel
不绝1915 小时前
C#核心:多态
开发语言·c#
橙露6 小时前
C#在视觉检测中的优势:工业智能化转型的利器
开发语言·c#·视觉检测
wtsolutions8 小时前
Real-World Use Cases - How Organizations Use Excel to JSON
json·github·excel
爱说实话8 小时前
C# DependencyObject类、Visual类、UIElement类
开发语言·c#
一只小H呀の8 小时前
pandas处理excel数据
excel·pandas
wregjru8 小时前
【操作系统】3.开发工具
excel
Mr.LJie8 小时前
记录使用iText7合并PDF文件、PDF发票、PDF火车票
java·pdf