_Cell object has a
.text_frame property, like a “regular” geometric shape (auto-shape), and it works the same way, providing a reference to a
You can access the paragraphs in the cell with
.add_paragraph() on the
TextFrame object, and add runs with different character formatting to a paragraph.
It’s up to you whether you make these different paragraphs or different runs, but that’s the basic idea. Note that each cell in a freshly-created table contains a single paragraph containing no runs.
cell = table.cell(0, 0) text_frame = cell.text_frame paragraph = text_frame.paragraphs run = paragraph.add_run() run.text = "r1" run.bold = True run_2 = paragraph.add_run() run.text = "25" run.italic = True
You don’t need to spell each step out on its own line; for example, you could do this to get the paragraph:
paragraph = table.cell(0, 0).text_frame.paragraphs
I just spell out the steps here so you can more clearly see each one. You can compose them into lines as you see fit.
CLICK HERE to find out more related problems solutions.