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

测试结果:

相关推荐
Non-existent98712 小时前
WPS批量清理单元格空白字符的4种方法-异常数字格式处理-实战
excel·wps
weixin_3975740913 小时前
PDF复杂表格的1:1还原引擎:跨页表格自动拼接技术实战
大数据·人工智能·pdf
Metaphor69213 小时前
使用 Python 将 PDF 转换为 HTML
python·pdf·html
2601_9618451514 小时前
粉笔行测5000题电子版|pdf|解析
pdf·新媒体运营·github·个人开发·内容运营·规格说明书·极限编程
2601_9620725514 小时前
李梦娇常识4600问|题库|打印版
sql·华为od·华为·c#·华为云·.net·harmonyos
Sour15 小时前
PDF翻译卡住不动怎么办?扫描件、OCR 和大文件排查清单
前端·pdf·ocr
Channing Lewis16 小时前
PHP 解析 Excel 的那些坑:一次“行号错位”引发的数据丢失
开发语言·php·excel
m0_5474866616 小时前
《C#语言程序设计与实践》 全套PPT课件
c语言·c#·c语言程序设计
叶帆17 小时前
【YFIOs】用C#开发硬件之设备上云
开发语言·unity·c#
jarreyer18 小时前
【数据分析绘图】excel绘图和bi工具区别
数据挖掘·数据分析·excel