Changer la direction du texte du commentaire
Contents
[
Hide
]
Microsoft Les utilisateurs d’Excel peuvent ajouter des commentaires aux cellules des feuilles de calcul pour ajouter des informations supplémentaires aux cellules et mettre en évidence les données. Les développeurs peuvent avoir besoin de personnaliser le commentaire pour spécifier les paramètres d’alignement et la direction du texte. Aspose.Cells fournit des API pour accomplir la tâche.
Aspose.Cells fournit unShape.setTextDirection()méthode pour définir la direction de texte souhaitée pour un commentaire.
L’image suivante montre le commentaire avec ses paramètres de format dans Microsoft Excel. Le fichier de sortie est obtenu après avoir exécuté le segment de code ci-dessous.
Commentaire avec sens du texte de droite à gauche
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"); |