I am writing python code to modify an existing powerpoint document using python-pptx. I can usually set text while preserving formatting, by setting text in the run:
shape.text_frame.paragraphs[0].runs[0].text = 'mytext'
However, in the tables I am modifying, the cells have no runs. They have a paragraph[0] and it contains a font object with no information (font.name, font.size, are blank). I don't know where the table font information is stored but it must have some since the table works in powerpoint. If I add a run to the paragraph and set its text, the text is not the same size as if I do this manually in the powerpoint UI. How do I set the text in a table cell while keeping the font information from the original table?
# this does not preserve table cell formatting...
table = shape.table
cell = table.rows[0].cells[0]
run = cell.text_frame.paragraphs[0].add_run()
run.text = 'mytext'