0

I have an existing table in Aspose word template, I want to change the font color of the text inside the cell. How can I achieve it?

CellCollection cellList = row.getCells() 
def i = 0 
Run run; 
Cell cell = cellList.get(i)

I am new to Aspose Word.

4

1 回答 1

2

请使用以下代码示例更改表格单元格内文本的颜色。希望这对您有所帮助。

//Load the document
Document doc = new Document(MyDir + "in.docx");

//Get the first table in the document
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);

//Get the first cell of first row
Cell cell = (Cell)table.getRows().get(0).getCells().get(0);

//Change the color of text
for (Run run : (Iterable<Run>)cell.getChildNodes(NodeType.RUN, true))
{
    run.getFont().setColor(Color.BLUE);
}

//Save the document
doc.save(MyDir + "Out.docx");

我与 Aspose 合作,担任开发人员传道者。

于 2016-03-25T09:26:46.300 回答