Etichetta dati personalizzata in ricco testo di un punto del grafico
Contents
[
Hide
]
Puoi usare Aspose.Cells per Python via .NET per creare etichette personalizzate di testo ricco del punto nel grafico. Aspose.Cells per Python via .NET fornisce il metodo DataLabels.characters() per restituire l’oggetto FontSetting che può essere usato per impostare le proprietà del carattere del testo come il colore, lo stile in grassetto ecc.
Etichetta dati personalizzata di testo ricco del punto del grafico
Il codice seguente accede al primo punto del grafico della prima serie, imposta il suo testo e quindi imposta il carattere dei primi 10 caratteri impostando il suo colore su rosso e il grassetto su true.
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") |