首页 > 解决方案 > 如何使用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..

标签: pythonpdfpdfrw

解决方案


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

推荐阅读