Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python pptx change entire table font size

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...

Ideas? Thanks.

like image 673
thebeancounter Avatar asked Oct 31 '16 14:10

thebeancounter


People also ask

How do I change the font of an entire table?

To change all the text in the table, select the table; to change the text in specific cells, select the cells. In the Format sidebar, click the Text tab. Click the Style button, then use the text controls in the font section to change the font, size, color, or character style (such as bold or italic).


Video Answer


1 Answers

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)
like image 107
scanny Avatar answered Sep 20 '22 09:09

scanny