セル値のテキスト幅を取得する
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-.NET | |
Workbook workbook = new Workbook(sourceDir + "GetTextWidthSample.xlsx"); | |
Console.WriteLine("Text width: " + CellsHelper.GetTextWidth(workbook.Worksheets[0].Cells["A1"].StringValue, workbook.DefaultStyle.Font, 1)); |