Skip to main content

基于 Python 开发的自动化 office 工具包

Project description

安装

pip install office-tool-plus -i https://mirrors.aliyun.com/pypi/simple/

使用

excel

ws_to_pdf(excel_path, sheet_names=None, pdf_dir=None):

将指定 Excel 工作簿中的工作表导出为PDF格式。

参数:

  • excel_path: Excel 文件的路径。
  • sheet_names: 需要导出的工作表名称列表。如果未提供,则默认导出所有工作表。
  • pdf_dir: PDF 文件的保存目录。如果未提供,则默认保存在 Excel 文件的同目录下。

返回:

  • pdf_path: 导出的PDF文件路径。

示例:

from office_tool_plus import ExcelTools

excel = ExcelTools()
# 将整个Excel导出为pdf,并保存在源目录下
excel.ws_to_pdf('test.xlsx')
# 将整个Excel导出为pdf,并保存在output目录下
excel.ws_to_pdf('test.xlsx', pdf_dir='output')
# 将指定sheet导出为pdf,并保存在源目录下
excel.ws_to_pdf('test.xlsx', ['Sheet1', 'Sheet2'])
# 将指定sheet导出为pdf,并保存在output目录下
excel.ws_to_pdf('test.xlsx', ['Sheet1', 'Sheet2'], 'output')

wb_to_pdf(excel_dir, recursive=True, suffix=None, pdf_dir=None):

将指定目录下的Excel文件批量导出为PDF格式。

参数:

  • excel_dir: Excel 文件的目录路径。
  • suffix: 需要导出的文件后缀名列表。如果未提供,则默认导出["*.xlsx", "*.xls"]
  • recursive: 是否递归搜索子目录。如果为True,则递归搜索子目录,否则只搜索当前目录。
  • pdf_dir: PDF 文件的保存目录。如果未提供,则默认保存在 Excel 文件的同目录下。

返回:

  • None

示例:

from office_tool_plus import ExcelTools

excel = ExcelTools()
# 将 test 目录下(包含子目录)所有的 Excel 文件批量导出为pdf,并保存在源目录下
excel.wb_to_pdf('test')
# 将 test 目录下(包含子目录)所有的 Excel 文件批量导出为pdf,并保存在 output 目录下
excel.wb_to_pdf('test', pdf_dir='output')
# 将 test 目录下(不包含子目录)所有的 Excel 文件批量导出为pdf,并保存在源目录下
excel.wb_to_pdf('test', recursive=False)
# 将 test 目录下(不包含子目录),后缀是 *.xlsx 的 Excel 文件批量导出为pdf,并保存在 output 目录下
excel.wb_to_pdf('test', recursive=False, suffix=['*.xlsx'], pdf_dir='output')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

office_tool_plus-0.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

office_tool_plus-0.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file office_tool_plus-0.0.2.tar.gz.

File metadata

  • Download URL: office_tool_plus-0.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for office_tool_plus-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c24c303fb5f0cfe7f677aa10bfdeed3afea4729ecf390088da34b3da6dc5e324
MD5 7dec0a7010fb3bdd4c53decef2dab95e
BLAKE2b-256 6843eb5f7fdabe7e73c93759314161969e616f7173d69d14b16ab0684b25dc06

See more details on using hashes here.

File details

Details for the file office_tool_plus-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for office_tool_plus-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c8d7de73872e4d647a6c68d8259726c65077961b2c1ec9ced8be7fb4f792e16a
MD5 29d0ae72f79127b331802f9f0ba63668
BLAKE2b-256 92e416a5c340aec25a13f067fbcf0a7168c115c189e8d24a31fcf4b35bdd97bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page