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

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

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

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

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

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

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Load the Excel file containing chart
Workbook wb = new Workbook("64716829.xlsx");
//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);
//Access the chart
Chart ch = ws.getCharts().get(0);
//Calculate the chart
ch.calculate();
//Read axis labels of category axis
String[] lstLabels = ch.getCategoryAxis().getAxisTexts();
//Print axis labels on console
System.out.println("Category Axis Labels: ");
System.out.println("---------------------");
//Iterate axis labels and print them one by one
for(int i=0; i<lstLabels.length; i++)
{
System.out.println(lstLabels[i]);
}

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

 Category Axis Labels:

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

Iran

China

USA

Brazil

England