إدارة عناوين رسوم بيانية Excel
في رسوم بيانية Excel، هناك نوعان من العناوين:
- عنوان الرسم البياني
- عناوين المحاور
خيارات العنوان
تسمح Aspose.Cells أيضًا بإدارة عناوين الرسوم البيانية في وقت التشغيل، باستخدام عنوان يمكنك تغيير النص والخط وتنسيق الملء للعناوين.
||
ضبط عناوين الرسوم البيانية أو المحاور
يمكنك استخدام مايكروسوفت إكسل لتعيين عناوين الرسم البياني ومحاوره في بيئة WYSIWYG. تسمح Aspose.Cells أيضًا للمطورين بتعيين عناوين الرسم البياني ومحاوره في وقت التشغيل. جميع الرسوم البيانية ومحاورها يحتوي على عنوان يمكن استخدامه لتعيين عناوينهم كما هو موضح أدناه في مثال.
يوضح مقتطف الكود التالي كيفية ضبط عناوين الرسوم البيانية والمحاور.
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Workbook object | |
int sheetIndex = workbook.getWorksheets().add(); | |
// Obtaining the reference of the newly added worksheet by passing its sheet index | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
// Adding sample values to cells | |
worksheet.getCells().get("A1").putValue("Series1"); | |
worksheet.getCells().get("A2").putValue(50); | |
worksheet.getCells().get("A3").putValue(100); | |
worksheet.getCells().get("A4").putValue(150); | |
worksheet.getCells().get("B1").putValue("Series2"); | |
worksheet.getCells().get("B2").putValue(60); | |
worksheet.getCells().get("B3").putValue(32); | |
worksheet.getCells().get("B4").putValue(50); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 15, 5); | |
// Accessing the instance of the newly added chart | |
Chart chart = worksheet.getCharts().get(chartIndex); | |
// Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart.getNSeries().add("A1:B3", true); | |
// Setting the title of a chart | |
chart.getTitle().setText("Title"); | |
// Setting the font color of the chart title to blue | |
chart.getTitle().getFont().setColor( Color.getBlue()); | |
// Setting the title of category axis of the chart | |
chart.getCategoryAxis().getTitle().setText ("Category"); | |
// Setting the title of value axis of the chart | |
chart.getValueAxis().getTitle().setText ( "Value"); | |
// Save the file | |
workbook.save("chart_datalabels.xlsx"); |