セル値のテキスト幅を取得する
Contents
[
Hide
]
セル値のテキスト幅を取得する
開発者は、時折、データを整理するためにセルの値の幅を計算する必要があります。Aspose.Cellsは開発者がセルの値のテキスト幅を取得することを可能にするCellsHelper.GetTextWidthメソッドを提供します。次のサンプルコードは、CellsHelper.GetTextWidthを使用してセルの値のテキスト幅にアクセスする方法を示しています。
以下のコードスニペットで使用されるソースファイルは参照用に添付されています。
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 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)); |