Formatting text in word document table cell

Hi

I’m using the example here: https://forum.aspose.com/t/102674 to generate a table.

I want the text in the first row of the table (the header) to be bold. I have tried using “Cell.FirstParagraph.ParagraphFormat.Style.Font.Bold”, but this changes all text in the entire document to bold, and not just the text in the cell.

I’m using the DocumentBuilder class to generate the table.

Help please

PS. I’m using version 9.5.0.0, we are in the process of evaluating different components to manipulate word documents. Aspose.Words is the most promising yet

Hello
Thanks for your interest in Aspose.Words. Please try using the following code:

// Open document and create Documentbuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set table formating
// Set borders
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.CellFormat.Borders.Color = Color.Red;
// Set left indent
builder.RowFormat.LeftIndent = 100;
// etc...
// Insert some table
for (int i = 0; i <5; i++)
{
    for (int j = 0; j <5; j++)
    {
        builder.InsertCell();
        if (i == 0)
            builder.Font.Bold = true;
        builder.Write("this is cell");
    }
    builder.Font.Bold = false;
    builder.EndRow();
}
builder.EndTable();
// Save output document
doc.Save("out.doc");

Best regards,

Excellent Andrey, thank you very much!