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

Free Support Forum - aspose.com

Font.Bold in table cell

Using the AlternatingRowsDemo.cs. The DocumentBuilder CellFormat methods work readily but the Font properties such as below do not. What is the correct approach to conditionally making a cell bold in the event handler?

// so we have to iterate over all cells in the row.
for (int colIdx = 0; colIdx < 4; colIdx++)
{
    mBuilder.MoveToCell(0, mRowIdx, colIdx, 0);
    mBuilder.Font.Bold = true; //add this one line to the demo - it has no effect here.
    mBuilder.CellFormat.Shading.BackgroundPatternColor = rowColor; //cool!

Hi
Thanks for your inquiry. Please try using the following code:

// Open document and create Documentbuilder
Document doc = new Document(@"Test120\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Move documentBuilder cursor into the cell
builder.MoveToCell(0, 0, 0, 0);
// Get current cell
Cell currentCell = builder.CurrentNode.GetAncestor(NodeType.Cell) as Cell;
if (currentCell != null)
{
    // Get collection of runs in the cell
    NodeCollection runs = currentCell.GetChildNodes(NodeType.Run, true);
    // loop though all runs and change font
    foreach (Run run in runs)
    {
        run.Font.Bold = true;
    }
}
// Save output document
doc.Save(@"Test120\out.doc");

Hope this helps.
Best regards.