Get Text Width of Cell Value
Get Text Width of Cell Value
Sometimes, the developers might need to calculate the width of the cell’s value for arranging data in some layout. Aspose.Cells for Python via .NET provides the CellsHelper.get_text_width method which allows developers to get the text width of the cell’s value. The following sample code illustrates how to use CellsHelper.get_text_width to access the text width of the cell’s value.
The Source file used in the following code snippet is attached for your reference.
Sample Code
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))) |