8

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.

Community
  • 1
  • 1
thebeancounter
  • 4,261
  • 8
  • 61
  • 109

1 Answers1

20

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)
scanny
  • 26,423
  • 5
  • 54
  • 80
  • 1
    could you please provide an example for how to change the font size of the table cell when i am adding it so i will be able to accept the answer? – thebeancounter Nov 03 '16 at 10:15
  • 1
    @captainshai Please add to your question the code you use to add the text and I'll have a look. – scanny Nov 03 '16 at 17:45