Skip to content

This content is for v4.x (Alpha). Switch to the Stable version.

The Chart class, a versatile component within the OpenXMLOffice.Spreadsheet library, empowers developers to seamlessly integrate various types of charts into Excel spreadsheet. This class supports multiple chart types and configurations, allowing users to add new charts to a sheet with dynamic and data-driven visualizations.

List of supported charts

For each chart family ChartSetting<ExcelSetting> have its relevant options and settings for customization.

public void ChartSample(Excel excel)
{
// Default Chart Type
Excel excel1 = new("./TestFiles/basic_test.xlsx", true);
Worksheet worksheet = excel1.AddSheet("AreaChart");
worksheet.AddChart(new()
{
cellIdStart = "A1",
cellIdEnd = "D4"
}, new AreaChartSetting<ExcelSetting>()
{
applicationSpecificSetting = new()
{
from = new()
{
row = 5,
column = 5
},
to = new()
{
row = 20,
column = 20
}
}
});
}

This section outlines the options available when configuring charts with ChartSetting using ExcelSetting parameters.

PropertyTypeDetails
isSecondaryAxisboolIf combo chart this can be used to indicate secondary axis activation.
chartDataSettingChartDataSettingThis setting enables users to customize both the input chart data range and value from cell labels with precision.
chartGridLinesOptionsChartGridLinesOptionsThis feature offers crisp options for users to finely customize the gridline settings of the chart.
chartLegendOptionsChartLegendOptionsThis feature offers crisp options for users to finely customize the gridline settings of the chart.
applicationSpecificSetting<ApplicationSpecificSetting>This is generic class setting. For Spreadsheet it is ExcelSetting
PropertyTypeDetails
fromAnchorPositionPlacement details for from starting point
toAnchorPositionPlacement details for to Ending point
PropertyTypeDetails
columnuintDefault:1
columnOffsetuintDefault:0
rowuintDefault:1
rowOffsetuintDefault:0
PropertyTypeDetails
chartDataColumnEnduintSpecify the number of columns for chart series; set to 0 for utilizing all columns.
Default: 0
chartDataColumnStartuintSpecify the starting column for chart data.
Default: 0
chartDataRowEnduintSpecify the number of rows for chart series; set to 0 for utilizing all rows.
Default: 0
chartDataRowStartuintSpecify the starting row for chart data.
Default: 0
advancedDataLabelAdvancedDataLabelUsed for Data Label Option From Office 2013
PropertyTypeDetails
isMajorCategoryLinesEnabledboolToggle visibility of major category lines with clarity.
isMajorValueLinesEnabledboolToggle visibility of major value lines with clarity.
isMinorCategoryLinesEnabledboolToggle visibility of minor category lines with clarity.
isMinorValueLinesEnabledboolToggle visibility of minor value lines with clarity.
PropertyTypeDetails
isEnableLegendboolToggle visibility of legend with clarity.
isLegendChartOverLapboolActivate the option for a sleek and tidy display by allowing the legends to overlap.
isBoldboolProvide the option to set text in a bold format with clarity.
isItalicboolProvide the option to set text in a italic format with clarity.
fontSizefloatProvide the option to set font size with clarity.
fontColorstring?Optional font color using hex code (without #).
Default : Theme Text 1.
underLineValuesUnderLineValuesText underline options. Default: None
strikeValuesStrikeValuesText strike options
legendPositionLegendPositionValuesLegend position in chart. Default: Bottom

This is base data label class extended by each chart type to give more specific/relevant options

PropertyTypeDetails
separatorstringData lable text separator used if multiple label enabled
showCategoryNameboolShow category name in label
showLegendKeyboolShow legend key in label
showSeriesNameboolShow series name in label
showValueboolShow value in label
isBoldboolSet label bold
isItalicboolSet label italic
fontSizefloatSet label font size
fontColorstring?Set label font color
underLineValuesUnderLineValuesSet label underline type
strikeValuesStrikeValuesSet label strike type
PropertyTypeDetails
showValueFromColumnboolShow Advanced data label
valueFromColumnDictionary<uint, uint>This option allows configuring a key map where series corresponds to the key, and the value is mapped to a target column based on cell column configuration.

This properties give control over the X and Y axes. (Relate placement based on your chart option)

PropertyTypeDetails
invertVerticalAxesOrderstring?
invertHorizontalAxesOrderstring?
isHorizontalAxesEnabledbool
isHorizontalBoldbool
isHorizontalItalicbool
horizontalFontSizefloat
horizontalFontColorstring?
horizontalUnderLineValuesUnderLineValues
horizontalStrikeValuesStrikeValues
isVerticalBoldbool
isVerticalItalicbool
verticalFontSizefloat
verticalFontColorstring?
verticalUnderLineValuesUnderLineValues
verticalStrikeValuesStrikeValues
isVerticalAxesEnabledbool
PropertyTypeDetails
borderColorstring?Explicit border color for current data series
PropertyTypeDetails
fillColorstring?Explicit fill color for one specific data point in a series
borderColorstring?Explicit border color for one specific data point in a series