office.excel.excel2pdf方法只能转换第一个工作表.
Opened this issue · 2 comments
wyl219 commented
# poexcel.api.excel
# line:71
# def excel2pdf(excel_path, pdf_path, sheet_id: int = 0):
# mainExcel.excel2pdf(excel_path, pdf_path, sheet_id)
sheet_id设定了默认值0.
在office.api.excel.excel2pdf的定义种并没有提供sheet_id参数
# poexcel.core.ExcelType.MainExcel.excel2pdf
# line:149
# sheet = book.sheets[sheet_id]
# sheet.to_pdf(path=pdf_path_name, show=False)
这里仅读取了sheet_id对应的sheet并转换为pdf.由于sheet_id是固定值,因此只能转换首个工作表.
可以将 poexcel.core.ExcelType.MainExcel.excel2pdf line165:
sheet.to_pdf(path=pdf_path_name, show=False)
修改为:
book.to_pdf(path=pdf_path_name, show=False,include=sheet_id)
并且修改 poexcel.api.excel line:71
def excel2pdf(excel_path, pdf_path, sheet_id: int = 0):
为:
def excel2pdf(excel_path, pdf_path, sheet_id: int = None):
CoderWanFeng commented
好主意!要不你直接提一个pull request?
源码地址👉https://github.com/CoderWanFeng/poexcel
wyl219 commented
提交了