コード例 #1
0
ファイル: ExcelSparklineGroup.cs プロジェクト: nxoxn/EPPlus
        private Color GetColorFromColorNode(XmlNode node)
        {
            // At the moment, only RGB color codes are supported.
            // However, other color definition types are possible, such as themes as outlined in the
            // ExcelDxfColor class.
            if (node == null)
            {
                return(Color.Empty);
            }
            var attribute = node.Attributes.GetNamedItem("rgb");

            if (attribute == null)
            {
                return(Color.Empty);
            }
            var parsed = ExcelConditionalFormattingHelper.ConvertFromColorCode(attribute.InnerText);

            if (Color.White.Equals(parsed))
            {
                return(Color.Empty);
            }
            else
            {
                return(parsed);
            }
        }
コード例 #2
0
ファイル: ExcelSparklineGroup.cs プロジェクト: nxoxn/EPPlus
        /// <summary>
        /// Variation of <see cref="ExcelConditionalFormattingHelper.GetAttributeDouble(XmlNode, string)"/> that
        /// returns null if the value cannot be found instead of double.NaN.
        /// </summary>
        /// <param name="topNode"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        private static double?GetAttributeDouble(XmlNode topNode, string attribute)
        {
            var result = ExcelConditionalFormattingHelper.GetAttributeDouble(topNode, attribute);

            if (double.IsNaN(result))
            {
                return(null);
            }
            else
            {
                return(result);
            }
        }
コード例 #3
0
ファイル: ExcelSparklineGroup.cs プロジェクト: nxoxn/EPPlus
        /// <summary>
        /// Copies the color and style contents of the given node to the current <see cref="ExcelSparklineGroup"/>,
        /// excluding the node's contained sparklines.
        /// </summary>
        /// <param name="topNode">The node containing the color and style elements to copy.</param>
        public void CopyNodeStyle(XmlNode topNode)
        {
            // Parse the color nodes.
            var node = topNode.SelectSingleNode("x14:colorSeries", base.NameSpaceManager);

            if (node != null)
            {
                this.ColorSeries = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorNegative", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorNegative = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorAxis", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorAxis = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorMarkers", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorMarkers = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorFirst", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorFirst = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorLast", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorLast = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorHigh", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorHigh = this.GetColorFromColorNode(node);
            }
            node = topNode.SelectSingleNode("x14:colorLow", base.NameSpaceManager);
            if (node != null)
            {
                this.ColorLow = this.GetColorFromColorNode(node);
            }
            // Parse the attributes.
            var attribute = topNode.Attributes["type"];

            if (attribute != null)
            {
                this.Type = ParseSparklineType(attribute.InnerText);
            }
            attribute = topNode.Attributes["displayEmptyCellsAs"];
            if (attribute != null)
            {
                this.DisplayEmptyCellsAs = ParseDisplayEmptyCellsAs(attribute.InnerText);
            }
            this.Negative      = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "negative");
            this.ManualMin     = GetAttributeDouble(topNode, "manualMin");
            this.ManualMax     = GetAttributeDouble(topNode, "manualMax");
            this.LineWeight    = GetAttributeDouble(topNode, "lineWeight");
            this.DateAxis      = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "dateAxis");
            this.Markers       = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "markers");
            this.High          = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "high");
            this.Low           = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "low");
            this.First         = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "first");
            this.Last          = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "last");
            this.DisplayXAxis  = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "displayXAxis");
            this.DisplayHidden = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "displayHidden");
            attribute          = topNode.Attributes["minAxisType"];
            if (attribute != null)
            {
                this.MinAxisType = ParseSparklineAxisMinMax(attribute.InnerText);
            }
            attribute = topNode.Attributes["maxAxisType"];
            if (attribute != null)
            {
                this.MaxAxisType = ParseSparklineAxisMinMax(attribute.InnerText);
            }
            this.RightToLeft = ExcelConditionalFormattingHelper.GetAttributeBool(topNode, "rightToLeft");
        }