Skip to content

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

Open

Description

@wyl219
# 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):

Activity

  1. CoderWanFeng commented on Nov 5, 2023

    @CoderWanFeng
    Owner

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

  2. wyl219 commented on Nov 6, 2023

    @wyl219
    Author

    提交了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions