python pptx更改整个表格字体大小 [英] python pptx change entire table font size

查看:150
本文介绍了python pptx更改整个表格字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 python 2.7 和 python pptx 来创建一个带有幻灯片的演示文稿,其中包含一个带有数据的表格.

I use python 2.7 with python pptx to create a presentation with a slide that contain a table with data.

我需要控制表格和文本的大小.

I need to control the size of the table and text.

我寻找了这样做的方法,我发现了一些关于使用段落更改特定单元格字体大小的方法 这里 和这里 在此处输入链接描述

I looked for ways to do so, and I found some things about changing a particular cell's font size using the paragraphs here and here enter link description here

但是我找不到关于更改整个表格文本大小的任何信息...

But I can't find anything about changing the entire table's text size...

想法?谢谢.

推荐答案

表格中的字体大小是逐次设置的.因此,您可以在添加文本时执行此操作,也可以在之后执行以下操作:

Font size in a table is set on a run-by-run basis. So you might do so as you're adding text, or you could do something like this afterward:

from pptx.util import Pt

def iter_cells(table):
    for row in table.rows:
        for cell in row.cells:
            yield cell

for cell in iter_cells(table):
    for paragraph in cell.text_frame.paragraphs:
        for run in paragraph.runs:
            run.font.size = Pt(24)

这篇关于python pptx更改整个表格字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆