قراءة تسميات المحور بعد حساب الرسم البياني

سيناريوهات الاستخدام المحتملة

يمكنك قراءة تسميات المحاور لرسم بياني بعد حساب قيمه باستخدام الطريقة Chart.Calculate(). يرجى استخدام الطريقة Axis.GetAxisTexts() لهذا الغرض التي ستُرجع قائمة تسميات المحاور.

قراءة تسميات المحور بعد حساب الرسم البياني

يرجى الاطلاع على رمز العينة التالي الذي يحمل ملف Excel عيني ويقرأ تسميات المحور الفئوي للرسم البياني في الورقة العمل الأولى. ثم يقوم بطباعة قيم تسميات المحور على وحدة التحكم. يرجى الاطلاع على الإخراج على وحدة التحكم من رمز العينة الذي يلي للرجوع إليه.

الكود المثالي

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load the Excel file containing chart
Workbook wb = new Workbook("ReadAxisLabels.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access the chart
Chart ch = ws.Charts[0];
//Calculate the chart
ch.Calculate();
//Read axis labels of category axis
string[] lstLabels = ch.CategoryAxis.GetAxisTexts();
//Print axis labels on console
System.Console.WriteLine("Category Axis Labels: ");
System.Console.WriteLine("---------------------");
//Iterate axis labels and print them one by one
for (int i = 0; i < lstLabels.Length; i++)
{
System.Console.WriteLine(lstLabels[i]);
}

مخرجات الوحدة

 Category Axis Labels:

\---------------------

Iran

China

USA

Brazil

England