更改评论的文本方向
Contents
[
Hide
]
Microsoft Excel 用户可以向电子表格中的单元格添加注释,以向单元格添加附加信息并突出显示数据。开发人员可能需要自定义注释以指定对齐设置和文本方向。 Aspose.Cells 提供 API 来完成任务。
Aspose.Cells提供了形状.setTextDirection()方法为评论设置所需的文本方向。
下图显示了注释及其在 Microsoft Excel 中的格式设置。运行以下代码段后获得输出文件。
使用从右到左的文本方向进行评论
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
// 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"); | |