Excelチャートのタイトルを管理する

タイトルオプション

Aspose.Cells for Python via .NETは、実行時にチャートのタイトルを管理することも可能です。Titleオブジェクトを使用して、タイトルのテキスト、フォント、塗りつぶしフォーマットを変更できます。

|todo:image_alt_text|

チャートや軸のタイトルの設定

Microsoft Excelを使用して、WYSIWYG環境でチャートと軸のタイトル設定が可能です。Aspose.Cells for Python via .NETは、開発者が実行時にチャートや軸のタイトルを設定することも可能です。すべてのチャートと軸にはtitleプロパティがあり、タイトルの設定に使用できます。例は以下の通りです。

次のコードスニペットは、チャートや軸にタイトルを設定する方法を示しています。

from aspose.cells import Workbook
from aspose.cells.charts import ChartType
from aspose.cells.drawing import GradientStyleType
from aspose.pydrawing import Color
from os import os, path
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create directory if it is not already present.
IsExists = path.isdir(dataDir)
if notIsExists:
os.makedirs(dataDir)
# 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 foreground color of the plot area
chart.plot_area.area.foreground_color = Color.blue
# Setting the foreground color of the chart area
chart.chart_area.area.foreground_color = Color.yellow
# Setting the foreground color of the 1st SeriesCollection area
chart.n_series[0].area.foreground_color = Color.red
# Setting the foreground color of the area of the 1st SeriesCollection point
chart.n_series[0].points[0].area.foreground_color = Color.cyan
# Filling the area of the 2nd SeriesCollection with a gradient
chart.n_series[1].area.fill_format.set_one_color_gradient(Color.lime, 1, GradientStyleType.HORIZONTAL, 1)
# 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
# Setting the title of category axis of the chart
chart.category_axis.title.text = "Category"
# Setting the title of value axis of the chart
chart.value_axis.title.text = "Value"
# Saving the Excel file
workbook.save(dataDir + "book1.out.xls")

高度なトピック