python - 如何使用python将excel表格转换为pdf?
问题描述
我有一个要转换为 Python 的 excel 表。在为上述查询建议包或模块时需要推荐。
我尝试过使用 PDFWriter。我正在使用 pandas 读取我的 excel 文件并将该数据集输入到 PDFwriter 以创建 pdf 文件。输出 pdf 似乎是空白的。
import pandas as pd
from pdfrw import PdfWriter
wb = pd.read_excel('excel file path')
wb=PdfWriter()
wb.write('result.pdf')
创建的pdf文件只有1kb..
解决方案
import pandas as pd
import pdfkit
df = pd.read_excel("file.xlsx")#input
df.to_html("file.html")#to html
pdfkit.from_file("file.html", "file.pdf")#to pdf
推荐阅读
- java - Spring Boot - Web 应用程序上下文 Bean 范围
- elasticsearch - 如何优化elasticsearch的全文搜索以匹配'C++'之类的字符串
- azure - 取消上一次运行时,逻辑应用程序的“等待”运行未启动
- javascript - 将变量存储在数组中(作为对象中的值) JavaScript
- android - 我的应用程序已安装但未显示或运行
- excel - 在仅知道部分值的列中查找最大值
- react-native - React-Native-Navigation 使用 getParam() 在其他屏幕中更改状态
- python - 使用带有量化整数范围的 scipy.optimize.minimize
- c# - Oracle 存储过程 - 创建游标后我可以清空临时表吗
- javascript - JavaScript super.constructor() 抛出“访问此之前必须调用”异常