チャートのトレンドラインの方程式テキストを取得する

以下のスクリーンショットは、トレンドライン付きのチャートとその方程式テキストが赤色で表示されています。以下のサンプルコードでは、Trendline.DataLabels.Textプロパティを使用してこのテキストを取得します。

todo:image_alt_text

チャートのトレンドラインの方程式テキストを取得するC#コード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object from source Excel file
Workbook workbook = new Workbook(dataDir + "source.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Access the first chart inside the worksheet
Chart chart = worksheet.Charts[0];
// Calculate the Chart first to get the Equation Text of Trendline
chart.Calculate();
// Access the Trendline
Trendline trendLine = chart.NSeries[0].TrendLines[0];
// Read the Equation Text of Trendline
Console.WriteLine("Equation Text: " + trendLine.DataLabels.Text);

サンプルコードによって生成された出力

これは上記のサンプルコードのコンソール出力です。

Equation Text: y = 8.1333x + 5