Very Specific: Need to delete certain indexes of a Excel Chart legend

Aug 11, 2014 at 9:37 PM
Edited Aug 11, 2014 at 9:39 PM
My goal is to have 3 series with the same color on a graph, and only represented by one legend item. When creating a chart with EPPlus, the legend makes an item for each series, obviously.
I've done some editing and recompiling to the EPPplus DLL, but I'm not an expert.
First, I made two excel files. The only difference between the two was that i deleted a legend item. I found that in the chart XML file, it added:


<c:idx val="0"/>

<c:delete val="1"/>


To the Legend XML area/node thing. I was able to replicate this exactly with a method inside EPPlus:

TopNode = _chart.ChartXml.SelectSingleNode("c:chartSpace/c:chart/c:legend", NameSpaceManager);
        string firstpart = "<c:legendPos val=\"r\"/>" ;
        string addedString = "<c:legendEntry><c:idx val = \"1\"/><c:delete val = \"1\"/></c:legendEntry>";
        string lastPart = "<c:layout/>" + "<c:overlay val=\"0\"/>";

        TopNode.InnerXml = string.Format(firstpart + addedString + lastPart, 0, 0);
Upon inspection, the resulting XML indicates that the legend at the specified index is deleted (it looks identical to the legend item code specified above), but the Excel file shows otherwise. No legend item is deleted. I know the method is shitty, I'm just trying to get it to work once.

Any other strategies I should try to figure out a method that can delete a legend item?