We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set Table Cell background and Text colors

Hi.
Please explain how to add color in Table Cell ( background and Text Colors. ).
Sunil

Hi
Thanks for your request.
If you need to set Background of table cell you should use CellFormat.Shading.BackgroundPatternColor. See the following link for more information.
https://reference.aspose.com/words/net/aspose.words/shading/backgroundpatterncolor/
You should use Font.Color to set color of text. Please see the following code. The code sets background color and text color of first cell of table.

// Open document
Document doc = new Document(@"Test208\in.doc");
// Get table
Table tab = doc.FirstSection.Body.Tables[0];
// Set backgroung of first cell
tab.FirstRow.FirstCell.CellFormat.Shading.BackgroundPatternColor = Color.Red;
// Set color of each run of text
NodeCollection runs = tab.FirstRow.FirstCell.GetChildNodes(NodeType.Run, true);
foreach (Run run in runs)
{
    run.Font.Color = Color.Blue;
}
// Save output docuemnt
doc.Save(@"Test208\out.doc");

Hope this helps.
Best regards.