Table of Contents

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

Dictionary<int, ExcelChartStyleLibraryItem>

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

Dictionary<int, ExcelChartStyleLibraryItem>

Properties

ColorsManager

A reference to color style settings for the chart

public ExcelChartColorsManager ColorsManager { get; }

Property Value

ExcelChartColorsManager

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

ExcelChartStyle

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

ExcelThemeOverride

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

fallBackStyle eChartStyle

LoadColorXml(XmlDocument)

Load a color xml documents

public void LoadColorXml(XmlDocument colorXml)

Parameters

colorXml XmlDocument

The 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

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

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

styleXml XmlDocument

The chart style xml document

colorXml XmlDocument

The 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

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

public static void LoadStyles(FileInfo ecsFile, bool clearLibrary = true)

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

public static void LoadStyles(Stream stream, bool clearLibrary = true)

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.

public void LoadTemplateStyles(FileInfo crtxFile)

Parameters

crtxFile FileInfo

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.

public void LoadTemplateStyles(Stream crtxStream)

Parameters

crtxStream Stream

A 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

style ePresetChartStyle

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

public void SetChartStyle(ePresetChartStyle style, ePresetChartColors colors)

Parameters

style ePresetChartStyle

The preset style to use

colors ePresetChartColors

The 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

style ePresetChartStyleMultiSeries

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.

public void SetChartStyle(ePresetChartStyleMultiSeries style, ePresetChartColors colors)

Parameters

style ePresetChartStyleMultiSeries

The preset style to use

colors ePresetChartColors

The 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

style int

The chart style id to use

colors int?

The preset color scheme id to use. Null means

See Also