This project has moved. For the latest updates, please go here.


Apr 23, 2015 at 8:23 AM
If i create table with 14 columns it fill in my document and is grate. But when i insert table with 16 cilumns it gous out from document and i can not see it. It is bug? How can i insert table larger then 14 columns?
May 31, 2015 at 1:03 AM
This happened to me also. Did you find a work around?
Jun 5, 2015 at 6:14 PM
I found one!

if you are specifying the widths for all the columns in the table, a fix is to not add the default widths for the table..

that is at line 443 through 447 of HelperFunctions.cs

Remove this portion
            XElement tableGrid = new XElement(XName.Get("tblGrid", DocX.w.NamespaceName));
            for (int i = 0; i < columnWidths.Length; i++)
                tableGrid.Add(new XElement(XName.Get("gridCol", DocX.w.NamespaceName), new XAttribute(XName.Get("w", DocX.w.NamespaceName), XmlConvert.ToString(columnWidths[i]))));

And here's a unit test
        private static Border BlankBorder = new Border(BorderStyle.Tcbs_none, 0, 0, Color.White);

        public void LargeTable()
            using (var output = File.Open(_directoryWithFiles + "LargeTable.docx", FileMode.Create))
                using (var doc = DocX.Create(output))
                    var tbl = doc.InsertTable(1, 18);
                    var wholeWidth = doc.PageWidth - doc.MarginLeft - doc.MarginRight;
                    var colWidth = wholeWidth/tbl.ColumnCount;
                    var colWidths = new int[tbl.ColumnCount];
                    var r = tbl.Rows[0];
                    var cx = 0;
                    foreach (var cell in r.Cells)
                        cell.Paragraphs.First().Append("Col " + cx);
                        cell.Width = colWidth;
                        cell.MarginBottom = 0;
                        cell.MarginLeft = 0;
                        cell.MarginRight = 0;
                        cell.MarginTop = 0;
                    tbl.SetBorder(TableBorderType.Bottom, BlankBorder);
                    tbl.SetBorder(TableBorderType.Left, BlankBorder);
                    tbl.SetBorder(TableBorderType.Right, BlankBorder);
                    tbl.SetBorder(TableBorderType.Top, BlankBorder);
                    tbl.SetBorder(TableBorderType.InsideV, BlankBorder);
                    tbl.SetBorder(TableBorderType.InsideH, BlankBorder);

Jun 7, 2015 at 10:37 PM
@someotherdevguy Would you say this is a global fix, or just for this occassion? Can you submit it as a patch? I still need to include your other patches so might as well go all the way and implement all 4.
Jun 10, 2015 at 9:04 PM
Edited Jun 10, 2015 at 9:05 PM
I'm not positive yet if this is a global fix.. I'll add some more unit tests and make sure it's ok if the column widths aren't specified for each column... then I'll also submit a combo patch with all the fixes instead of just the changes