I'm trying to create an automated report using EPPlus and running into an odd issue. It seems that any time I try to create a chart, everything works except the axis labels are missing. I've had no luck getting them back either through EPPlus or directly in Excel. I can't find anyone else with this problem and I'm wondering if I'm doing something wrong or if something else is going on.
Here's the chart code:
var ws = package.Workbook.Worksheets.Add("Test");
ws.Cells["A1"].Value = "1";
ws.Cells["A2"].Value = "2";
ws.Cells["A3"].Value = "3";
ws.Cells["A4"].Value = "4";
ws.Cells["B1"].Value = 10;
ws.Cells["B2"].Value = 20;
ws.Cells["B3"].Value = 30;
ws.Cells["B4"].Value = 40;
//Create the chart
var chart = ws.Drawings.AddBarChart("Test", eBarChartType.ColumnStacked);
chart.Title.Text = "Clustered Bar Graph Report";
var series = chart.Series.Add(ExcelRange.GetAddress(1, 2, 4, 2), ExcelRange.GetAddress(1, 1, 4, 1));
series.Header = "test";
And here's what I'm getting in Excel:
The axis labels are there, they're just blank. I've tried changing the text, I've tried deleting and re-adding, I've tried reselecting the data, I've tried changing the font, I've tried changing the chart type. No matter what I do they stay blank. I've even tried creating a new console app with just this code in it and I get the same result.
I have found that you need to apply a style to a chart to get some of the axes and gridlines to draw. Try adding the following line right after "var chart = ...."
chart.StyleManager.SetChartStyle(ePresetChartStyle.StackedColumnChartStyle1, ePresetChartColors.ColorfulPalette1);
In EPPlus v5.1.0 adding this line makes the axes magically appear. Without it, I get no axes. I consider this unexpected behavior, and therefore a bug. The same applies to many other chart types (e.g. XYScatterLines).