Come cambiare il colore del carattere del commento
Contents
[
Hide
]
Microsoft Excel consente agli utenti di aggiungere commenti alle celle per aggiungere informazioni aggiuntive e evidenziare dati. Gli sviluppatori potrebbero aver bisogno di personalizzare il commento per specificare impostazioni di allineamento, direzione del testo, colore del carattere, ecc. Aspose.Cells per Python via .NET fornisce API per eseguire questo compito.
Aspose.Cells per Python via .NET fornisce una proprietà Shape.text_body per il colore del carattere del commento. Il seguente esempio di codice dimostra l’uso della proprietà Shape.text_body per impostare la direzione del testo di un commento.
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 StyleFlag, TextAlignmentType, Workbook | |
from aspose.pydrawing import Color | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Output directory | |
outputDir = "" | |
# Instantiate a new Workbook | |
workbook = Workbook() | |
# Get the first worksheet | |
worksheet = workbook.worksheets[0] | |
# Add some text in cell A1 | |
worksheet.cells.get("A1").put_value("Here") | |
# Add a comment to A1 cell | |
commentIndex = worksheet.comments.add("A1") | |
comment = worksheet.comments[commentIndex] | |
# Set its vertical alignment setting | |
comment.comment_shape.text_vertical_alignment = TextAlignmentType.CENTER | |
# Set the Comment note | |
comment.note = "This is my Comment Text. This is Test." | |
shape = worksheet.comments.get(0, 0).comment_shape | |
# worksheet.Comments["A1"].CommentShape; | |
shape.fill.solid_fill.color = Color.black | |
font = shape.font | |
font.color = Color.white | |
styleFlag = StyleFlag() | |
styleFlag.font_color = True | |
shape.text_body.format(0, len(shape.text), font, styleFlag) | |
# Save the Excel file | |
workbook.save(outputDir + "outputChangeCommentFontColor.xlsx") |
Il file di output (102662195.xlsx) generato dal codice sopra è allegato per il tuo riferimento.