Home     Products      Support      Corporate     Sign In 

Support Knowledge Base, Article 1267

Product
ExcelWriter
Version
6.x
Title
Trendline Label doesn't show Equation/R-squared value
Problem

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:



Trendlines (see documentation) can also be created as objects in ExcelApplication through the Series of a Chart.
The Trendline object has the following Properties:

bool ShowEquation
bool ShowRSquare

Setting these properties to true does not seem to have any effect and the label is not shown.
However, if you open, with ExcelApplication, an existing workbook which already has a Trendline label these properties will work properly. From that point on you can programmatically change the label as you like using the properties.
Solution
This problem will be fixed in a future version of ExcelWriter

For now it can be worked around in the following manner:

  • Create a new Excel WorkSheet with a Chart and 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).

    [C#]
    Trendline trend = oSeries.Trendlines[0];
    //now this will work
    trend.ShowEquation = true;
    [VB.NET]
    Dim trend As Trendline
    trend = oSeries.Trendlines[0]
    'now this will work
    trend.ShowEquation = true

Created : 1/7/2008 2:31:45 PM (last modified : 1/7/2008 2:31:45 PM)

Rate this article!

 
Comments



Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.

Site Map     |     Privacy Policy     |     Contact Us