Search code examples
c#wpfepplusepplus-4

EPPLUS: Set marker fill color in LineMarkers


I tried setting all related properties ExcelLineChartSerie has to offer, but still cannot set or change the color of the Excel marker from default ugly blue.

ExcelChart ec = ws.Drawings.AddChart("LineChart01", eChartType.LineMarkers);

var rangeX = ws.Cells["A2:A11"]; // X-Axis
var range1 = ws.Cells["B2:B11"]; // 1st LineSerie

ExcelLineChartSerie serie1 = (ExcelLineChartSerie)ec.Series.Add(range1, rangeX);

serie1.MarkerLineColor = System.Drawing.Color.Gray;
serie1.MarkerSize = 10;
serie1.Fill.Color = System.Drawing.Color.Gray;
serie1.LineColor = System.Drawing.Color.Gray;
serie1.Border.LineStyle = eLineStyle.Solid;

enter image description here


Solution

  • From looking at the current source code, it looks like this functionality is not implemented in EPPlus yet.

    This discussion points to a SO post which shows how to implement an extension method to add functionality to change line thickness and color. It should be possible to adapt this code to change the marker fill color. The property paths you will need for this are at the end of the discussion on codeplex (second link above).