图表点的富文本自定义数据标签
Contents
[
Hide
]
您可以使用Aspose.Cells for Python via .NET为图表点创建丰富文本的自定义数据标签。该API提供DataLabels.characters()方法,返回FontSetting对象,可用来设置文本的字体属性,如颜色、粗细等。
数据点的图表富文本自定义数据标签
以下代码访问第一个系列的第一个图表点,设置其文本,然后通过设置字体的颜色为红色并将其粗体设置为true 来设置前10个字符的字体。
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.pydrawing import Color | |
# 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 a workbook from source Excel file | |
workbook = Workbook(dataDir + "sample.xlsx") | |
# Access first worksheet | |
worksheet = workbook.worksheets[0] | |
# Access the first chart inside the sheet | |
chart = worksheet.charts[0] | |
# Access the data label of first series first point | |
dlbls = chart.n_series[0].points[0].data_labels | |
# Set data label text | |
dlbls.text = "Rich Text Label" | |
# Set the font setting of the first 10 characters | |
fntSetting = dlbls.characters(0, 10) | |
fntSetting.font.color = Color.red | |
fntSetting.font.is_bold = True | |
# Save the workbook | |
workbook.save(dataDir + "output_out.xlsx") |