/** * * org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt to * org.openxmlformats.schemas.drawingml.x2006.main.CTFont adapter */ private static void ApplyAttributes(CT_RPrElt pr, CT_TextCharacterProperties rPr) { if (pr.sizeOfBArray() > 0) { rPr.b = (pr.GetBArray(0).val); } if (pr.sizeOfUArray() > 0) { ST_UnderlineValues u1 = pr.GetUArray(0).val; if (u1 == ST_UnderlineValues.single) { rPr.u = (ST_TextUnderlineType.sng); } else if (u1 == ST_UnderlineValues.@double) { rPr.u = (ST_TextUnderlineType.dbl); } else if (u1 == ST_UnderlineValues.none) { rPr.u = (ST_TextUnderlineType.none); } } if (pr.sizeOfIArray() > 0) { rPr.i = (pr.GetIArray(0).val); } if (pr.sizeOfFamilyArray() > 0) { CT_TextFont rFont = rPr.AddNewLatin(); rFont.typeface = (pr.GetRFontArray(0).val); } if (pr.sizeOfSzArray() > 0) { int sz = (int)(pr.GetSzArray(0).val * 100); rPr.sz = (sz); } if (pr.sizeOfColorArray() > 0) { CT_SolidColorFillProperties fill = rPr.IsSetSolidFill() ? rPr.solidFill : rPr.AddNewSolidFill(); NPOI.OpenXmlFormats.Spreadsheet.CT_Color xlsColor = pr.GetColorArray(0); if (xlsColor.IsSetRgb()) { CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr(); clr.val = (xlsColor.rgb); } else if (xlsColor.IsSetIndexed()) { HSSFColor indexed = HSSFColor.GetIndexHash()[(int)xlsColor.indexed] as HSSFColor; if (indexed != null) { byte[] rgb = indexed.RGB; CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr(); clr.val = (rgb); } } } }
public void SetFontColor(Color color) { CT_TextCharacterProperties rPr = GetRPr(); CT_SolidColorFillProperties fill = rPr.IsSetSolidFill() ? rPr.solidFill : rPr.AddNewSolidFill(); CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr(); clr.val = (new byte[] { color.R, color.G, color.B }); if (fill.IsSetHslClr()) { fill.UnsetHslClr(); } if (fill.IsSetPrstClr()) { fill.UnsetPrstClr(); } if (fill.IsSetSchemeClr()) { fill.UnsetSchemeClr(); } if (fill.IsSetScrgbClr()) { fill.UnsetScrgbClr(); } if (fill.IsSetSysClr()) { fill.UnsetSysClr(); } }
internal void AddToChart(CT_LineChart ctLineChart) { CT_LineSer ctLineSer = ctLineChart.AddNewSer(); CT_Grouping ctGrouping = ctLineChart.AddNewGrouping(); ctGrouping.val = ST_Grouping.standard; ctLineSer.AddNewIdx().val = (uint)id; ctLineSer.AddNewOrder().val = (uint)order; // No marker symbol on the chart line. ctLineSer.AddNewMarker().AddNewSymbol().val = ST_MarkerStyle.none; CT_AxDataSource catDS = ctLineSer.AddNewCat(); XSSFChartUtil.BuildAxDataSource(catDS, categories); CT_NumDataSource valueDS = ctLineSer.AddNewVal(); XSSFChartUtil.BuildNumDataSource(valueDS, values); if (IsTitleSet) { ctLineSer.tx = GetCTSerTx(); } if (fillColor != null) { ctLineSer.spPr = new OpenXmlFormats.Dml.Chart.CT_ShapeProperties(); CT_LineProperties ctLineProperties = ctLineSer.spPr.AddNewLn(); CT_SolidColorFillProperties ctSolidColorFillProperties = ctLineProperties.AddNewSolidFill(); CT_SRgbColor ctSRgbColor = ctSolidColorFillProperties.AddNewSrgbClr(); ctSRgbColor.val = fillColor; } }
/** * Sets the color used to fill this shape using the solid fill pattern. */ public void SetFillColor(int red, int green, int blue) { CT_ShapeProperties props = GetShapeProperties(); CT_SolidColorFillProperties fill = props.IsSetSolidFill() ? props.solidFill : props.AddNewSolidFill(); CT_SRgbColor rgb = new CT_SRgbColor(); rgb.val = (new byte[] { (byte)red, (byte)green, (byte)blue }); fill.srgbClr = (rgb); }
/** * The color applied to the lines of this shape. */ public void SetLineStyleColor(int red, int green, int blue) { CT_ShapeProperties props = GetShapeProperties(); CT_LineProperties ln = props.IsSetLn() ? props.ln : props.AddNewLn(); CT_SolidColorFillProperties fill = ln.IsSetSolidFill() ? ln.solidFill : ln.AddNewSolidFill(); CT_SRgbColor rgb = new CT_SRgbColor(); rgb.val = (new byte[] { (byte)red, (byte)green, (byte)blue }); fill.srgbClr = (rgb); }
/** * The color applied to the lines of this shape. */ public virtual void SetLineStyleColor(int red, int green, int blue) { Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties props = GetShapeProperties(); CT_LineProperties ln = props.IsSetLn() ? props.ln : props.AddNewLn(); CT_SolidColorFillProperties fill = ln.IsSetSolidFill() ? ln.solidFill : ln.AddNewSolidFill(); CT_SRgbColor rgb = new CT_SRgbColor(); rgb.val = (new byte[] { (byte)red, (byte)green, (byte)blue }); fill.srgbClr = (rgb); }
public CT_CustomColor() { this.prstClrField = new CT_PresetColor(); this.schemeClrField = new CT_SchemeColor(); this.sysClrField = new CT_SystemColor(); this.hslClrField = new CT_HslColor(); this.srgbClrField = new CT_SRgbColor(); this.scrgbClrField = new CT_ScRgbColor(); this.nameField = ""; }
public CT_TableStyleTextStyle() { this.extLstField = new CT_OfficeArtExtensionList(); this.prstClrField = new CT_PresetColor(); this.schemeClrField = new CT_SchemeColor(); this.sysClrField = new CT_SystemColor(); this.hslClrField = new CT_HslColor(); this.srgbClrField = new CT_SRgbColor(); this.scrgbClrField = new CT_ScRgbColor(); this.fontRefField = new CT_FontReference(); this.fontField = new CT_FontCollection(); this.bField = ST_OnOffStyleType.def; this.iField = ST_OnOffStyleType.def; }
public Color GetFontColor() { CT_TextCharacterProperties rPr = GetRPr(); if (rPr.IsSetSolidFill()) { CT_SolidColorFillProperties fill = rPr.solidFill; if (fill.IsSetSrgbClr()) { CT_SRgbColor clr = fill.srgbClr; byte[] rgb = clr.val; return(Color.FromArgb(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2])); } } return(Color.FromArgb(0, 0, 0)); }
public static CT_FontReference Parse(XElement node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_FontReference ctObj = new CT_FontReference(); if (node.Attribute("idx") != null) { ctObj.idx = (ST_FontCollectionIndex)Enum.Parse(typeof(ST_FontCollectionIndex), node.Attribute("idx").Value); } foreach (XElement childNode in node.ChildElements()) { if (childNode.Name.LocalName == "scrgbClr") { ctObj.scrgbClr = CT_ScRgbColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "srgbClr") { ctObj.srgbClr = CT_SRgbColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "hslClr") { ctObj.hslClr = CT_HslColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "sysClr") { ctObj.sysClr = CT_SystemColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "schemeClr") { ctObj.schemeClr = CT_SchemeColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "prstClr") { ctObj.prstClr = CT_PresetColor.Parse(childNode, namespaceManager); } } return(ctObj); }
public static CT_StyleMatrixReference Parse(XElement node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_StyleMatrixReference ctObj = new CT_StyleMatrixReference(); ctObj.idx = XmlHelper.ReadUInt(node.Attribute("idx")); foreach (XElement childNode in node.ChildElements()) { if (childNode.Name.LocalName == "scrgbClr") { ctObj.scrgbClr = CT_ScRgbColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "srgbClr") { ctObj.srgbClr = CT_SRgbColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "hslClr") { ctObj.hslClr = CT_HslColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "sysClr") { ctObj.sysClr = CT_SystemColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "schemeClr") { ctObj.schemeClr = CT_SchemeColor.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "prstClr") { ctObj.prstClr = CT_PresetColor.Parse(childNode, namespaceManager); } } return(ctObj); }
internal void AddToChart(CT_BarChart ctBarChart) { CT_BarSer ctBarSer = ctBarChart.AddNewSer(); CT_BarGrouping ctGrouping = ctBarChart.AddNewGrouping(); ctGrouping.val = ST_BarGrouping.clustered; ctBarSer.AddNewIdx().val = (uint)id; ctBarSer.AddNewOrder().val = (uint)order; CT_Boolean ctNoInvertIfNegative = new CT_Boolean(); ctNoInvertIfNegative.val = 0; ctBarSer.invertIfNegative = ctNoInvertIfNegative; CT_BarDir ctBarDir = ctBarChart.AddNewBarDir(); ctBarDir.val = ST_BarDir.col; CT_AxDataSource catDS = ctBarSer.AddNewCat(); XSSFChartUtil.BuildAxDataSource(catDS, categories); CT_NumDataSource valueDS = ctBarSer.AddNewVal(); XSSFChartUtil.BuildNumDataSource(valueDS, values); if (IsTitleSet) { ctBarSer.tx = GetCTSerTx(); } if (fillColor != null) { ctBarSer.spPr = new OpenXmlFormats.Dml.Chart.CT_ShapeProperties(); CT_SolidColorFillProperties ctSolidColorFillProperties = ctBarSer.spPr.AddNewSolidFill(); CT_SRgbColor ctSRgbColor = ctSolidColorFillProperties.AddNewSrgbClr(); ctSRgbColor.val = fillColor; } }
/** * org.Openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt to * org.Openxmlformats.schemas.Drawingml.x2006.main.CTFont adapter */ private static void ApplyAttributes(CT_RPrElt pr, CT_TextCharacterProperties rPr) { if (pr.SizeOfBArray() > 0) { rPr.b = (/*setter*/ pr.GetBArray(0).val); } if (pr.SizeOfUArray() > 0) { ST_UnderlineValues u1 = pr.GetUArray(0).val; if (u1 == ST_UnderlineValues.single) { rPr.u = (/*setter*/ ST_TextUnderlineType.sng); } else if (u1 == ST_UnderlineValues.@double) { rPr.u = (/*setter*/ ST_TextUnderlineType.dbl); } else if (u1 == ST_UnderlineValues.none) { rPr.u = (/*setter*/ ST_TextUnderlineType.none); } } if (pr.SizeOfIArray() > 0) { rPr.i = (/*setter*/ pr.GetIArray(0).val); } if (pr.SizeOfRFontArray() > 0) { CT_TextFont rFont = rPr.IsSetLatin() ? rPr.latin : rPr.AddNewLatin(); rFont.typeface = (/*setter*/ pr.GetRFontArray(0).val); } if (pr.SizeOfSzArray() > 0) { int sz = (int)(pr.GetSzArray(0).val * 100); rPr.sz = (/*setter*/ sz); } if (pr.SizeOfColorArray() > 0) { CT_SolidColorFillProperties fill = rPr.IsSetSolidFill() ? rPr.solidFill : rPr.AddNewSolidFill(); NPOI.OpenXmlFormats.Spreadsheet.CT_Color xlsColor = pr.GetColorArray(0); if (xlsColor.IsSetRgb()) { CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr(); clr.val = (/*setter*/ xlsColor.rgb); } else if (xlsColor.IsSetIndexed()) { HSSFColor indexed = (HSSFColor)HSSFColor.GetIndexHash()[((int)xlsColor.indexed)]; if (indexed != null) { byte[] rgb = new byte[3]; rgb[0] = (byte)indexed.GetTriplet()[0]; rgb[1] = (byte)indexed.GetTriplet()[1]; rgb[2] = (byte)indexed.GetTriplet()[2]; CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr(); clr.val = (/*setter*/ rgb); } } } }