Class ExcelChartStyleManager
Manages styles for a chart
Inherited Members
Namespace: OfficeOpenXml.Drawing.Chart.Style
Assembly: EPPlus.dll
Syntax
public class ExcelChartStyleManager : XmlHelper
Fields
ColorsLibrary
A library where chart color styles can be loaded for easier access
Declaration
public static Dictionary<int, ExcelChartStyleLibraryItem> ColorsLibrary
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Int32, ExcelChartStyleLibraryItem> |
StyleLibrary
A library where chart styles can be loaded for easier access. EPPlus loads most buildin styles into this collection.
Declaration
public static Dictionary<int, ExcelChartStyleLibraryItem> StyleLibrary
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Int32, ExcelChartStyleLibraryItem> |
Properties
ColorsManager
A reference to color style settings for the chart
Declaration
public ExcelChartColorsManager ColorsManager { get; }
Property Value
Type | Description |
---|---|
ExcelChartColorsManager |
ColorsXml
The color xml document
Declaration
public XmlDocument ColorsXml { get; }
Property Value
Type | Description |
---|---|
System.Xml.XmlDocument |
Style
A reference to style settings for the chart
Declaration
public ExcelChartStyle Style { get; }
Property Value
Type | Description |
---|---|
ExcelChartStyle |
StyleXml
The chart style xml document
Declaration
public XmlDocument StyleXml { get; }
Property Value
Type | Description |
---|---|
System.Xml.XmlDocument |
ThemeOverride
If the chart has a different theme than the theme in the workbook, this property defines that theme.
Declaration
public ExcelThemeOverride ThemeOverride { get; }
Property Value
Type | Description |
---|---|
ExcelThemeOverride |
ThemeOverrideXml
Overrides the current theme for the chart.
Declaration
public XmlDocument ThemeOverrideXml { get; }
Property Value
Type | Description |
---|---|
System.Xml.XmlDocument |
Methods
ApplyStyles()
Apply the chart and color style to the chart. Style ColorsManager
Declaration
public void ApplyStyles()
ApplyStylesEx()
Apply the chart and color style to the chart. Style ColorsManager
Declaration
public void ApplyStylesEx()
CreateEmptyStyle(eChartStyle)
Creates an empty style and color for chart, ready to be customized
Declaration
public void CreateEmptyStyle(eChartStyle fallBackStyle = eChartStyle.Style2)
Parameters
Type | Name | Description |
---|---|---|
eChartStyle | fallBackStyle |
LoadColorXml(XmlDocument)
Load a color xml documents
Declaration
public void LoadColorXml(XmlDocument colorXml)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | colorXml | The color xml |
LoadStyles()
Loads the default chart style library from the internal resource library. Loads styles, colors and the default theme.
Declaration
public static void LoadStyles()
LoadStyles(DirectoryInfo, Boolean)
Load all chart style library files (*.ecs) into memory from the supplied directory
Declaration
public static void LoadStyles(DirectoryInfo directory, bool clearLibrary = true)
Parameters
Type | Name | Description |
---|---|---|
System.IO.DirectoryInfo | directory | Load all *.ecs files from the directory |
System.Boolean | clearLibrary | If true, clear the library before load. |
LoadStyles(FileInfo, Boolean)
Load a single chart style library file (*.ecs) into memory
Declaration
public static void LoadStyles(FileInfo ecsFile, bool clearLibrary = true)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | ecsFile | The file to load |
System.Boolean | clearLibrary | If true, clear the library before load. |
LoadStyles(Stream, Boolean)
Load a single chart style library stream into memory from the supplied directory
Declaration
public static void LoadStyles(Stream stream, bool clearLibrary = true)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to load |
System.Boolean | clearLibrary | If true, clear the library before load. |
LoadStyleXml(XmlDocument, eChartStyle, XmlDocument)
Loads a chart style xml file, and applies the style.
Declaration
public int LoadStyleXml(XmlDocument styleXml, eChartStyle fallBackStyle, XmlDocument colorsXml = null)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | styleXml | The chart style xml document |
eChartStyle | fallBackStyle | The build in style to fall back on |
System.Xml.XmlDocument | colorsXml | The chart colord xml document |
Returns
Type | Description |
---|---|
System.Int32 | The id of the Style loaded |
LoadStyleXml(XmlDocument, XmlDocument)
Loads a chart style xml file, and applies the style.
Declaration
public int LoadStyleXml(XmlDocument styleXml, XmlDocument colorXml = null)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | styleXml | The chart style xml document |
System.Xml.XmlDocument | colorXml | The chart color xml document |
Returns
Type | Description |
---|---|
System.Int32 | The new Id of the Style loaded |
Remarks
This is the style.xml and colors.xml related to the chart.xml inside a package or chart template, e.g \xl\charts\chart1.xml \xl\charts\style1.xml \xl\charts\colors1.xml
LoadTemplateStyles(FileInfo)
Loads a crtx file and applies it to the chart. Crtx files are exported from a Spreadsheet Application like Excel.
Loading a template will only apply the styles to the chart, not change settings for the chart.
Please use the AddChartFromTemplate
method to add a chart from a template file.
Declaration
public void LoadTemplateStyles(FileInfo crtxFile)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileInfo | crtxFile | A crtx file |
See Also
LoadTemplateStyles(Stream)
Loads a crtx file and applies it to the chart. Crtx files are exported from a Spreadsheet Application like Excel.
Loading a template will only apply the styles to the chart, not change settings for the chart, override themes etc.
Please use the AddChartFromTemplate
method to add a chart from a template file.
Declaration
public void LoadTemplateStyles(Stream crtxStream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | crtxStream | A stream containing a crtx file |
See Also
SetChartStyle(ePresetChartStyle)
Applies a preset chart style loaded into the StyleLibrary to the chart.
Declaration
public void SetChartStyle(ePresetChartStyle style)
Parameters
Type | Name | Description |
---|---|---|
ePresetChartStyle | style | The style to use |
See Also
SetChartStyle(ePresetChartStyle, ePresetChartColors)
Applies a preset chart style loaded into the StyleLibrary to the chart.
This enums matches Excel's styles for single series for common scenarios.
Excel changes chart styles depending on many parameters, like number of series, axis type and more, so it will not always match the number in Excel.
To be certain of getting the correct style use the chart style number of the style you want to apply
Declaration
public void SetChartStyle(ePresetChartStyle style, ePresetChartColors colors)
Parameters
Type | Name | Description |
---|---|---|
ePresetChartStyle | style | The preset style to use |
ePresetChartColors | colors | The preset color scheme to use |
See Also
SetChartStyle(ePresetChartStyleMultiSeries)
Applies a preset chart style loaded into the StyleLibrary to the chart.
Declaration
public void SetChartStyle(ePresetChartStyleMultiSeries style)
Parameters
Type | Name | Description |
---|---|---|
ePresetChartStyleMultiSeries | style | The style to use |
See Also
SetChartStyle(ePresetChartStyleMultiSeries, ePresetChartColors)
Applies a preset chart style loaded into the StyleLibrary to the chart.
This enums matches Excel's styles for multiple series for common scenarios.
Excel changes chart styles depending on many parameters, like number of series, axis type and more, so it will not always match the number in Excel.
To be certain of getting the correct style use the chart style number of the style you want to apply.
Declaration
public void SetChartStyle(ePresetChartStyleMultiSeries style, ePresetChartColors colors)
Parameters
Type | Name | Description |
---|---|---|
ePresetChartStyleMultiSeries | style | The preset style to use |
ePresetChartColors | colors | The preset color scheme to use |
See Also
SetChartStyle(Int32, Nullable<Int32>)
Applies a chart style loaded into the StyleLibrary to the chart.
Declaration
public void SetChartStyle(int style, int? colors = 10)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | style | The chart style id to use |
System.Nullable<System.Int32> | colors | The preset color scheme id to use. Null means |