Modifier l'espacement des caractères d'Excel TextBox ou Shape
Contents
[
Hide
]
Vous pouvez modifier l’espacement des caractères de la zone de texte ou de la forme Excel à l’aide de laFontSetting.TextOptions.Spacing la propriété.
Modifier l’espacement des caractères d’Excel TextBox ou Shape
L’exemple de code suivant modifie l’espacement des caractères de la zone de texte dans un fichier Excel au point 4, puis l’enregistre sur le disque.
La capture d’écran suivante montre comment leexemple de fichier excel regarde avant l’exécution du code.
La capture d’écran suivante montre comment lefichier excel de sortie veille à l’exécution du code.
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 | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(ChangeCharacterSpacing.class) + "articles/"; | |
// Load your excel file inside a workbook obect | |
Workbook wb = new Workbook(dataDir + "character-spacing.xlsx"); | |
// Access your text box which is also a shape object from shapes collection | |
Shape shape = wb.getWorksheets().get(0).getShapes().get(0); | |
// Access the first font setting object via GetCharacters() method | |
ArrayList<FontSetting> lst = shape.getCharacters(); | |
FontSetting fs = lst.get(0); | |
// Set the character spacing to point 4 | |
fs.getTextOptions().setSpacing(4); | |
// Save the workbook in xlsx format | |
wb.save(dataDir + "CCSpacing_out.xlsx", SaveFormat.XLSX); |