Change Text Direction of the Comment

Contents
[ ]

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.

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)