Как изменить цвет шрифта существующей ячейки таблицы в Aspose Word на Java?

У меня есть существующая таблица в шаблоне слова Aspose, я хочу изменить цвет шрифта текста внутри ячейки. Как я могу достичь этого?

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

Я новичок в Aspose Word.


person sgiri    schedule 24.03.2016    source источник


Ответы (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 в качестве евангелиста разработчиков.

person Tahir Manzoor    schedule 25.03.2016