إدارة وسيلة جداول رسوم بيانية إكسل
Contents
[
Hide
]
خيارات الأسطورة
كما يتيح Aspose.Cells للبايثون via .NET إدارة أسطورة المخطط أثناء التشغيل، مع كائن Legend، يمكن نقل الأسطورة وتحديثها وتنسيقها.
||
ضبط أسطورة الرسم البياني
من السهل إدارة أسطورة الرسم البياني باستخدام Aspose.Cells للبايثون via .NET Legend.
توضح مقتطفات الكود التالية كيفية إدارة الأسطورة:
This file contains hidden or 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
from aspose.cells import Workbook | |
from aspose.cells.charts import ChartType, LegendPositionType | |
from aspose.pydrawing import Color | |
# Instantiating a Workbook object | |
workbook = Workbook() | |
# Adding a new worksheet to the Workbook object | |
sheetIndex = workbook.worksheets.add() | |
# Obtaining the reference of the newly added worksheet by passing its sheet index | |
worksheet = workbook.worksheets[sheetIndex] | |
# Adding sample values to cells | |
worksheet.cells.get("A1").put_value(50) | |
worksheet.cells.get("A2").put_value(100) | |
worksheet.cells.get("A3").put_value(150) | |
worksheet.cells.get("B1").put_value(60) | |
worksheet.cells.get("B2").put_value(32) | |
worksheet.cells.get("B3").put_value(50) | |
# Adding a chart to the worksheet | |
chartIndex = worksheet.charts.add(ChartType.COLUMN, 5, 0, 15, 5) | |
# Accessing the instance of the newly added chart | |
chart = worksheet.charts[chartIndex] | |
# Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart.n_series.add("A1:B3", True) | |
# Setting the title of a chart | |
chart.title.text = "Title" | |
# Setting the font color of the chart title to blue | |
chart.title.font.color = Color.blue | |
# Move the legend to left | |
chart.legend.position = LegendPositionType.LEFT | |
# Set font color of the legend | |
chart.legend.font.color = Color.blue | |
# Save the file | |
workbook.save("chart_legend.xlsx") |