예제 #1
0
        private string SelectXmlNodes(string[] NodesToBeIterated)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var nodetobeiterated in NodesToBeIterated)
            {
                using (StringReader s = new StringReader(cleanEngineXmlString))
                {
                    XDocument xdoc       = XDocument.Load(s);
                    var       childnodes = xdoc.Descendants(nodetobeiterated).ToArray();
                    foreach (var childnode in childnodes)
                    {
                        var child =
                            new XElement("PayableInvoiceAsset",
                                         NodeMap.Where(keyvaluePair => !keyvaluePair.Value.IsParentAttribute &&
                                                       keyvaluePair.Value.engineNodeOptions != EngineNodeOptions.ChildEntityPointer)
                                         .Select(keyvaluePair => new XElement(keyvaluePair.Key,
                                                                              XmlHelperInstance.FetchValueFromNodeForChild(NodeMap.GetValueOrDefault(keyvaluePair.Key), childnode))
                                                 )
                                         );
                        sb.Append(child.ConvertToString());
                    }
                }
            }
            return(sb.ToString());
        }
예제 #2
0
        private ExcelDxfBorderItem GetBorderItem(XmlHelperInstance helper, string path)
        {
            ExcelDxfBorderItem bi = new ExcelDxfBorderItem(_styles);

            bi.Style = GetBorderStyleEnum(helper.GetXmlNodeString(path + "/@style"));
            bi.Color = GetColor(helper, path + "/d:color");
            return(bi);
        }
예제 #3
0
 private void GenerateDataSet(out XElement parentDataSet, out string childDataSet)
 {
     parentDataSet =
         new XElement("PayableInvoices",
                      new XElement("PayableInvoice",
                                   NodeMap.Where(keyvaluePair => keyvaluePair.Value.IsParentAttribute)
                                   .Select(keyvaluePair => new XElement(keyvaluePair.Key,
                                                                        XmlHelperInstance.FetchValueFromNodeForParent(NodeMap.GetValueOrDefault(keyvaluePair.Key)))
                                           )
                                   )
                      );
     childDataSet = "<PayableInvoiceAssets>" + GenerateChildDataSet() + "</PayableInvoiceAssets>";
 }
예제 #4
0
        private string CreateDeserializedDataSet(string engineXmlString)
        {
            string endTag = "</PayableInvoice></PayableInvoices>";

            cleanEngineXmlString = XmlPreprocessorInstance.CleanXmlFromEngine(engineXmlString);
            XmlHelperInstance.SetXmlString(cleanEngineXmlString);
            XElement parentDataSet;
            string   childDataSet;

            GenerateDataSet(out parentDataSet, out childDataSet);
            Console.WriteLine(XElement.Parse(parentDataSet.ConvertToString().Replace(endTag, childDataSet + endTag)));
            Console.ReadKey();
            return(parentDataSet.ConvertToString().Replace(endTag, childDataSet + endTag));
        }
예제 #5
0
		/// <summary>
		/// Set the cache field node.
		/// </summary>
		/// <param name="cacheField">The cache field node being set.</param>
		internal void SetCacheFieldNode(XmlNode cacheField)
		{
			myCacheFieldHelper = new XmlHelperInstance(this.NameSpaceManager, cacheField);
			var groupNode = cacheField.SelectSingleNode("d:fieldGroup", this.NameSpaceManager);
			if (groupNode != null)
			{
				var groupBy = groupNode.SelectSingleNode("d:rangePr/@groupBy", this.NameSpaceManager);
				if (groupBy == null)
					myGrouping = new ExcelPivotTableFieldNumericGroup(this.NameSpaceManager, cacheField);
				else
				{
					this.DateGrouping = (eDateGroupBy)Enum.Parse(typeof(eDateGroupBy), groupBy.Value, true);
					myGrouping = new ExcelPivotTableFieldDateGroup(this.NameSpaceManager, groupNode);
				}
			}
		}
예제 #6
0
        private ExcelDxfColor GetColor(XmlHelperInstance helper, string path)
        {
            ExcelDxfColor ret = new ExcelDxfColor(_styles);

            ret.Theme = (eThemeSchemeColor?)helper.GetXmlNodeIntNull(path + "/@theme");
            ret.Index = helper.GetXmlNodeIntNull(path + "/@indexed");
            string rgb = helper.GetXmlNodeString(path + "/@rgb");

            if (rgb != "")
            {
                ret.Color = Color.FromArgb(int.Parse(rgb.Replace("#", ""), NumberStyles.HexNumber));
            }
            ret.Auto = helper.GetXmlNodeBoolNullable(path + "/@auto");
            ret.Tint = helper.GetXmlNodeDoubleNull(path + "/@tint");
            return(ret);
        }
예제 #7
0
        private ExcelDxfColor GetColor(XmlHelperInstance helper, string path)
        {
            ExcelDxfColor ret = new ExcelDxfColor(_styles);

            ret.Theme = helper.GetXmlNodeIntNull(path + "/@theme");
            ret.Index = helper.GetXmlNodeIntNull(path + "/@index");
            string rgb = helper.GetXmlNodeString(path + "/@rgb");

            if (rgb != "")
            {
                ret.Color = Color.FromArgb(int.Parse(rgb.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier),
                                           int.Parse(rgb.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier),
                                           int.Parse(rgb.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier),
                                           int.Parse(rgb.Substring(6, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
            }
            ret.Auto = helper.GetXmlNodeBoolNullable(path + "/@auto");
            ret.Tint = helper.GetXmlNodeDoubleNull(path + "/@tint");
            return(ret);
        }
        private ExcelSparklineGroup NewSparklineGroup()
        {
            var xh = new XmlHelperInstance(_ws.NameSpaceManager, _ws.WorksheetXml); //SelectSingleNode("/d:worksheet", _ws.NameSpaceManager)

            if (!xh.ExistNode(_extPath + _searchPath))
            {
                var ext = xh.CreateNode(_extPath, false, true);
                if (ext.Attributes["uri"] == null)
                {
                    ((XmlElement)ext).SetAttribute("uri", "{05C60535-1F16-4fd2-B633-F4F36F0B64E0}");        //Guid URI for sparklines... https://msdn.microsoft.com/en-us/library/dd905242(v=office.12).aspx
                }
            }
            var parent = xh.CreateNode(_topSearchPath);

            var topNode = _ws.WorksheetXml.CreateElement("x14", "sparklineGroup", ExcelPackage.schemaMainX14);

            topNode.SetAttribute("xmlns:xm", ExcelPackage.schemaMainXm);
            topNode.SetAttribute("uid", ExcelPackage.schemaXr2, $"{{{Guid.NewGuid().ToString()}}}");
            parent.AppendChild(topNode);
            topNode.AppendChild(topNode.OwnerDocument.CreateElement("x14", "sparklines", ExcelPackage.schemaMainX14));
            return(new ExcelSparklineGroup(_ws.NameSpaceManager, topNode, _ws));
        }
예제 #9
0
        internal ExcelDxfStyleConditionalFormatting(XmlNamespaceManager nameSpaceManager, XmlNode topNode, ExcelStyles styles) : base(styles)
        {
            NumberFormat = new ExcelDxfNumberFormat(_styles);
            Font         = new ExcelDxfFontBase(_styles);
            Border       = new ExcelDxfBorderBase(_styles);
            Fill         = new ExcelDxfFill(_styles);
            if (topNode != null)
            {
                _helper = new XmlHelperInstance(nameSpaceManager, topNode);
                NumberFormat.NumFmtID = _helper.GetXmlNodeInt("d:numFmt/@numFmtId");
                NumberFormat.Format   = _helper.GetXmlNodeString("d:numFmt/@formatCode");
                if (NumberFormat.NumFmtID < 164 && string.IsNullOrEmpty(NumberFormat.Format))
                {
                    NumberFormat.Format = ExcelNumberFormat.GetFromBuildInFromID(NumberFormat.NumFmtID);
                }

                Font.Bold      = _helper.GetXmlNodeBoolNullable("d:font/d:b/@val");
                Font.Italic    = _helper.GetXmlNodeBoolNullable("d:font/d:i/@val");
                Font.Strike    = _helper.GetXmlNodeBoolNullable("d:font/d:strike");
                Font.Underline = GetUnderLineEnum(_helper.GetXmlNodeString("d:font/d:u/@val"));
                Font.Color     = GetColor(_helper, "d:font/d:color");

                Border.Left   = GetBorderItem(_helper, "d:border/d:left");
                Border.Right  = GetBorderItem(_helper, "d:border/d:right");
                Border.Bottom = GetBorderItem(_helper, "d:border/d:bottom");
                Border.Top    = GetBorderItem(_helper, "d:border/d:top");

                Fill.PatternType     = GetPatternTypeEnum(_helper.GetXmlNodeString("d:fill/d:patternFill/@patternType"));
                Fill.BackgroundColor = GetColor(_helper, "d:fill/d:patternFill/d:bgColor/");
                Fill.PatternColor    = GetColor(_helper, "d:fill/d:patternFill/d:fgColor/");
            }
            else
            {
                _helper = new XmlHelperInstance(nameSpaceManager);
            }
            _helper.SchemaNodeOrder = new string[] { "font", "numFmt", "fill", "border" };
        }
예제 #10
0
 internal void SetCacheFieldNode(XmlNode cacheField)
 {
     _cacheFieldHelper = new XmlHelperInstance(NameSpaceManager, cacheField);
     var groupNode = cacheField.SelectSingleNode("d:fieldGroup", NameSpaceManager);
     if (groupNode!=null)
     {
         var groupBy = groupNode.SelectSingleNode("d:rangePr/@groupBy", NameSpaceManager);
         if (groupBy==null)
         {
             _grouping = new ExcelPivotTableFieldNumericGroup(NameSpaceManager, cacheField);
         }
         else
         {
             DateGrouping=(eDateGroupBy)Enum.Parse(typeof(eDateGroupBy), groupBy.Value, true);
             _grouping = new ExcelPivotTableFieldDateGroup(NameSpaceManager, groupNode);
         }
     }
 }