セル値のテキスト幅を取得する
Contents
[
Hide
]
セル値のテキスト幅を取得する
開発者は、データを配置するためにセルの値の幅を計算する必要があることがあります。Aspose.Cells for Python via .NET は、開発者がセルの値のテキスト幅を取得する CellsHelper.get_text_width メソッドを提供しています。次のサンプルコードは、CellsHelper.get_text_width の使用方法を示しています。
以下のコードスニペットで使用されるソースファイルは参照用に添付されています。
サンプルコード
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
import io | |
import aspose.cells | |
from aspose.cells import Workbook, Worksheet, Cells, CellsHelper | |
# For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
workbook = Workbook("Sample.xlsx"); | |
a1_cell_value = workbook.worksheets[0].cells.get("A1").string_value | |
print("Text width: " + str(CellsHelper.get_text_width(a1_cell_value, workbook.default_style.font, 1.0))) |