Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
The following screenshot shows a chart with a trendline, and its equation text is displayed in red. We will retrieve this text using the Trendline.GetText() property in the following sample code.

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Charts;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Create workbook object from source Excel file
Workbook workbook(srcDir + u"source.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Access the first chart inside the worksheet
Chart chart = worksheet.GetCharts().Get(0);
// Calculate the chart first to get the equation text of the trendline
chart.Calculate();
// Access the trendline
Trendline trendLine = chart.GetNSeries().Get(0).GetTrendLines().Get(0);
// Read the equation text of the trendline
std::cout << "Equation Text: " << trendLine.GetDataLabels().GetText().ToUtf8() << std::endl;
Aspose::Cells::Cleanup();
}
This is the console output of the above sample code.
Equation Text: y = 8.1333x + 5
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.