一、表格转换成果
【ptf】
【转换后Excel】
可用看到表格内容位置一致,转换完成
二、转换方法【一】(适用只有一页)
(1)安装camelot库文章来源:https://www.toymoban.com/news/detail-554409.html
pip install "camelot-py[base]"
(2)转换代码文章来源地址https://www.toymoban.com/news/detail-554409.html
import camelot.io as camelot
data = camelot.read_pdf("abc.pdf", pages='1',flavor='stream')
data[0].to_excel('result.xlsx',encoding='utf_8_sig')
三、转换方法【二】(适用pdf含有多页转换excel)
import camelot.io as camelot
from openpyxl import Workbook
work = Workbook()
sheet = work.active
data = camelot.read_pdf("计算机技术拟录取名单.pdf", pages='all',flavor='stream')
for i in range(data.n):
for rows in data[i].data:
sheet.append(rows)
work.save('success.xlsx')
到了这里,关于python读取表格数据将pdf文件转excel文件最新可用方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!