I’m creating a table with dynamic data in an existing word document.
In the word document I just create a placeholder table with 2 rows and 1 column like this:
[ Custom label ]
Then I replace the cell with “@@DATA@@” with many cells (horizontally in the same row).
Some times the table takes all page size (also if not requested), but I have already opened a bug for this in similar conditions (WORDSNET-20098).
Some times the second row (“Custom label” in the example above), becomes large as the whole table (like if it was merged), but not always and this makes the result unpredictable.
I’m having an inconsistent behaviour in different conditions.
Apparently simply changing these conditions, I get different results for the same operation:
- Fixed cell width vs. auto cell width
- Different text lenght in cells
- Different cell width (for fixed cell width cases)
Moreover the inconsistence depends also on the way the output is produced:
- DOCX or PDF
- with or without calling UpdateTableLayout()
I tried to make a single word with all the different conditions (13 cases).
These are the strange behaviours I get:
- case 4, 5: label cell is large as table in both DOCX and PDF, without UpdateTableLayout
- case 4, 5: table takes all space in PDF, no DOCX, without UpdateTableLayout
- case 6: label cell is large as table in both DOCX and PDF, without UpdateTableLayout
- case 7, 8: last cell is larger in DOCX, no PDF, with UpdateTableLayout
- case 10, 13: label cell is large as table in both DOCX and PDF, without UpdateTableLayout
- case 10, 13: table takes all space , always
Note that there are different combinations, some are only in DOCX, some only in PDF, some in both, some with UpdateTableLayout(), some without UpdateTableLayout() and some in all conditions.
I don’t know what output is right and what is wrong, but I would expect to have the same behaviour in all conditions else I get different results applying the same C# logic to different word documents.
Tested with Aspose.Words 20.3 and Word 2013.
Bug Dynamic Columns.zip (115.1 KB)
See also this related bug report: