简体   繁体   English

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

[英]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.

相关问题 如何更改页眉和页脚文本(即合并字段)的字体颜色并在 Aspose Word Java 中存在行颜色更改 - How to change the font color of Header and Footer Text (which is merge field) and exist Line color change in Aspose Word Java 如何在不使用段落和运行的情况下更改特定表单元上的Apache POI Word文档中的字体颜色? - How to change font color in Apache POI word document on a specific table cell without using paragraph and run? 如何使用Aspose Word for Java从.doc中读取文本和字体 - How to read text and font from .doc using Aspose Word for Java 如何在Java中更改现有Excel(xlsx或xls)单元格的颜色 - How to change color of a cell of an existing excel (xlsx or xls) in java 用Java更改表格单元格颜色 - Change table cell color in Java 使用 Aspose java 隐藏表格中单元格的边框 - Hide the border for cell in table using Aspose java 使用Java的aspose单词在MS单词表中不合并最后一行 - last row is not merged in ms word table using aspose word for java 如何在java中更改按钮的字体大小/颜色? - How to change font size/color of a button in java? Java:如何随机改变背景和字体颜色 - Java:How to Randomly Change Background And Font Color 如何在java中使用aspose pdf在表格单元格中设置文本样式 - how to set text style vertical in table cell using aspose pdf in java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM