Different format in one cell of a table

Hello,

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?

Regards
Ringo

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.
https://docs.aspose.com/words/net/applying-formatting/

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

Document doc = new Document(MyDir + "in.docx");
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();
cell.RemoveAllChildren();
cell.EnsureMinimum();
string textInBold = text.Substring(0, text.IndexOf(":") + 1);
string textNoFormat = text.Substring(text.IndexOf(":"));
builder.MoveTo(cell.FirstParagraph);
builder.Font.Bold = true;
builder.Write(textInBold);
builder.Font.Bold = false;
builder.Write(textNoFormat);
doc.Save(MyDir + "Out.docx");