Table widths again


I have followed the various threads on resizing a table using aspose words, but most if not all the examples and situations deal with creating tables in code. My current implementation has complex tables which are created in word and loaded, as a template, into my application.

I ned to be able to add columns dynamically. Currently my code clones a dummy column which may include sub-columns and then generates the necessay columns and renames merge fields and all this works. However, setting the Cell.CellFormat.Width property has no effect on the width of the table. The table width appears to be limited to the template width. To get round this problem I use Row.RowFormat.AllowAutoFit and assign it to TRUE just for the first row of the table.

The question I have is that what determines the final width of the columns when the property is set to true. I am using table data related merge fields within the cells. So is the final size of the table set once the merge fields have been updated with their corresponding data or on the actual length of the merge fields ?

The other question is how does one get the table width to reflect the values of the Cell.CellFormat.Width values when they are updated. One of the threads referred to a prefered width property which had not been exposed yet. I am currently using Aspose. 3.6.x.x. does the latest version of Aspose words allow me to dynamically change table widths?


AllowAutoFit = true dictates Word to manage cell widths according to their contents. The cell width grow when the content grow. It also keeps the total width of the table to fit the page width. If table width reaches the page width the cell widths are distributed proportional to the width of their content.

If the cell width is set explicitly through its CellFormat.Width property then this cell width does not grow depending on its content. Thus, AutoFit stops fitting cell width to its content but still keeps the table width in page boundaries, this time proportional to their CellFormat.Width value.

Only few changes were made in table handling API since 3.6.x.x. Namely, WrapText and FitText properties were made public.

We are going to expand table handling API later this year however.

Hope this helps.

Best regards,