We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Conversion issue (ODT to DOC) : merged cells are lost

Hello,

When converting an ODT file to DOC format, I have a rendering error in the generated DOC file : some merged cells are lost in the final DOC file.
I converted the file fileToCOnvert.odt to odt2doc_aspose202203.doc using the Aspose free online converter.
When I use the Libre Office conversion (ODT to DOC) the converted file is valid (see odt2doc_libreoffice.doc).

Regards,

conversionErrors.jpg (323.2 KB)
files.zip (27.5 KB)

@jdebouil unfortunately, I cannot reproduce the problem on my side using the latest 22.3 version of Aspose.Words. Please see the output document generated on my side using the following code:

Document doc = new Document("C:\\Temp\\in.odt");
doc.save("C:\\Temp\\out.doc");

out.zip (7.6 KB)

Thanks for your reply.

But after opening your file out.doc, I can see the issue : some cells merging are no more applied after conversion (see the comparison preview attachment).

conversionErrors2.jpg (315.1 KB)

@jdebouil Thank you for additional information. I have logged the problem as WORDSNET-23683. The problem is not visible in MS Word, but can be observed in LibreOffice and OpenOffice.

@jdebouil We have completed analysis and concluded It is not an Aspose.Words bug.
inSimple.zip (13.9 KB)
After re-save we will see two rows in the LibreOffice app.

Libreoffice can not process correctly cases when cells have both vertical and horizontal merge. Libreoffice application converts horizontal merged cells into the one combined cell.
At the same time when a souce DOC document has cells with vertical and horizontal merges then it looks like the Libreoffice skips vertical merge.
However it is possible to update AW model and obtain expected output for the problematic document:

Document doc = new Document(@"in.odt");

Table tbl = (Table)doc.GetChild(NodeType.Table, 0, true);

foreach(Row row in tbl.Rows)
{
    double cellWidth = 0;
    for (int i = row.Cells.Count - 1; i >= 0; --i)
    {
        CellFormat cellFormat = row.Cells[i].CellFormat;

        if (cellFormat.VerticalMerge == CellMerge.None)
            continue;

        switch (cellFormat.HorizontalMerge)
        {
            case CellMerge.None:
                cellWidth = 0;
                break;
            case CellMerge.First:
                cellFormat.HorizontalMerge = CellMerge.None;
                cellWidth += cellFormat.PreferredWidth.Value;
                cellFormat.PreferredWidth = PreferredWidth.FromPoints(cellWidth);
                break;
            case CellMerge.Previous:
                cellWidth += cellFormat.PreferredWidth.Value;
                row.Cells[i].Remove();
                break;
        }
    }
}

doc.Save(@"aw_out.doc");

The code above replaces merges with one the combined cell.