Class ExcelChartStyleManager¶
Namespace: OfficeOpenXml.Drawing.Chart.Style
Assembly: EPPlus.dll
Manages styles for a chart
Inheritance¶
object ← XmlHelper ← ExcelChartStyleManager
Inherited Members¶
object.Equals(object?, object?)
object.Equals(object?)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object?, object?)
object.ToString()
Fields¶
ColorsLibrary¶
A library where chart color styles can be loaded for easier access
Field Value¶
Dictionary<int, ExcelChartStyleLibraryItem>
StyleLibrary¶
A library where chart styles can be loaded for easier access. EPPlus loads most buildin styles into this collection.
Field Value¶
Dictionary<int, ExcelChartStyleLibraryItem>
Properties¶
ColorsManager¶
A reference to color style settings for the chart
Property Value¶
ColorsXml¶
The color xml document
Property Value¶
XmlDocument
Style¶
A reference to style settings for the chart
Property Value¶
StyleXml¶
The chart style xml document
Property Value¶
XmlDocument
ThemeOverride¶
If the chart has a different theme than the theme in the workbook, this property defines that theme.
Property Value¶
ThemeOverrideXml¶
Overrides the current theme for the chart.
Property Value¶
XmlDocument
Methods¶
ApplyStyles()¶
Apply the chart and color style to the chart. Style ColorsManager
ApplyStylesEx()¶
Apply the chart and color style to the chart. Style ColorsManager
CreateEmptyStyle(eChartStyle)¶
Creates an empty style and color for chart, ready to be customized
Parameters¶
fallBackStyle eChartStyle
LoadColorXml(XmlDocument)¶
Load a color xml documents
Parameters¶
colorXml XmlDocument
The color xml
LoadStyleXml(XmlDocument, XmlDocument)¶
Loads a chart style xml file, and applies the style.
Parameters¶
styleXml XmlDocument
The chart style xml document
colorXml XmlDocument
The chart color xml document
Returns¶
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
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¶
styleXml XmlDocument
The chart style xml document
fallBackStyle eChartStyle
The build in style to fall back on
colorsXml XmlDocument
The chart colord xml document
Returns¶
The id of the Style loaded
LoadStyles()¶
Loads the default chart style library from the internal resource library. Loads styles, colors and the default theme.
LoadStyles(DirectoryInfo, bool)¶
Load all chart style library files (*.ecs) into memory from the supplied directory
Parameters¶
directory DirectoryInfo
Load all *.ecs files from the directory
clearLibrary bool
If true, clear the library before load.
LoadStyles(FileInfo, bool)¶
Load a single chart style library file (*.ecs) into memory
Parameters¶
ecsFile FileInfo
The file to load
clearLibrary bool
If true, clear the library before load.
LoadStyles(Stream, bool)¶
Load a single chart style library stream into memory from the supplied directory
Parameters¶
stream Stream
The stream to load
clearLibrary bool
If true, clear the library before load.
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.
Parameters¶
crtxFile FileInfo
A crtx file
See Also¶
ExcelDrawings.AddChartFromTemplate\([FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo), [string](https://learn.microsoft.com/dotnet/api/system.string)\)
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.
Parameters¶
crtxStream Stream
A stream containing a crtx file
See Also¶
ExcelDrawings.AddChartFromTemplate\([Stream](https://learn.microsoft.com/dotnet/api/system.io.stream), [string](https://learn.microsoft.com/dotnet/api/system.string)\)
SetChartStyle(ePresetChartStyle)¶
Applies a preset chart style loaded into the StyleLibrary to the chart.
Parameters¶
style ePresetChartStyle
The style to use
See Also¶
ExcelChartStyleManager.SetChartStyle\([int](https://learn.microsoft.com/dotnet/api/system.int32), [int](https://learn.microsoft.com/dotnet/api/system.int32)?\)
SetChartStyle(ePresetChartStyleMultiSeries)¶
Applies a preset chart style loaded into the StyleLibrary to the chart.
Parameters¶
style ePresetChartStyleMultiSeries
The style to use
See Also¶
ExcelChartStyleManager.SetChartStyle\([int](https://learn.microsoft.com/dotnet/api/system.int32), [int](https://learn.microsoft.com/dotnet/api/system.int32)?\)
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
Parameters¶
style ePresetChartStyle
The preset style to use
colors ePresetChartColors
The preset color scheme to use
See Also¶
ExcelChartStyleManager.SetChartStyle\([int](https://learn.microsoft.com/dotnet/api/system.int32), [int](https://learn.microsoft.com/dotnet/api/system.int32)?\)
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.
Parameters¶
style ePresetChartStyleMultiSeries
The preset style to use
colors ePresetChartColors
The preset color scheme to use
See Also¶
ExcelChartStyleManager.SetChartStyle\([int](https://learn.microsoft.com/dotnet/api/system.int32), [int](https://learn.microsoft.com/dotnet/api/system.int32)?\)
SetChartStyle(int, int?)¶
Applies a chart style loaded into the StyleLibrary to the chart.
Parameters¶
style int
The chart style id to use
colors int?
The preset color scheme id to use. Null means
See Also¶
ExcelChartStyleManager.SetChartStyle\([ePresetChartStyle](OfficeOpenXml.Drawing.Chart.Style.ePresetChartStyle.md)\)