Is there a way to create a word table with more than 15 columns using Novacode DocX?
If I create a new table with greater than 14 columns, the table doesn't appear. I can get around this by doing something like this:
int addCols = Math.Min(data.colCount, 14);
Table docTable = doc.InsertTable(data.rowCount, addCols);
And then later this:
docTable.InsertColumn();
However, if I try to do this more than once to create a table with 16 or more columns, I have the same issue where the table doesn't appear.
Is there any way around this?
There is something like a bug in the library. When you create a table with many columns it becomes unusable. Reason is, that each column is created with its initial width. When you create table (independatly of the used method: InsertTable, AddTable, InsertTableBeforeSelf etc.) with many columns and the sum of their widths exceeds the document width - the table becomes unusable.
I solved this problem by adding columns in cycle and decreasing their width. My code is similar to this: