I need to get and replace font color of a cell.
@Mark030 Font formatting is actually not applied to a cell or paragraph it is applied to a Run
nodes - the smallest pieces of text in MS Word documents. So you can use the following simple code to get font formatting of a particular cell in the table:
import aspose.words as aw
doc = aw.Document("C:\\Temp\\in.docx")
table = doc.first_section.body.tables[0]
for n in table.first_row.first_cell.get_child_nodes(aw.NodeType.RUN, True) :
r = n.as_run()
print(r.font.name)
print(r.font.size)
print(r.font.color)
The similar code can be used to change formatting of the text:
import aspose.words as aw
import aspose.pydrawing as pydraw
doc = aw.Document("C:\\Temp\\in.docx")
table = doc.first_section.body.tables[0]
for n in table.first_row.first_cell.get_child_nodes(aw.NodeType.RUN, True) :
r = n.as_run()
r.font.name = "Arial"
r.font.size = 12
r.font.color = pydraw.Color.red
doc.save("C:\\Temp\\out.docx")