Ottieni la larghezza del testo del valore Cell
Contents
[
Hide
]
Ottieni la larghezza del testo del valore Cell
volte, gli sviluppatori potrebbero dover calcolare la larghezza del valore della cella per disporre i dati in un layout. Aspose.Cells fornisce ilCellsHelper.GetTextWidth che consente agli sviluppatori di ottenere la larghezza del testo del valore della cella. Il seguente codice di esempio illustra come utilizzareCellsHelper.GetTextWidth per accedere alla larghezza del testo del valore della cella.
Il file di origine utilizzato nel seguente frammento di codice è allegato come riferimento.
This file contains hidden or 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 output directory. | |
String sourceDir = Utils.Get_SourceDirectory();Workbook workbook = new Workbook(sourceDir + "GetTextWidthSample.xlsx"); | |
System.out.println("Text width: " + CellsHelper.getTextWidth(workbook.getWorksheets().get(0).getCells().get("A1").getStringValue(), workbook.getDefaultStyle().getFont(), 1)); |