Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
How To Properly Handle Column / Row Spans Using TableNode
posted

Hey there,

I am currently creating an API that my team and I will use to generate / display reports in a RichTextView (that will afterwards end up being exported as a Word document).

We want to be able to easily add / generate tables within this document using a single AddTable method (specifying row / column counts). We will fill in the table at a later stage through a simple FillIn method (that has for inputs columnIndex, rowIndex and its content). This has been working well so far until I have tried to implement a way to edit this same table so that we could set column / row spans to it. I could achieve that by setting the members ColumnSpan / VerticalMerge of TableCellSettings...

But here comes my problem... When I try to set a columnspan, it will automatically add extra column(s) (depending on how big I set my columnspan) and shift the previously defined ones to its right, which will give me a table that looks like the one screenshotted below.

Is it possible to set a column / row span that will overtake and merge the cell next to it ? (e.g. in the case above, I would like to set a column span of 2 on "Column 1" that will merge Column 2 into the first one without creating an extra cell that shifts the remaining ones to its right)

Looking forward to hearing from you guys!

Cheers,

Max

  • 3520
    Offline posted

    Hello Max,

     

    Based on your description I would say that the approach you took is the correct one. The ColumnSpan should be used to merge cells but in addition the last cell of the respective row should be removed as follows:

    table.Rows[0].ChildNodes.RemoveAt(2);

     

    I used this approach to create a small sample application for your reference. Please review it and let me know if I can provide any further assistance.

    RTE_Sample.zip