public void SerializeCalcChainDocumentTest() { var calcChain = new CT_CalcChain(); { var cell1 = new CT_CalcCell(); cell1.r = "E1"; cell1.i = 1; calcChain.AddC(cell1); } { var cell1 = new CT_CalcCell(); cell1.r = "D1"; calcChain.AddC(cell1); } { var cell1 = new CT_CalcCell(); cell1.r = "C1"; calcChain.AddC(cell1); } using (StringWriter stream = new StringWriter()) { CT_CalcChain_Accessor.serializer.Serialize(stream, calcChain, CT_CalcChain_Accessor.namespaces); string expected = @"<?xml version=""1.0"" encoding=""utf-16""?> <calcChain xmlns=""http://schemas.openxmlformats.org/spreadsheetml/2006/main""> <c r=""E1"" i=""1"" /> <c r=""D1"" /> <c r=""C1"" /> </calcChain>"; Assert.AreEqual(expected, stream.ToString()); } }
public static CalcChainDocument Parse(XmlDocument xmlDoc, XmlNamespaceManager NameSpaceManager) { var calcChainDoc = new CalcChainDocument(); foreach (XmlElement node in xmlDoc.SelectNodes("//d:c", NameSpaceManager)) { CT_CalcCell cc = new CT_CalcCell(); if (node.GetAttributeNode("i") != null) { cc.i = Int32.Parse(node.GetAttribute("i")); cc.iSpecified = true; } cc.r = node.GetAttribute("r"); if (node.GetAttributeNode("t") != null) { string value = node.GetAttribute("t"); if (value == "1" || value.ToLower() == "true") { cc.t = true; } else { cc.t = false; } } if (node.GetAttributeNode("s") != null) { string value = node.GetAttribute("s"); if (value == "1" || value.ToLower() == "true") { cc.s = true; } else { cc.s = false; } } if (node.GetAttributeNode("l") != null) { string value = node.GetAttribute("l"); if (value == "1" || value.ToLower() == "true") { cc.l = true; } else { cc.l = false; } } calcChainDoc.calcChain.AddC(cc); } return calcChainDoc; }
public static CalcChainDocument Parse(XmlDocument xmlDoc, XmlNamespaceManager NameSpaceManager) { CalcChainDocument calcChainDoc = new CalcChainDocument(); foreach (XmlElement node in xmlDoc.SelectNodes("//d:c", NameSpaceManager)) { CT_CalcCell cc = new CT_CalcCell(); if (node.GetAttributeNode("i")!= null) { cc.i = XmlHelper.ReadInt(node.GetAttributeNode("i")); cc.iSpecified = true; } cc.r = node.GetAttribute("r"); cc.t = XmlHelper.ReadBool(node.GetAttributeNode("t")); cc.s = XmlHelper.ReadBool(node.GetAttributeNode("s")); cc.l = XmlHelper.ReadBool(node.GetAttributeNode("l")); calcChainDoc.calcChain.AddC(cc); } return calcChainDoc; }
public static CalcChainDocument Parse(XmlDocument xmlDoc, XmlNamespaceManager NameSpaceManager) { CalcChainDocument calcChainDoc = new CalcChainDocument(); foreach (XmlElement node in xmlDoc.SelectNodes("//d:c", NameSpaceManager)) { CT_CalcCell cc = new CT_CalcCell(); if (node.GetAttributeNode("i") != null) { cc.i = XmlHelper.ReadInt(node.GetAttributeNode("i")); cc.iSpecified = true; } cc.r = node.GetAttribute("r"); cc.t = XmlHelper.ReadBool(node.GetAttributeNode("t")); cc.s = XmlHelper.ReadBool(node.GetAttributeNode("s")); cc.l = XmlHelper.ReadBool(node.GetAttributeNode("l")); calcChainDoc.calcChain.AddC(cc); } return(calcChainDoc); }
public void AddC(CT_CalcCell cell) { this.c.Add(cell); }