2016-03-24 53 views

回答

1

请使用下面的代码示例更改表格单元格内文本的颜色。希望这可以帮助你。

//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作为Developer evangelist。

+0

谢谢。有效。 :) – sgiri

相关问题