Free Support Forum - aspose.com

Question on Tables

Two questions regarding creating tables. I am programmatically inserting a table using the DocumentBuilder. Right now I am having problems with:

1. Getting the table to span the width of the page. By default the width of the table is the width of its contents.

2. Another problem that I am having is with table that has 17 columns. It is not being rendered correctly on the page. half off the table ends up outside the document.

Hi,

Both the problems would be eliminated by setting the width of the table to 100% but unfortunately at the moment the API only allows to specify the width of individual cells in points. The only case when different table width measurement units are satisfied is importing from HTML. However, we're planning to expose the capability of setting table and cell width in various units in the future, in several months I think.

Meanwhile try to calculate the width of the cells in such a way that the resulting table width fits the width of the page. Consider the CellFormat.FitText property which fits text in the cell, compressing each paragraph to the width of the cell. Consider also the RowFormat.AllowAutoFit property that allows Microsoft Word to automatically resize cells in a table to fit their contents.