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

Free Support Forum - aspose.com

Tablerows with uneven cellcount exceeds tablewidth

Hello

I’m trying to create a table with uneven cellcount in each row. The width of each row shouldn’t exceed the width of the table, but somehow thats whats happening.

Example:

Row 1: 1st cell (pref. width 25%), 2nd cell (pref. width 75%) <-- looks fine

Row 2: 1st cell (pref. width 15%, 2nd cell (pref. width 20%), 3rd cell (pref width.65%) <-- last cell is placed outside the table, and the two first cell aligns width with those of row 1.

The tables pref. width is set to 100% and AllowAutoFit = false.

You have a page regarding “Working with columns”


and there is an illustration of what i want to achieve but unfortunately there is no example of how to implement just that illustration.

Thanks!

Hi Morten,

Thanks for your inquiry. It would be great if you please share following detail for investigation purposes.


  • Please attach your input Word document.
  • Please

    create a standalone/runnable simple application (for example a Console
    Application Project
    ) that demonstrates the code (Aspose.Words code) you used to generate
    your output document


Unfortunately,
it is difficult to say what the problem is without the Document(s) and
simplified application. We need your Document(s) and simple project to
reproduce the problem. As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

Hello there


Ive uploaded two documents, one with the format i want and one with the output of the application. Ive also included a console app. that outputs the wrong table format.

BTW i was unable to recover the password of my original account, so im posting from another.

Thanks for helping out, looking forward to hear from you.

/Morten

Hi Morten,


Thanks for sharing the detail.

Please
note that a table in MS Word is a set of independent rows. Each row has
a set of cells independent on cells of other rows. So there is no
logical “column” in a MS Word’s table. “The 1st column” is something
like “a set of the 1st cells of each row in a table”.

For
example, it’s possible to have a table where the 1st row consists of
two cells: 2cm and 1cm and the 2nd row consists of different two cells:
1cm and 2cm of width.

I
suggest you, please set the size of each cell in points instead of merging
columns. I have modified the code of class ResultFrameworkDocumentBuilderService. Please check the attachment. I have also attached the output docx with this post for your kind reference. Hope this helps you.

Hi Tahir


First of all thank you very much for taking time to look into my issue - much appreciated!

I’ve had time to try out your solution and it does indeed work as expected, i am however a bit curious as to why it’s not possible to achieve the result using percentages instead of units. I find that a bid odd frankly.

BR
Morten

Hi Morten,


Thanks for your inquiry. Yes, it is possible to get the required output by setting the cell width as percentage value. You can use PreferredWidth with FromPercent and FromPoints methods. I have modified your code example with cell width from percentage value. Please check the attachment. I have also attached the output document with this post for your kind reference.