如何在Java中更改Aspose Word中现有表格单元格的字体颜色?

如何在Java中更改Aspose Word中现有表格单元格的字体颜色?,java,aspose.words,Java,Aspose.words,我在OSE word模板中有一个现有表,我想更改单元格内文本的字体颜色。我怎样才能做到呢 CellCollection cellList = row.getCells() def i = 0 Run run; Cell cell = cellList.get(i) 我不熟悉Aspose Word。请使用以下代码示例更改表单元格中文本的颜色。希望这对你有帮助 //Load the document Document doc = new Document(MyDir + "in.docx")

我在OSE word模板中有一个现有表,我想更改单元格内文本的字体颜色。我怎样才能做到呢

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

我不熟悉Aspose Word。

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

//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");
//加载文档
文档文档=新文档(MyDir+“in.docx”);
//获取文档中的第一个表
Table Table=(Table)doc.getChild(NodeType.Table,0,true);
//获取第一行的第一个单元格
Cell Cell=(Cell)table.getRows().get(0.getCells().get(0);
//更改文本的颜色
for(Run-Run:(Iterable)cell.getChildNodes(NodeType.Run,true))
{
run.getFont().setColor(Color.BLUE);
}
//保存文档
文档保存(MyDir+“Out.docx”);

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

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

//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");
//加载文档
文档文档=新文档(MyDir+“in.docx”);
//获取文档中的第一个表
Table Table=(Table)doc.getChild(NodeType.Table,0,true);
//获取第一行的第一个单元格
Cell Cell=(Cell)table.getRows().get(0.getCells().get(0);
//更改文本的颜色
for(Run-Run:(Iterable)cell.getChildNodes(NodeType.Run,true))
{
run.getFont().setColor(Color.BLUE);
}
//保存文档
文档保存(MyDir+“Out.docx”);
我与Aspose合作,担任开发人员宣传员