예제 #1
0
        internal static XElement CreateTable(int rowCount, int[] columnWidths)
        {
            var newTable = new XElement(XName.Get("tbl", DocX.w.NamespaceName),
                                        new XElement(XName.Get("tblPr", DocX.w.NamespaceName),
                                                     new XElement(XName.Get("tblStyle", DocX.w.NamespaceName), new XAttribute(XName.Get("val", DocX.w.NamespaceName), "TableGrid")),
                                                     new XElement(XName.Get("tblW", DocX.w.NamespaceName), new XAttribute(XName.Get("w", DocX.w.NamespaceName), "5000"), new XAttribute(XName.Get("type", DocX.w.NamespaceName), "auto")),
                                                     new XElement(XName.Get("tblLook", DocX.w.NamespaceName), new XAttribute(XName.Get("val", DocX.w.NamespaceName), "04A0"))));

            for (int i = 0; i < rowCount; i++)
            {
                var row = new XElement(XName.Get("tr", DocX.w.NamespaceName));

                for (int j = 0; j < columnWidths.Length; j++)
                {
                    var cell = HelperFunctions.CreateTableCell();
                    row.Add(cell);
                }

                newTable.Add(row);
            }
            return(newTable);
        }