الحصول على نص المعادلة لخط اتجاه الرسم البياني
Contents
[
Hide
]
يمكنك استرجاع نص المعادلة لخط اتجاه الرسم البياني باستخدام Aspose.Cells. توفر Aspose.Cells الواجهة البرمجية للتطبيقات Trendline.DataLabels.Text التي تُرجع نص المعادلة لخط اتجاه الرسم البياني. لاستخدام هذه الواجهة البرمجية، سيلزمك أولاً استدعاء الطريقة Chart.Calculate().
تظهر اللقطة المتصورة التالية الرسم البياني مع خط اتجاه ونص المعادلة له باللون الأحمر. سوف نسترجع هذا النص باستخدام الواجهة البرمجية Trendline.DataLabels.Text في رمز العينة التالي.
رمز C# للحصول على نص معادلة خط اتجاه الرسم البياني
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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