Document with merged cells saved as FixedXaml displays with merged cells collapsed when viewed in WPF document viewer

We’re recreating a form using Aspose.Words and are using cells to create the spacing and organization that the report needs. We are using the following code in the document creation to set up our merged cells using i in a for loop:

row.Cells[0].CellFormat.HorizontalMerge = CellMerge.First;

then

row.Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous; //for all other cells in the merge.

We then save the document to SaveFormat.XamlFixed to a temporary location. Within our WPF GUI, when then open that xaml and pop it into a document viewer. The merged cells are collapsed in the WPF DocumentViewer. However, when exported or saved as xps from the viewer, the cells are back to normal.

My question is this:
Is it how I’m merging the cells that is causing the oddity, a problem with Aspose, or a problem with WPF?

Hi Vern,

Thanks for your inquiry. In this case, you should just call Document.UpdateTableLayout method before exporting to XAML (or any other fixed-page format e.g. PDF), only in rare cases where you confirmed that tables appear incorrectly laid out in the output document. I hope, calling this method will help to correct the output. Here is how use should use it:

Document doc = new Document(@"c:\test\in.docx");
...
... 
doc.UpdateTableLayout();
doc.Save(@"c:\test\out.xaml", SaveFormat.XamlFixed);

Best Regards,

That solved it, thank you!