Table cell merge [problems in the ASPOSE library 10.2.0]

I have some code that worked fine with the older Aspose library and has problems when used with the new library 10.2.0.
Example: I created a table where the first row was merged. On the first row I create 6 cells:
The first cell has builder.CellFormat.HorizontalMerge = Tables.CellMerge.First
The following 5 cells have builder.CellFormat.HorizontalMerge = Tables.CellMerge.Previous
I set the width of each cell individually and the final merged cell had the width equal so the sum of widths of all the cells that took part in the merger.
With the older Aspose library I had a nice merged first row that had the width of all the cells taking part in the merger. With the newer version the merged cell has the same width as the first column. I tried setting the size of the first cell to the row size and that didn’t help either. In any case with the newer Aspose.Words library I get the following result:

Merged row [wrong cell width]

The result I had with previous version looked like this

Merged row

Hi
Thanks for your request. I cannot reproduce the problem on my side. Have you tried using simply wide cells instead of horizontally merged? This might resolve the problem.
The fact that by Microsoft Word design, rows in a table in a Microsoft Word document are completely independent. It means each row can have any number of cells of any width. So if you imagine first row with one wide cell and second row with two narrow cells, then looking at this document the cell in the first row will appear horizontally merged. But it is not a merged cell; it is just a single wide cell. Another perfectly valid scenario is when the first row has two cells. First cell has CellMerge.First and second cell has CellMerge.Previous, in this case, it is a merged cell. In both cases, the visual appearance in MS Word is exactly the same. Both cases are valid and produce the same result on my side.
Here is simple code, which demonstrates the described things.

// Create empty document and DocumentBuilder object.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Configure DocumentBuilder
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.CellFormat.Borders.Color = Color.Black;
// Build table, with simply wide cells.
// First row will contains simply wide cell and in MS Word it will look like merged.
builder.InsertCell();
builder.CellFormat.Width = 200;
builder.Write("This is simply wide cell");
builder.EndRow();
// Insert the second row
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.EndRow();
builder.EndTable();
// Insert few paragraphs between table.
builder.Writeln();
builder.Writeln();
// Build table, with merged cells.
// First row will contains merged cells.
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.Write("This is merged cells");
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.EndRow();
// Insert the second row
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.EndRow();
builder.EndTable();
// Save output document
doc.Save("out.doc");

If the problem still occurs, please attach the output document produced on your side.
Best regards,

It did help to see that your example worked, but it took me some time to find out what was different in my code.
The difference is that I called doc.UpdateTableLayout() before calling doc.save(). This seems to mess up merged cells and table layouts. The same code called with the previous Aspose version worked fine. Is doc.UpdateTableLayout() needed? My documents look fine without me calling it, so this looks to be the solution in my case.
Anyways my post should actualy say that doc.UpdateTableLayout() worked in the previous Aspose version and seems to cause problems in 10.2.0.
You should see some probematic behviour in this modified example:

// Build table, with merged cells.
// First row will contains merged cells.
builder.InsertCell();
//Following change should make the merged cell bigger than the following rows but this does not wok when calling doc.UpdateTableLayout()
builder.CellFormat.Width = 300; 
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.Write("This is merged cells");
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.EndRow();
// Insert the second row
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.InsertCell();
builder.CellFormat.Width = 100;
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.EndRow();
builder.EndTable();
builder.UpdateTableLayout()
// Save output document
doc.Save("out.doc");

Hi
Thank you for additional information. It is not recommended to call UpdateTableLayout when you save the document in Word formats. Sometimes it is necessary when you save the document in PDF. But normally this method should not be called.
So, just remove this line of code.
Best regards,