コメントのテキスト方向を変更する
Contents
[
Hide
]
Microsoft Excel ユーザーは、スプレッドシートのセルにコメントを追加して、セルに追加情報を追加し、データを強調表示できます。開発者は、配置設定とテキストの方向を指定するために、コメントをカスタマイズする必要がある場合があります。 Aspose.Cells は、タスクを実行するための API を提供します。
Aspose.Cells はShape.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"); | |