Row spans number of VerticalMerge cells:

Hi,
I’m using Documentvisitor to extract table from word document to create a xml file, I want to know at every cell if it’s Verticaly Merged and how many time. So what I do:

public override VisitorAction VisitCellStart(Aspose.Words.Tables.Cell cell)
{
    try
    {
        if (cell.CellFormat.VerticalMerge != CellMerge.Previous)
        {
            _mIsSkipCell = false;
            _mTableCellElem = _mXmlDoc.CreateElement("TableCell");
            _mTableCellElem.SetAttribute("HorizontalAlignment", cell.Paragraphs[0].ParagraphFormat.Alignment.ToString().ToLower());
            _mTableCellElem.SetAttribute("VerticalAlignment", cell.CellFormat.VerticalAlignment.ToString().ToLower());
            _mTableCellElem.SetAttribute("BorderWidthBottom", cell.CellFormat.Borders.Bottom.LineWidth.ToString());
            _mTableCellElem.SetAttribute("BorderWidthLeft", cell.CellFormat.Borders.Left.LineWidth.ToString());
            _mTableCellElem.SetAttribute("BorderWidthRight", cell.CellFormat.Borders.Right.LineWidth.ToString());
            _mTableCellElem.SetAttribute("BorderWidthTop", cell.CellFormat.Borders.Top.LineWidth.ToString());
            if (cell.CellFormat.VerticalMerge == CellMerge.First)
            {
                _mTableCellElem.SetAttribute("Rowspan", cell.CellFormat.???????);
            }
            _mXmlTableCell = new XmlTableCell(_mTableCellElem, _mXmlTableRow.ThisElement);
            _mXmlTableRow.AddCell(_mXmlTableCell);
        }
        else
        {
            _mIsSkipCell = true;
        }
        return VisitorAction.Continue;

How can I figure out the number of RowSpan (how many time this cell is merged verically?)?

_mTableCellElem.SetAttribute("Rowspan",?????);

where ??? is the number of merged verically cells
Thanks

Hi

Thanks for your request. There is no way to get number of spanned rows. However, you can calculate this value using CellMerge property. Loop through rows and cells and determine how many cells are merged with previous.
https://reference.aspose.com/words/net/aspose.words.tables/cellformat/verticalmerge/
Best regards.

Hi,
I did all my possible to calculate the number of Rowspan and I failed, the problem is always the colspan. If there number of cells is not the same in different rows we have a big problem and I can’t guess witch cell is merged with what.
Could please help me to find an algorithm so I can identify a cell and make it unique.
I join an example of my file.
Thanks

Robert,

Why do you need to create custom XML? Maybe it would be enough to convert your document to HTML and WML(xml) format.
Best regards.

Hi Alexey,
Actually we have word documents writhen with custom styles to be treated in custom manner.
What we need is to parse them in custom manner and make searches on these documents and all of them using XSLT. Some document may make references to another document.
We had before a word parser which parsed word document, but we didn’t have a control on the manner it parse it. Now with Aspose I can parse what I want and in the way I want it.
The only problem we had so far is the Colspan of a table, and it makes me crazy.
I’ve been working 3 days on an algorithm to calculate the Rowspan within a table, but I failed.
So would like please to help me on it?
Thanks
Robert

Hi Robert,

I posted code example here:
https://forum.aspose.com/t/102529
Hope this helps.
Best regards.