Få textbredd på Cell-värde
Contents
[
Hide
]
Få textbredd på Cell-värde
Ibland kan utvecklarna behöva beräkna bredden på cellens värde för att ordna data i någon layout. Aspose.Cells tillhandahållerCellsHelper.GetTextWidth metod som låter utvecklare få textbredden för cellens värde. Följande exempelkod illustrerar hur du använderCellsHelper.GetTextWidth för att komma åt textbredden för cellens värde.
Källfilen som används i följande kodavsnitt bifogas som referens.
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)); |