更改评论的文本方向

Contents
[ ]

Aspose.Cells提供了一个Shape.setTextDirection()方法来设置评论的期望文本方向。

下面的图片显示了Microsoft Excel中评论的格式设置。在运行以下代码段后,可获得输出文件。

具有从右到左文本方向的评论

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = "";
// Instantiate a new Workbook
Workbook wb = new Workbook();
// Get the first worksheet
Worksheet sheet = wb.getWorksheets().get(0);
// Add a comment to A1 cell
Comment comment = sheet.getComments().get(sheet.getComments().add("A1"));
// Set its vertical alignment setting
comment.getCommentShape().setTextVerticalAlignment(TextAlignmentType.CENTER);
// Set its horizontal alignment setting
comment.getCommentShape().setTextHorizontalAlignment(TextAlignmentType.RIGHT);
// Set the Text Direction - Right-to-Left
comment.getCommentShape().setTextDirection(TextDirectionType.RIGHT_TO_LEFT);
// Set the Comment note
comment.setNote("This is my Comment Text. This is test");
// Save the Excel file
wb.save(dataDir + "outCommentShape1.xlsx");