UpdateFields messes the rendering of merged cells of table using .NET

I'm using the UpdateFields() call to update a table of contents after assembling a document. This works for the table of contents but it messes with the rendering of merged cells in a table completely unrelated to the TOC.

The following code sample demonstrates the problem. I create a simple four column table, where the last three columns are merged in the first row (as in a header).

The document it is working with (attached to this post) contains a simple TOC, nothing else.

With the UpdateFields() call, the merged cells render incorrectly across only one column. If you comment out the call, then the merged cells will render properly across all three columns. In my original code I fix the widths of the columns with CellFormat.PreferredWidth, but that doesn't resolve the problem.

Please advise if I am doing something wrong, or if there is a workaround. I'm using Aspose Words 11.2, but the problem also occurs in earlier versions.

Jim

Dim doc As Document = New Document("c:\test\Aspose_table_test.docx")
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
Dim table As Table = builder.StartTable()

'Add a header row with four cells, the last three are merged.
builder.InsertCell()
builder.Write("Cell 1")
'Add the three merged cells.
builder.InsertCell()
builder.CellFormat.HorizontalMerge = CellMerge.First
builder.Write("Merged cells")
builder.InsertCell()
builder.CellFormat.HorizontalMerge = CellMerge.Previous
builder.InsertCell()
builder.CellFormat.HorizontalMerge = CellMerge.Previous
builder.EndRow()
builder.CellFormat.HorizontalMerge = CellMerge.None

'Add a few lines of body to the table - four cells not merged.
For row As Integer = 1 To 3
For Col As Integer = 1 To 4
builder.InsertCell()
builder.Write("Cell " & Col.ToString())
Next
builder.EndRow()
Next
builder.EndTable()

doc.UpdateFields()
doc.Save("c:\test\table_test.docx", Aspose.Words.SaveFormat.Docx)


Hi Jim,

Thanks for your query. I have managed to reproduce the same problem at my end. I have logged this issue in our issue tracking system and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-6262) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.