Novacode.Table.Table C# (CSharp) Method

Table() private method

private Table ( DocX document, System.Xml.Linq.XElement xml ) : System
document DocX
xml System.Xml.Linq.XElement
return System
        internal Table(DocX document, XElement xml)
            : base(document, xml)
        {
            autofit = AutoFit.ColumnWidth;
            this.Xml = xml;
            this.mainPart = document.mainPart;

            XElement properties = xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));

            XElement style = properties?.Element(XName.Get("tblStyle", DocX.w.NamespaceName));
            if (style != null)
            {
                XAttribute val = style.Attribute(XName.Get("val", DocX.w.NamespaceName));

                if (val != null)
                {
                    String cleanValue = val.Value.Replace("-", string.Empty);
                    if (Enum.IsDefined(typeof(TableDesign), cleanValue))
                    {
                        design = (TableDesign)Enum.Parse(typeof(TableDesign), cleanValue);
                    }
                    else
                    {
                        design = TableDesign.Custom;
                    }
                }
                else
                    design = TableDesign.None;
            }

            else
                design = TableDesign.None;

            XElement tableLook = properties?.Element(XName.Get("tblLook", DocX.w.NamespaceName));
            if (tableLook != null)
            {
                TableLook = new TableLook
                {
                    FirstRow = tableLook.GetAttribute(XName.Get("firstRow", DocX.w.NamespaceName)) == "1",
                    LastRow = tableLook.GetAttribute(XName.Get("lastRow", DocX.w.NamespaceName)) == "1",
                    FirstColumn = tableLook.GetAttribute(XName.Get("firstColumn", DocX.w.NamespaceName)) == "1",
                    LastColumn = tableLook.GetAttribute(XName.Get("lastColumn", DocX.w.NamespaceName)) == "1",
                    NoHorizontalBanding = tableLook.GetAttribute(XName.Get("noHBand", DocX.w.NamespaceName)) == "1",
                    NoVerticalBanding = tableLook.GetAttribute(XName.Get("noVBand", DocX.w.NamespaceName)) == "1"
                };
            }
        }