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();
        }
    }
}

测试结果:

相关推荐
筱璦4 小时前
期货软件开发 - C# 调用 HQChart 指标计算 C++ 动态库
c++·microsoft·c#
武藤一雄5 小时前
C# 异常(Exception)处理避坑指南
windows·microsoft·c#·.net·.netcore·鲁棒性
xinixini7 小时前
小初高全学科课程标准PDF
pdf
武藤一雄8 小时前
WPF中ViewModel之间的5种通讯方式
开发语言·前端·microsoft·c#·wpf
雨浓YN8 小时前
OPC UA 通讯开发笔记 - 基于Opc.Ua.Client
笔记·c#
我是唐青枫9 小时前
C#.NET TPL Dataflow 深入解析:数据流管道、背压控制与实战取舍
c#·.net
SQVIoMPLe9 小时前
python-langchain框架(3-7-提取pdf中的图片 )
python·langchain·pdf
奔跑的呱呱牛10 小时前
前端/Node.js操作Excel实战:使用@giszhc/xlsx(导入+导出全流程)
前端·node.js·excel·xlsx·sheetjs
Highcharts.js11 小时前
Highcharts客户端导出使用文档说明|图表导出模块讲解
前端·javascript·pdf·highcharts·图表导出
Metaphor69211 小时前
使用 Python 设置 Excel 表格的行高与列宽
开发语言·python·excel