This project has moved and is read-only. For the latest updates, please go here.

Changing trendline properties

Nov 12, 2012 at 8:01 AM

Initially I have ExcelLineChart and added trendline to it. After that I want to remove all captions from trendline:

ExcelLineChart ec = (ExcelLineChart)wsGraph.Drawings.AddChart(graphic.graphicName, eChartType.Line);
    ec.Series[ec.Series.Count - 1].TrendLines.Add(eTrendLine.Linear);
    ec.Series[ec.Series.Count - 1].TrendLines.ElementAt(0).DisplayEquation = false;
    ec.Series[ec.Series.Count - 1].TrendLines.ElementAt(0).DisplayRSquaredValue = false;

And got error "Collection have no elements". It's strange, because then I open file - trendline exists in chart.

So, how can I access properties of existing trendline?