Search code examples
excelopenxml

OpenXml - How to remove lines between points in a scatterChart


I have plotted a scatterChart in an Excel file using OpenXml. The points are joined by line. How can I remove the line? I tried doing this:

ScatterStyle scatterStyle = new ScatterStyle() { Val = ScatterStyleValues.Marker };
                scatterchart.AppendChild<ScatterStyle>(scatterStyle);

But Excel repairs the file and changes the value back to ScatterStyleValues.LineMarker from ScatterStyleValues.Marker. Please help me. Thankyou


Solution

  • It turns out that you have to add a shape property to your series, and add an outline where fill = nofill. enter code here

    //ChartShapeProperty of series
    ChartShapeProperties SeriesShapeProperty = new DocumentFormat.OpenXml.Drawing.Charts.ChartShapeProperties();
                            DocumentFormat.OpenXml.Drawing.Outline outline = new DocumentFormat.OpenXml.Drawing.Outline(new DocumentFormat.OpenXml.Drawing.NoFill()) { Width = 28575 };
                            SeriesShapeProperty.Append(outline);
                            scatterChartSeries.Append(SeriesShapeProperty);