Skip to content

Styling Charts

Jan Källman edited this page Jan 29, 2020 · 9 revisions

Charts

EPPlus 5 supports over 100 new chart styles introduced in Excel 2016. These styles can be easily set by the new StyleManager either using the ePresetChartStyle enum or the Excel ChartStyle number.

//Add a column chart
var chart = ws.Drawings.AddBarChart("column3dChart", eBarChartType.ColumnClustered3D);
var serie = chart.Series.Add(ws.Cells[2, 7, 26, 7], ws.Cells[2, 6, 26, 6]);
serie.Header = "Order Value";
chart.SetPosition(0, 0, 8, 0);
chart.SetSize(1000, 300);
chart.Title.Text = "Column Chart 3D";
//Set style 9 and Colorful Palette 3
chart.StyleManager.SetChartStyle(ePresetChartStyle.Bar3dChartStyle9, ePresetChartColors.ColorfulPalette3);

EPPlus 5 also support chart templates (with the crtx extension) via the AddChartFromTemplate method. Crtx files can be exported from Excel from any chart.

//Add an Area chart from a template file.
var areaChart = (ExcelAreaChart)ws.Drawings.AddChartFromTemplate(FileInputUtil.GetFileInfo("15-ChartsAndThemes", "AreaChartStyle3.crtx"), "areaChart");

var areaSerie = areaChart.Series.Add(ws.Cells[2, 7, 26, 7], ws.Cells[2, 6, 26, 6]);
areaSerie.Header = "Order Value";
areaChart.SetPosition(51, 0, 10, 0);
areaChart.SetSize(1000, 300);
areaChart.Title.Text = "Area Chart";

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally