Hi,
I’m using aspose.Words for .net version 21.8. I’m creating a table with some of the cells merged. in the merged cells, I add fields that need to have Document.UpdateFields performed in order to display correctly (first discovered when the update was performed for a Shape object). I’ve noticed that the Document.UpdateFields() is breaking CellFormat.VerticalMerge. I’ve managed to replicate it with the following code:
var doc = new Document();
var builder = new DocumentBuilder(doc);
builder.StartTable();
builder.InsertCell();
builder.Write("col0row0");
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.First;
builder.Write("Col1Row0");
builder.InsertField("PAGE", "aaa");
builder.Write("\n");
builder.Document.UpdateFields();
builder.EndRow();
builder.InsertCell();
builder.Write("Col0row1");
builder.CellFormat.VerticalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.VerticalMerge = CellMerge.Previous;
builder.Write("Col1row1");
builder.EndRow();
builder.EndTable();
doc.Save(@"output save path goes here");
As you’ll notice, the table in the output document is ignoring the vertical merge, and getting rid of builder.Document.UpdateFields(); causes the cells to print as merged. I still need to use the UpdateDocument() in my production code, as there are other fields in the cell that need updating, so removing it is not a viable solution for me.
Could you advise on how to avoid the cell merge being undone by .UpdateFields() please?
Thanks,
Tomek