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

Free Support Forum - aspose.com

Different format in one cell of a table


I want to put text into a cell of a table:
table.LastRow.Cells[0].FirstParagraph.Runs[0].Text = text;

But inside the cell I want to format some words different to the other:
string textInBold = text.Substring( 0, text.IndexOf(":") + 1);
string textNoFormat = text.Substring(text.IndexOf(":") + 1, text.Length);

How I can put the text in different format (bold and not bold) into one cell? Is it posible?


Hi Ringo,

Thanks for your inquiry. Run class represents a run of characters with the same font formatting. All text of the document is stored in runs of text. Please use Run.Font property to format the text. We suggest you please read following documentation link for your kind reference.

You can also achieve your requirements using DocumentBuilder. Please check following code example. Hope this helps you.

Document doc = new Document(MyDir + “in.docx”);<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

Cell cell = (Cell)table.GetChild(NodeType.Cell, 0, true);

String text = cell.ToString(SaveFormat.Text).Trim();



string textInBold = text.Substring(0, text.IndexOf(":") + 1);

string textNoFormat = text.Substring(text.IndexOf(":"));


builder.Font.Bold = true;


builder.Font.Bold = false;


doc.Save(MyDir + "Out.docx");