
We will see how to do that in the next section. However, you can further customize this line according to your requirement. Note that the trendline is shown here as a simple dotted line by default. This means that as the value of x increases, the value of y increases too. It can be worked around in the following manner:ġ. Create a new chart in Excel and add a trendline.Ģ. Add the Equation or the R-Square: Select the trendline then right-click the trendline or choose Format>Selected Trendline from the menu.ģ. Now simply open the workbook with ExcelApplication.Open, retrieve the trendline and program it any way you like (Including changing the trendline regression type or value or show/hide the Equation or R-Squared value): Trendline trend = oSeries.Trendlines //now this will work trend.Looking at the above chart, the trendline shows that the two variables have a positive relationship since the trendline shows the movement of the points in the positive direction. This issue persists for the BIFF (XLS) file format. This issue has been resolved for charts in the OOXML file format (XLSX, XLSM) as part of implementing OOXML support for ExcelApplication in OfficeWriter v8.0. From that point on you can programmatically change the label as you like using the properties. However, if you open, with ExcelApplication, an existing workbook which already has a Trendline label these properties will work properly. Setting these properties to true does not seem to have any effect and the label is not shown.

The Trendline object has the properties to ShowEquation and ShowRSquaredValue. Trendlines can also be created as objects in ExcelApplication through the Series of a Chart.

It is possible, in Excel, to add a label to a trendline of a chart that shows the Equation or the R-squared value of the trendline like in the image below:
