/// <summary>
        /// Fills a <see cref="OfficeOpenXml.Drawing.ExcelDrawingBorder"/> object with model data.
        /// </summary>
        /// <param name="border"><see cref="OfficeOpenXml.Drawing.ExcelDrawingBorder"/> object.</param>
        /// <param name="element">Chart element.</param>
        /// <param name="model">Chart border model definition.</param>
        /// <exception cref="T:System.ArgumentNullException">If <paramref name="border" /> is <c>null</c>.</exception>
        /// <exception cref="T:System.ArgumentNullException">If <paramref name="model" /> is <c>null</c>.</exception>
        /// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The value specified is outside the range of valid values.</exception>
        public static void FormatFromModel(this ExcelDrawingBorder border, KnownChartElement element, ChartBorderModel model)
        {
            SentinelHelper.IsEnumValid(element);
            SentinelHelper.ArgumentNull(model);
            SentinelHelper.ArgumentNull(border);

            if (model.Show == YesNo.Yes)
            {
                border.Fill.Color = model.GetColor();
                border.Width      = model.Width.ToEppBorderWidth();
                border.LineStyle  = model.Style.ToEppLineStyle();
            }

            if (model.Shadow.Show == YesNo.No)
            {
                return;
            }

            var root  = ChartXmlHelper.FromKnownChartElement(element);
            var exist = ChartXmlHelper.TryGetElementFrom(root, "c:spPr", out var shapePropertiesNode);

            shapePropertiesNode.AddEffectContainerNode(model.Shadow);

            if (!exist)
            {
                root.AppendChild(shapePropertiesNode);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Converts a <see cref="OfficeOpenXml.Drawing.Chart.ExcelChartAxis"/> objects to <see cref="System.Array"/> elements of type <see cref="System.Xml.XmlNode"/>.
        /// </summary>
        /// <param name="axes"><see cref="OfficeOpenXml.Drawing.Chart.ExcelChartAxis"/> objects.</param>
        /// <returns>
        /// List of nodes equivalent a <see cref="OfficeOpenXml.Drawing.Chart.ExcelChartAxis"/> objects.
        /// </returns>
        /// <exception cref="System.ComponentModel.InvalidEnumArgumentException">If <paramref name="axes" /> not belong to enumeration.</exception>
        public static IEnumerable <XmlNode> ToAxisXmlFrom(IEnumerable <ExcelChartAxis> axes)
        {
            SentinelHelper.ArgumentNull(axes);

            var xmlAxisNodeList = new List <XmlNode>
            {
                ChartXmlHelper.FromKnownChartElement(KnownChartElement.PrimaryCategoryAxis),
                ChartXmlHelper.FromKnownChartElement(KnownChartElement.PrimaryValueAxis),
            };

            var catAxisXmlNodes = ChartXmlHelper.GetElementsByTagName("c:catAx");

            if (catAxisXmlNodes.Count() <= 1)
            {
                return(xmlAxisNodeList);
            }

            xmlAxisNodeList.Add(ChartXmlHelper.FromKnownChartElement(KnownChartElement.SecondaryCategoryAxis));
            xmlAxisNodeList.Add(ChartXmlHelper.FromKnownChartElement(KnownChartElement.SecondaryValueAxis));

            return(xmlAxisNodeList);
        }