Free Support Forum - aspose.com

Set different font color in one cell

i build document with table in loop with one object DocumentBuilder. like this



Document doc = new Document();



DocumentBuilder builder = new DocumentBuilder(doc);



builder.InsertCell();

builder.CellFormat.Shading.BackgroundPatternColor = rowColor;

builder.CellFormat.HorizontalMerge = CellMerge.First;

builder.CellFormat.BottomPadding = 5;

//builder.CellFormat.Width = 130;

builder.CellFormat.Width = tableWidth / aValues.Length;

builder.Write(“text”);

builder.EndRow();



how can i change font color in one cell, not all document?

i found a decision
builder.InsertHtml(“text”);
but is this the one way to solve the problem of different font color?

Formatting properties available through DocumentBuilder are like "formatting at cursor". That is, if you move the cursor into a certain place, formatting properties of DocumentBuilder will take on the formatting available at that location. Also, if you set color and start adding cells, you will be "moving the cursor" with every insertion and they will all come out in the same color until you change it.

In your case, you simply need to set color and fill options before creating every cell or set it (switch off) after you created the first cell.