[英]How to change font color of an existing table cell in Aspose Word in Java?
I have an existing table in Aspose word template, I want to change the font color of the text inside the cell. 我在Aspose字模板中已有一个表格,我想更改单元格内文本的字体颜色。 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. 我是Aspose Word的新手。
Please use following code example to change the color of text inside table's cell. 请使用下面的代码示例更改表格单元格中文本的颜色。 Hope this helps you.
希望这对您有所帮助。
//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");
I work with Aspose as Developer evangelist. 我与Aspose合作,担任Developer推广员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.