Class ExcelChartStyleManager
- Namespace
- OfficeOpenXml.Drawing.Chart.Style
- Assembly
- EPPlus.dll
Manages styles for a chart
public class ExcelChartStyleManager : XmlHelper
- Inheritance
-
ExcelChartStyleManager
- Inherited Members
Fields
ColorsLibrary
A library where chart color styles can be loaded for easier access
public static Dictionary<int, ExcelChartStyleLibraryItem> ColorsLibrary
Field Value
StyleLibrary
A library where chart styles can be loaded for easier access. EPPlus loads most buildin styles into this collection.
public static Dictionary<int, ExcelChartStyleLibraryItem> StyleLibrary
Field Value
Properties
ColorsManager
A reference to color style settings for the chart
public ExcelChartColorsManager ColorsManager { get; }
Property Value
ColorsXml
The color xml document
public XmlDocument ColorsXml { get; }
Property Value
- XmlDocument
Style
A reference to style settings for the chart
public ExcelChartStyle Style { get; }
Property Value
StyleXml
The chart style xml document
public XmlDocument StyleXml { get; }
Property Value
- XmlDocument
ThemeOverride
If the chart has a different theme than the theme in the workbook, this property defines that theme.
public ExcelThemeOverride ThemeOverride { get; }
Property Value
ThemeOverrideXml
Overrides the current theme for the chart.
public XmlDocument ThemeOverrideXml { get; }
Property Value
- XmlDocument
Methods
ApplyStyles()
Apply the chart and color style to the chart. Style ColorsManager
public void ApplyStyles()
ApplyStylesEx()
Apply the chart and color style to the chart. Style ColorsManager
public void ApplyStylesEx()
CreateEmptyStyle(eChartStyle)
Creates an empty style and color for chart, ready to be customized
public void CreateEmptyStyle(eChartStyle fallBackStyle = eChartStyle.Style2)
Parameters
fallBackStyleeChartStyle
LoadColorXml(XmlDocument)
Load a color xml documents
public void LoadColorXml(XmlDocument colorXml)
Parameters
colorXmlXmlDocumentThe color xml
LoadStyleXml(XmlDocument, eChartStyle, XmlDocument)
Loads a chart style xml file, and applies the style.
public int LoadStyleXml(XmlDocument styleXml, eChartStyle fallBackStyle, XmlDocument colorsXml = null)
Parameters
styleXmlXmlDocumentThe chart style xml document
fallBackStyleeChartStyleThe build in style to fall back on
colorsXmlXmlDocumentThe chart colord xml document
Returns
- int
The id of the Style loaded
LoadStyleXml(XmlDocument, XmlDocument)
Loads a chart style xml file, and applies the style.
public int LoadStyleXml(XmlDocument styleXml, XmlDocument colorXml = null)
Parameters
styleXmlXmlDocumentThe chart style xml document
colorXmlXmlDocumentThe chart color xml document
Returns
- int
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
LoadStyles()
Loads the default chart style library from the internal resource library. Loads styles, colors and the default theme.
public static void LoadStyles()
LoadStyles(DirectoryInfo, bool)
Load all chart style library files (*.ecs) into memory from the supplied directory
public static void LoadStyles(DirectoryInfo directory, bool clearLibrary = true)
Parameters
directoryDirectoryInfoLoad all *.ecs files from the directory
clearLibraryboolIf true, clear the library before load.
LoadStyles(FileInfo, bool)
Load a single chart style library file (*.ecs) into memory
public static void LoadStyles(FileInfo ecsFile, bool clearLibrary = true)
Parameters
LoadStyles(Stream, bool)
Load a single chart style library stream into memory from the supplied directory
public static void LoadStyles(Stream stream, bool clearLibrary = true)
Parameters
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.
public void LoadTemplateStyles(FileInfo crtxFile)
Parameters
crtxFileFileInfoA 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.
public void LoadTemplateStyles(Stream crtxStream)
Parameters
crtxStreamStreamA stream containing a crtx file
- See Also
SetChartStyle(ePresetChartStyle)
Applies a preset chart style loaded into the StyleLibrary to the chart.
public void SetChartStyle(ePresetChartStyle style)
Parameters
styleePresetChartStyleThe 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
public void SetChartStyle(ePresetChartStyle style, ePresetChartColors colors)
Parameters
styleePresetChartStyleThe preset style to use
colorsePresetChartColorsThe preset color scheme to use
- See Also
SetChartStyle(ePresetChartStyleMultiSeries)
Applies a preset chart style loaded into the StyleLibrary to the chart.
public void SetChartStyle(ePresetChartStyleMultiSeries style)
Parameters
styleePresetChartStyleMultiSeriesThe 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.
public void SetChartStyle(ePresetChartStyleMultiSeries style, ePresetChartColors colors)
Parameters
styleePresetChartStyleMultiSeriesThe preset style to use
colorsePresetChartColorsThe preset color scheme to use
- See Also
SetChartStyle(int, int?)
Applies a chart style loaded into the StyleLibrary to the chart.
public void SetChartStyle(int style, int? colors = 10)
Parameters
- See Also