我使用python-pptx v0.6.2生成powerpoint。我读了一个现有的幻灯片到BytesIO,然后做了一些修改并保存它。我可以成功地下载该文件,并且我确信可以将内容写入该文件。但是当我打开powerpoint时,它会弹出一个错误信息"Powerpoint发现foo.pptx中的内容有问题。Powerpoint可以尝试修复预设。“,然后我必须单击”修复“按钮,powerpoint将显示为”已修复“模式。我的Python版本是3.5.2,Django版本是1.10。下面是我的代码:
with open('foo.pptx', 'rb') as
我想通过pptx python将ppt幻灯片导出为png格式的图像。
我已经完成了此解决方案,但在运行win32com.client.Dispatch("PowerPoint.Application")时以com_error: (-2147221005, 'Invalid class string', None, None)身份遇到错误
我也尝试过使用pptx_tools.utils.save_pptx_as_png,但它询问Comptype module needed to save PNGs.,我在Python语言中找不到任何comptype模块。我已经安装
我已经使用c#将图像插入powerpoint,并插入到图片及其工作perfectly.But的超链接,现在我需要读取使用c#插入的图片的超链接。
使用c#将带有超链接的文本插入到powerpoint中,然后通过下面的方法从powerpoint读取超链接。
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (var item in presentation.Slides[i + 1].Shapes)
{
var shape
我一直在使用python访问幻灯片(我发现它比使用win32要平滑得多,因为它不需要打开Powerpoint窗口。但是,我已经检查了文档,但是找不到打印幻灯片的任何方法。我是不是遗漏了什么?
以下是我到目前为止所拥有的:
from pptx import Presentation
prs = Presentation(path)
for slide in prs.slides:
if slide.name == slide_I_want:
#send slide to printer
我能够用以下代码删除/覆盖一些元数据(存储在core.xml中的元数据):
def remove_metadata(prs):
"""Overwrites the metadata in core.xml however does not overwrite metadata which is stored in app.xml"""
prs.core_properties.title = 'PowerPoint Presentation'
prs.core_properties.last_modified
我有一个预先构建和填充的powerpoint演示文稿,在这里我正在修改图表和表格的数据。我想保留所有格式(和大部分文本),但替换幻灯片中的线条图中的数据。
我有一个功能,将取代数据使用熊猫的数据框架,与条形图工作。
def replaceCategoryChart(df, chart, skipLastCol=0):
"""
Replaces Category chartdata for a simple series chart. e.g. Nonfarm Employment
Parameters:
df: dataframe co
我发现这段代码可以创建一个形状并添加一个超链接,我将其修改为让超链接转到同一文档中的另一张幻灯片,但在Actionsettings中得到编译错误。
Sub Hyper()
Dim pr As PowerPoint.Presentation
Dim sl As PowerPoint.Slide
Dim sh As PowerPoint.Shape
Set pr = ActivePresentation
Set sh = sl.Shapes.AddShape(Type:=msoShapeRectangle, Left:=50, Top:=50, Width:=100, Height:=200)
s
我试图在power point幻灯片上抓取一个矩形内构建的图表的图像。我找到了python-pptx,并且能够识别每张幻灯片上的形状。有没有办法将其扩展为拍摄矩形内区域的快照,并将其导出为图像?
# Auto grab the photos created in Powerpoint
from pptx import Presentation
prs = Presentation('ex.pptx')
for slide in prs.slides:
print(slide)
for shape in slide.shapes:
有没有办法用python-pptx在powerpoint演示文稿中绘制matplotlib图表,而不用将图表保存为*.jpg或*.png?下面是一种简单的方法,将matplotlib图形保存为图像文件,然后将其加载到python-pptx,但这根本不是一种有效的方法。
import numpy as np
import matplotlib.pyplot as plt
from pptx import Presentation
from pptx.util import Inches
np.random.seed(5)
x = np.arange(1, 101)
y = 20 + 3 *
我试图使用Python在一些PowerPoint幻灯片上运行带有pytesseract的OCR,这些幻灯片中有(文本的)图像,而我只能将图像传递给pytesseract。
到目前为止,我有这个问题,但最后一行是问题所在:
for slide in presentation.Slides:
for shape in slide.Shapes:
if 'Picture' in shape.Name: #in my case, the images I want have this.
picture_text = image_to_s
我想使用现有的powerpoint演示文稿生成一系列报告:
在我的想象中,powerpoint幻灯片将包含以下或类似形式的内容:
Date of report: {{report_date}}
Number of Sales: {{no_sales}}
...
然后,我的python应用程序打开powerpoint,填写该报告的值,并使用新名称保存该报告。我用谷歌搜索了一下,但找不到解决方案。
虽然有python-pptx,但这一切都是为了创建新的演示文稿,而不是在模板中插入值。
有人能给点建议吗?