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

测试结果:

相关推荐
VBAMatrix1 天前
deepseek-v4正式接入Excel,一键生成财务分析报告
word·excel·审计·财务分析·deepseek·会计师事务所·tb工具箱
hixiong1231 天前
C# OpenvinoSharp使用DINOv2模型进行图像相似度计算
开发语言·c#
月昤昽1 天前
autoCAD二次开发 4.正多边形与collection区分
算法·c#·二次开发·autocad二次开发
Victory_20251 天前
c#定时器顺序控制写法
开发语言·c#·c#顺序控制+定时器
雪度娃娃1 天前
基于TCP的网络词典
网络·c++·tcp/ip·c#
梵克之泪1 天前
批量拆分PDF只取PDF的首页,批量按文件页数拆分PDF,按卷内目录页码表计算批量拆分分割PDF
pdf·pdf拆分
xxjj998a1 天前
PHP vs C#:两大编程语言终极对比
开发语言·c#·php
工程师0071 天前
C# 泛型:约束、协变逆变、底层模板生成机制
c#·泛型·逆变·协变
bestcxx1 天前
多个维度对 Java、Python、C#、Go 这四种主流编程语言进行比较
java·python·c#
我是唐青枫1 天前
内存为什么越来越高?C#.NET GC 详解:分代回收、LOH、终结器与性能优化实战
性能优化·c#·.net