Skip to main content

用于生成 PowerPoint 文件的 Python 模块

Project description

edge_pdf 使用说明

概述

edge_pdf 是一个用于生成 PowerPoint 文件的 Python 模块。它提供了一系列方法用于插入表格、文本、图片和图表等内容,并可以保存生成的 PPT 文件。

使用方法

1. 导入模块及类

from edge_pdf import PlaceholderComponent, PPTTable, PPTGenerator

2. 创建 PPTGenerator 实例

ppt = PPTGenerator()

或者使用现有的模板文件创建实例:

template_ppt = "template.pptx"
ppt = PPTGenerator(template_ppt)

3. 插入内容

3.1 插入表格

data = your_data_frame
slide_index = 0 # 第几张幻灯片
placeholder_index = 0 # 占位符索引

ppt.insert_table(data, slide_index, placeholder_index)

3.2 插入文本

content_text = "Your text content"
slide_index = 0 # 第几张幻灯片
placeholder_index = 1 # 占位符索引

ppt.insert_text(content_text, slide_index, placeholder_index)

3.3 插入图片

image_file_path = "path/to/your/image.jpg"
slide_index = 0 # 第几张幻灯片
placeholder_index = 2 # 占位符索引

ppt.insert_picture(image_file_path, slide_index, placeholder_index)

或者从 URL 插入图片:

image_url = "http://example.com/image.jpg"
slide_index = 0 # 第几张幻灯片
placeholder_index = 2 # 占位符索引

ppt.insert_picture(image_url, slide_index, placeholder_index)

3.4 插入图表

chart_type = XL_CHART_TYPE.LINE # 图表类型,参考 pptx.enum.chart.XL_CHART_TYPE
chart_data = your_chart_data
slide_index = 0 # 第几张幻灯片
placeholder_index = 3 # 占位符索引

ppt.insert_chart(chart_type, chart_data, slide_index, placeholder_index)

4. 保存 PPT 文件

output_file = "output.pptx"
ppt.save_ppt(output_file)

注意事项

  • 插入内容时的幻灯片索引和占位符索引都是从0开始的。
  • 插入表格时,数据应为 Pandas DataFrame 对象。

以上就是 PPTGenerator 类的使用说明。希望对您有所帮助!如有任何问题,请随时向我提问。

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

edge_pptx-1.0.2.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

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

edge_pptx-1.0.2-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file edge_pptx-1.0.2.tar.gz.

File metadata

  • Download URL: edge_pptx-1.0.2.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for edge_pptx-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f73d86b957ad5240a56ab9272c8229ff7aae706dd0cb8d096d7023e521c1324b
MD5 5b2f4d92a5ad6a6cb3130ca63b8e11fe
BLAKE2b-256 a893798fc58bba34a48664488a37c9c008ac44c3feb9dadf47b6919a8185daa3

See more details on using hashes here.

File details

Details for the file edge_pptx-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: edge_pptx-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for edge_pptx-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3ecdee936ffb382cf2ddf0becf030abe005a34e64aff72116da6a53e7ee654d7
MD5 8418538b357605ee027e3e4466f23532
BLAKE2b-256 e2b67640c42a41d645dc3f343969b60df2c4a98f479d3df20a6bb45cd196cada

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