Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

office.excel.excel2pdf方法只能转换第一个工作表. #110

Open
wyl219 opened this issue Nov 5, 2023 · 2 comments
Open

office.excel.excel2pdf方法只能转换第一个工作表. #110

wyl219 opened this issue Nov 5, 2023 · 2 comments

Comments

@wyl219
Copy link

wyl219 commented Nov 5, 2023

# 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
Copy link
Owner

CoderWanFeng commented Nov 5, 2023

好主意!要不你直接提一个pull request?
源码地址👉https://github.com/CoderWanFeng/poexcel

@wyl219
Copy link
Author

wyl219 commented Nov 6, 2023

提交了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants