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

测试结果:

相关推荐
Fighting_p33 分钟前
【预览word文档】使用插件 docx-preview 预览线上 word 文档
开发语言·c#·word
夏日白云2 小时前
《PDF解析工程实录》第 11 章|图像路线的工程现实:DPI、分辨率和内存炸裂
pdf·llm·大语言模型·rag·文档解析
拓端研究室2 小时前
2026年消费行业展望报告:智能科技、可持续发展与幼稚经济|附750+份报告PDF、数据、可视化模板汇总下载
科技·pdf
hqyjzsb2 小时前
2026年AI证书选择攻略:当“平台绑定”与“能力通用”冲突,如何破局?
大数据·c语言·人工智能·信息可视化·职场和发展·excel·学习方法
牛奔2 小时前
Linux 的日志分析命令
linux·运维·服务器·python·excel
December3103 小时前
EPUB转PDF实用指南,减少格式错乱烦恼
pdf·文档格式转换·电子书转pdf·epub转pdf·电子书转换格式
jiushidt4 小时前
Things About ArcGISPro
arcgis·c#·.net·arcgispro
雪雁4 小时前
CodeSpirit 多语言国际化使用指南(Beta)
c#·asp.net·.net 10·codespirit
自己的九又四分之三站台4 小时前
写一个简单的DebugView
c#
CreasyChan4 小时前
C#中单个下划线的语法与用途详解
前端·c#