Hi,
I’m using Aspose.Words 21.10 In our code we often need to call builder.Font.ClearFormatting() after a table row is built but before entire table is finalized. I’ve noticed that this behaves in an odd manner when the last cell has no contents in it - when there is text in the last cell, if we call .EndRow() and then Font.ClearFormatting(), the cell retains its font settings, but if the cell is empty and we call these two methods, the cell’s font settings are reset to default. I’ve replicated it with the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("this is default size");
Table table1 = builder.StartTable();
builder.Font.Size = 5;
builder.InsertCell();
builder.Write("This should be size 5, and the following cell should also be size 5");
builder.InsertCell();//with no text in the cell, its font gets reset to default if the ClearFormatting is called after row is closed
builder.EndRow();
builder.Font.ClearFormatting();
builder.EndTable();
builder.Writeln("this is here just to separate the tables in the word doc, and should be default size");
Table table2 = builder.StartTable();
builder.Font.Size = 5;
builder.InsertCell();
builder.Write("This should be size 5, and the following cell should also be size 5");
builder.InsertCell();
builder.Write("This should be size 5");//with text in the cell, its font doesn't get reset to default if the ClearFormatting is called after row is closed
builder.EndRow();
builder.Font.ClearFormatting();
builder.EndTable();
builder.Writeln("this is last paragraph, and should be default size");
doc.Save(@"path to your file.docx");
I would expect the last cell in first table to have font size =5, similarly to the last cell in second table, but it seems to reset to default value. Could you advise please?
Thanks,
Tomek