Beispiel #1
0
        public static SstDocument Parse(XDocument xml, XmlNamespaceManager namespaceManager)
        {
            try
            {
                SstDocument sstDoc = new SstDocument();
                sstDoc.AddNewSst();
                CT_Sst sst = sstDoc.GetSst();
                sst.count       = XmlHelper.ReadInt(xml.Document.Root.Attribute("count"));
                sst.uniqueCount = XmlHelper.ReadInt(xml.Document.Root.Attribute("uniqueCount"));

                var nl = xml.XPathSelectElements("//d:sst/d:si", namespaceManager);
                if (nl != null)
                {
                    foreach (XElement node in nl)
                    {
                        CT_Rst rst = CT_Rst.Parse(node, namespaceManager);
                        sstDoc.sst.si.Add(rst);
                    }
                }
                return(sstDoc);
            }
            catch (XmlException e)
            {
                throw new IOException(e.Message);
            }
        }
Beispiel #2
0
        public static CT_Cell Parse(XElement node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Cell ctObj = new CT_Cell();

            ctObj.r = XmlHelper.ReadString(node.Attribute("r"));
            ctObj.s = XmlHelper.ReadUInt(node.Attribute("s"));
            if (node.Attribute("t") != null)
            {
                ctObj.t = (ST_CellType)Enum.Parse(typeof(ST_CellType), node.Attribute("t").Value);
            }
            ctObj.cm = XmlHelper.ReadUInt(node.Attribute("cm"));
            ctObj.vm = XmlHelper.ReadUInt(node.Attribute("vm"));
            ctObj.ph = XmlHelper.ReadBool(node.Attribute("ph"));
            foreach (XElement childNode in node.ChildElements())
            {
                if (childNode.Name.LocalName == "f")
                {
                    ctObj.f = CT_CellFormula.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "v")
                {
                    ctObj.v = childNode.Value;
                }
                else if (childNode.Name.LocalName == "is")
                {
                    ctObj.@is = CT_Rst.Parse(childNode, namespaceManager);
                }
                else if (childNode.Name.LocalName == "extLst")
                {
                    ctObj.extLst = CT_ExtensionList.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
Beispiel #3
0
        private string guidField = null;         // optional attribute

        //public CT_Comment()
        //{
        //    this.textField = new CT_Rst();
        //}
        public static CT_Comment Parse(XElement node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Comment ctObj = new CT_Comment();

            ctObj.@ref = XmlHelper.ReadString(node.Attribute("ref"));
            if (node.Attribute("authorId") != null)
            {
                ctObj.authorId = XmlHelper.ReadUInt(node.Attribute("authorId"));
            }
            ctObj.guid = XmlHelper.ReadString(node.Attribute("guid"));
            foreach (XElement childNode in node.ChildElements())
            {
                if (childNode.Name.LocalName == "text")
                {
                    ctObj.text = CT_Rst.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }