Come cambiare il colore del carattere del commento

Contents
[ ]

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.

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.