Change Text Direction of the Comment
Contents
[
Hide
]
Microsoft Excel allows users to add comments to cells to add additional information and highlight data. Developers may need to customize the comment to specify alignment settings and text direction. Aspose.Cells for Python via .NET provides APIs to accomplish the task.
Aspose.Cells for Python via .NET provides a Shape.text_direction property to set text direction for a comment. The following sample code demonstrates the use of Shape.text_direction property to set text direction for a comment.
This file contains 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 TextAlignmentType, TextDirectionType, Workbook | |
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) | |
# Instantiate a new Workbook | |
wb = Workbook() | |
# Get the first worksheet | |
sheet = wb.worksheets[0] | |
# Add a comment to A1 cell | |
comment = sheet.comments[sheet.comments.add("A1")] | |
# Set its vertical alignment setting | |
comment.comment_shape.text_vertical_alignment = TextAlignmentType.CENTER | |
# Set its horizontal alignment setting | |
comment.comment_shape.text_horizontal_alignment = TextAlignmentType.RIGHT | |
# Set the Text Direction - Right-to-Left | |
comment.comment_shape.text_direction = TextDirectionType.RIGHT_TO_LEFT | |
# Set the Comment note | |
comment.note = "This is my Comment Text. This is test" | |
dataDir = dataDir + "OutCommentShape.out.xlsx" | |
# Save the Excel file | |
wb.save(dataDir) |