public static CT_TableColumn Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_TableColumn ctObj = new CT_TableColumn(); if (node.Attributes["id"] != null) { ctObj.id = XmlHelper.ReadUInt(node.Attributes["id"]); } ctObj.uniqueName = XmlHelper.ReadString(node.Attributes["uniqueName"]); ctObj.name = XmlHelper.ReadString(node.Attributes["name"]); if (node.Attributes["totalsRowFunction"] != null) { ctObj.totalsRowFunction = (ST_TotalsRowFunction)Enum.Parse(typeof(ST_TotalsRowFunction), node.Attributes["totalsRowFunction"].Value); } ctObj.totalsRowLabel = XmlHelper.ReadString(node.Attributes["totalsRowLabel"]); if (node.Attributes["queryTableFieldId"] != null) { ctObj.queryTableFieldId = XmlHelper.ReadUInt(node.Attributes["queryTableFieldId"]); } if (node.Attributes["headerRowDxfId"] != null) { ctObj.headerRowDxfId = XmlHelper.ReadUInt(node.Attributes["headerRowDxfId"]); } if (node.Attributes["dataDxfId"] != null) { ctObj.dataDxfId = XmlHelper.ReadUInt(node.Attributes["dataDxfId"]); } if (node.Attributes["totalsRowDxfId"] != null) { ctObj.totalsRowDxfId = XmlHelper.ReadUInt(node.Attributes["totalsRowDxfId"]); } ctObj.headerRowCellStyle = XmlHelper.ReadString(node.Attributes["headerRowCellStyle"]); ctObj.dataCellStyle = XmlHelper.ReadString(node.Attributes["dataCellStyle"]); ctObj.totalsRowCellStyle = XmlHelper.ReadString(node.Attributes["totalsRowCellStyle"]); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "calculatedColumnFormula") { ctObj.calculatedColumnFormula = CT_TableFormula.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "totalsRowFormula") { ctObj.totalsRowFormula = CT_TableFormula.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "xmlColumnPr") { ctObj.xmlColumnPr = CT_XmlColumnPr.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "extLst") { ctObj.extLst = CT_ExtensionList.Parse(childNode, namespaceManager); } } return(ctObj); }
public static TableDocument Parse(XmlDocument xmldoc, XmlNamespaceManager namespaceMgr) { CT_Table obj = new CT_Table(); XmlElement tableNode = xmldoc.DocumentElement; obj.id = XmlHelper.ReadUInt(tableNode.Attributes["id"]); obj.name = XmlHelper.ReadString(tableNode.Attributes["name"]); obj.displayName = XmlHelper.ReadString(tableNode.Attributes["displayName"]); if (tableNode.Attributes["tableType"] != null) { obj.tableType = (ST_TableType)Enum.Parse(typeof(ST_TableType), tableNode.Attributes["tableType"].Value); } obj.totalsRowCount = XmlHelper.ReadUInt(tableNode.GetAttributeNode("totalsRowCount")); obj.totalsRowShown = XmlHelper.ReadBool(tableNode.GetAttributeNode("totalsRowShown")); obj.@ref = XmlHelper.ReadString(tableNode.Attributes["ref"]); XmlNode autoFilter = xmldoc.SelectSingleNode("//d:autoFilter", namespaceMgr); if (autoFilter != null) { obj.autoFilter = new CT_AutoFilter(); obj.autoFilter.@ref = XmlHelper.ReadString(autoFilter.Attributes["name"]); } XmlNodeList tableCols = xmldoc.SelectNodes("//d:tableColumns/d:tableColumn", namespaceMgr); if (tableCols != null) { obj.tableColumns = new CT_TableColumns(); obj.tableColumns.count = (uint)tableCols.Count; foreach (XmlElement tableColNode in tableCols) { CT_TableColumn ctTableCol = new CT_TableColumn(); ctTableCol.id = XmlHelper.ReadUInt(tableColNode.GetAttributeNode("id")); ctTableCol.name = XmlHelper.ReadString(tableColNode.GetAttributeNode("name")); ctTableCol.uniqueName = XmlHelper.ReadString(tableColNode.GetAttributeNode("uniqueName")); ctTableCol.totalsRowCellStyle = XmlHelper.ReadString(tableColNode.GetAttributeNode("totalsRowCellStyle")); ctTableCol.totalsRowDxfId = XmlHelper.ReadUInt(tableColNode.GetAttributeNode("totalsRowDxfId")); ctTableCol.totalsRowLabel = XmlHelper.ReadString(tableColNode.GetAttributeNode("totalsRowDxfId")); ctTableCol.queryTableFieldId = XmlHelper.ReadUInt(tableColNode.GetAttributeNode("queryTableFieldId")); ctTableCol.xmlColumnPr = CT_XmlColumnPr.Parse(tableColNode.SelectSingleNode("d:xmlColumnPr", namespaceMgr), namespaceMgr); //TODO: parse sub element of CT_TableColumn obj.tableColumns.tableColumn.Add(ctTableCol); } } XmlNode tableStyleInfo = xmldoc.SelectSingleNode("//d:tableStyleInfo", namespaceMgr); if (tableStyleInfo != null) { obj.tableStyleInfo = new CT_TableStyleInfo(); obj.tableStyleInfo.name = XmlHelper.ReadString(tableStyleInfo.Attributes["name"]); obj.tableStyleInfo.showFirstColumn = XmlHelper.ReadBool(tableStyleInfo.Attributes["showFirstColumn"]); obj.tableStyleInfo.showLastColumn = XmlHelper.ReadBool(tableStyleInfo.Attributes["showLastColumn"]); obj.tableStyleInfo.showRowStripes = XmlHelper.ReadBool(tableStyleInfo.Attributes["showRowStripes"]); obj.tableStyleInfo.showColumnStripes = XmlHelper.ReadBool(tableStyleInfo.Attributes["showColumnStripes"]); } return(new TableDocument(obj)); }