/// <summary> /// Adds the label alignment to the specified axis. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="axis"><c>Xml</c> node than represent an axis definition.</param> /// <param name="model">A <see cref="KnownHorizontalAlignment" /> value from model.</param> /// <exception cref="T:System.ArgumentNullException">If <paramref name="axis" /> is <c>null</c>.</exception> /// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The value specified is outside the range of valid values.</exception> /// <exception cref="T:System.InvalidOperationException">If <paramref name="axis" /> is not an axis.</exception> public static void AddAxisLabelAlignment(this XmlNode axis, KnownHorizontalAlignment model) { SentinelHelper.ArgumentNull(axis); SentinelHelper.IsEnumValid(model); SentinelHelper.IsFalse(axis.Name.Contains("catAx") || axis.Name.Contains("valAx") || axis.Name.Contains("dateAx"), "Imposible extraer tipo. el nodo no es de tipo eje"); var axisType = axis.ExtractAxisType(); switch (axisType) { case KnownAxisType.PrimaryCategoryAxis: case KnownAxisType.SecondaryCategoryAxis: var valAttr = ChartXmlHelper.CreateAttribute("val"); valAttr.Value = model.ToEppLabelAlignmentString(); var lblAlignXmlNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(axis, "c:lblAlgn"); lblAlignXmlNode.Attributes.Append(valAttr); break; case KnownAxisType.PrimaryValueAxis: case KnownAxisType.SecondaryValueAxis: break; } }
/// <summary> /// Adds a <c>outerShdw</c> node (Outer Shadow) to the node of type <c>effectLst</c> (Effect Container) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="effectContainerNode"><c>effectLst</c> node (Effect Container).</param> /// <param name="model">Shadow from model.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_outerShdw-2.html">http://www.schemacentral.com/sc/ooxml/e-a_outerShdw-2.html</a> /// </remarks> private static void AddOuterShadowNode(this XmlNode effectContainerNode, ShadowModel model) { var blurRadAttr = ChartXmlHelper.CreateAttribute("blurRad"); blurRadAttr.Value = "63500"; var distAttr = ChartXmlHelper.CreateAttribute("dist"); distAttr.Value = "71842"; var dirAttr = ChartXmlHelper.CreateAttribute("dir"); dirAttr.Value = "2700013"; var rotWithShapeAttr = ChartXmlHelper.CreateAttribute("rotWithShape"); rotWithShapeAttr.Value = "0"; var outerShadowNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(effectContainerNode, "a", "outerShdw"); outerShadowNode.Attributes.Append(blurRadAttr); outerShadowNode.Attributes.Append(distAttr); outerShadowNode.Attributes.Append(dirAttr); outerShadowNode.Attributes.Append(rotWithShapeAttr); outerShadowNode.AddRgbColorModelPercentageVariantNode(model); }
/// <summary> /// Adds a <c>scrgbClr</c> node (Rgb Color Model Percentage Variant) to the node of type <c>outerShdw</c> (Outer Shadow) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="outerShadowNode"><c>outerShdw</c> node (Outer Shadow).</param> /// <param name="model">Shadow from model.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_scrgbClr-1.html">http://www.schemacentral.com/sc/ooxml/e-a_scrgbClr-1.html</a> /// </remarks> private static void AddRgbColorModelPercentageVariantNode(this XmlNode outerShadowNode, ShadowModel model) { var redRadAttr = ChartXmlHelper.CreateAttribute("r"); redRadAttr.Value = "0"; var greenAttr = ChartXmlHelper.CreateAttribute("g"); greenAttr.Value = "0"; var blueAttr = ChartXmlHelper.CreateAttribute("b"); blueAttr.Value = "0"; var rgbColorModelPercentageVariantNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(outerShadowNode, "a", "scrgbClr"); rgbColorModelPercentageVariantNode.Attributes.Append(redRadAttr); rgbColorModelPercentageVariantNode.Attributes.Append(greenAttr); rgbColorModelPercentageVariantNode.Attributes.Append(blueAttr); var valAttr = ChartXmlHelper.CreateAttribute("val"); valAttr.Value = (model.Transparency * 100000).ToString(CultureInfo.InvariantCulture); var alphaNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(rgbColorModelPercentageVariantNode, "a", "alpha"); alphaNode.Attributes.Append(valAttr); }
/// <summary> /// Adds a <c>defRPr</c> node (Default Text Run Properties) to the node of type <c>pPr</c> (Text Paragraph Properties) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="node"><c>pPr</c> node (Text Paragraph Properties).</param> /// <param name="model">Font from model.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_defRPr-1.html">http://www.schemacentral.com/sc/ooxml/e-a_defRPr-1.html</a> /// </remarks> private static void AddDefaultTextRunPropertiesNode(this XmlNode node, FontModel model) { var sizeAttr = ChartXmlHelper.CreateAttribute("sz"); sizeAttr.Value = (model.Size * 100).ToString(CultureInfo.InvariantCulture); var boldAttr = ChartXmlHelper.CreateAttribute("b"); boldAttr.Value = model.Bold == YesNo.Yes ? "1" : "0"; var italicAttr = ChartXmlHelper.CreateAttribute("i"); italicAttr.Value = model.Italic == YesNo.Yes ? "1" : "0"; var underlineAttr = ChartXmlHelper.CreateAttribute("u"); underlineAttr.Value = model.Underline == YesNo.Yes ? "sng" : "none"; var defaultTextRunPropertiesNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(node, "a", "defRPr"); defaultTextRunPropertiesNode.Attributes.Append(boldAttr); defaultTextRunPropertiesNode.Attributes.Append(sizeAttr); defaultTextRunPropertiesNode.Attributes.Append(italicAttr); defaultTextRunPropertiesNode.Attributes.Append(underlineAttr); defaultTextRunPropertiesNode.AddSolidFillNode(model.GetColor()); defaultTextRunPropertiesNode.AddLatinFontNode(model.Name); defaultTextRunPropertiesNode.AddEastAsianFontNode(model.Name); defaultTextRunPropertiesNode.AddComplexScriptFontNode(model.Name); }
/// <summary> /// Adds a <c>endParaRPr</c> node (End Paragraph Run Properties) to the node of type <c>p</c> (Text Paragraphs) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="textParagraphsNode"><c>p</c> node (Text Paragraphs).</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_endParaRPr-1.html">http://www.schemacentral.com/sc/ooxml/e-a_endParaRPr-1.html</a> /// </remarks> private static void AddEndParagraphRunPropertiesNode(this XmlNode textParagraphsNode) { var langAttr = ChartXmlHelper.CreateAttribute("lang"); langAttr.Value = CultureInfo.CurrentCulture.Name; var endParagraphRunPropertiesNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(textParagraphsNode, "a", "endParaRPr"); endParagraphRunPropertiesNode.Attributes.Append(langAttr); }
/// <summary> /// Adds a <c>cs</c> node (Complex Script Font) to the node of type <c>defRPr</c> (Default Text Run Properties) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="node"><c>defRPr</c> node (Shape Properties).</param> /// <param name="fontname">Font name.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_cs-1.html">http://www.schemacentral.com/sc/ooxml/e-a_cs-1.html</a> /// </remarks> private static void AddComplexScriptFontNode(this XmlNode node, string fontname) { var typefaceAttr = ChartXmlHelper.CreateAttribute("typeface"); typefaceAttr.Value = fontname; var complexScriptFontNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(node, "a", "cs"); complexScriptFontNode.Attributes.Append(typefaceAttr); }
/// <summary> /// Adds a <c>ea</c> node (East Asian Font) to the node of type <c>defRPr</c> (Default Text Run Properties) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="node"><c>defRPr</c> node (Shape Properties).</param> /// <param name="fontname">Font name.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_ea-1.html">http://www.schemacentral.com/sc/ooxml/e-a_ea-1.html</a> /// </remarks> private static void AddEastAsianFontNode(this XmlNode node, string fontname) { var typefaceAttr = ChartXmlHelper.CreateAttribute("typeface"); typefaceAttr.Value = fontname; var eastAsianFontNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(node, "a", "ea"); eastAsianFontNode.Attributes.Append(typefaceAttr); }
/// <summary> /// Adds a <c>solidFill</c> node (Solid Fill Properties) to the node of type <c>spPr</c> (Shape properties) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="shapePropertiesNode"><c>spPr</c> node (Shape Properties).</param> /// <param name="color">Fill color.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_solidFill-1.html">http://www.schemacentral.com/sc/ooxml/e-a_solidFill-1.html</a> /// </remarks> private static void AddSolidFillNode(this XmlNode shapePropertiesNode, Color color) { var solidFillNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(shapePropertiesNode, "a", "solidFill"); var valAttr = ChartXmlHelper.CreateAttribute("val"); valAttr.Value = ColorHelper.ToHex(color).Replace("#", string.Empty); var srgbClrNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(solidFillNode, "a", "srgbClr"); srgbClrNode.Attributes.Append(valAttr); }
/// <summary> /// Adds a <c>bodyPr</c> node (Body Properties) to the node of type <c>txPr</c> (Text properties) specified. Not supported in <c>EPPlus</c> library. /// </summary> /// <param name="textPropertiesNode"><c>txPr</c> node (Text properties).</param> /// <param name="orientation">A <see cref="KnownLabelOrientation" /> value from model.</param> /// <remarks> /// For more information please see <a href="http://www.schemacentral.com/sc/ooxml/e-a_bodyPr-2.html">http://www.schemacentral.com/sc/ooxml/e-a_bodyPr-2.html</a> /// </remarks> private static void AddBodyPropertiesNode(this XmlNode textPropertiesNode, KnownLabelOrientation orientation) { var rotAttr = ChartXmlHelper.CreateAttribute("rot"); rotAttr.Value = orientation.ToAngle().ToString(CultureInfo.InvariantCulture); var vertAttr = ChartXmlHelper.CreateAttribute("vert"); vertAttr.Value = orientation == KnownLabelOrientation.Vertical ? "wordArtVert" : "horz"; var bodyPropertiesNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(textPropertiesNode, "a", "bodyPr"); bodyPropertiesNode.Attributes.Append(rotAttr); bodyPropertiesNode.Attributes.Append(vertAttr); }
/// <summary> /// Modifies crosses for the specified axis. Supported in <c>EPPlus</c> library but fails. /// </summary> /// <param name="axis"><c>Xml</c> node than represent an axis definition.</param> /// <exception cref="T:System.ArgumentNullException">If <paramref name="axis" /> is <c>null</c>.</exception> /// <exception cref="T:System.InvalidOperationException">If <paramref name="axis" /> is not an axis.</exception> public static void ModifyAxisCrosses(this XmlNode axis) { SentinelHelper.ArgumentNull(axis); SentinelHelper.IsFalse(axis.Name.Contains("catAx") || axis.Name.Contains("valAx") || axis.Name.Contains("dateAx"), "Imposible extraer tipo. el nodo no es de tipo eje"); var axisType = axis.ExtractAxisType(); if (axisType != KnownAxisType.SecondaryCategoryAxis) { return; } var valAttr = ChartXmlHelper.CreateAttribute("val"); valAttr.Value = "max"; var crossesXmlNode = ChartXmlHelper.CreateOrDefaultAndAppendElementToNode(axis, "c:crosses"); crossesXmlNode.Attributes.Append(valAttr); }