Ottieni larghezza testo del valore della cella
Contents
[
Hide
]
Ottieni larghezza testo del valore della cella
A volte, gli sviluppatori potrebbero aver bisogno di calcolare la larghezza del valore della cella per organizzare i dati in qualche layout. Aspose.Cells per Python via .NET fornisce il metodo CellsHelper.get_text_width che consente agli sviluppatori di ottenere la larghezza del testo del valore della cella. Il codice di esempio seguente illustra come utilizzare CellsHelper.get_text_width per accedere alla larghezza del testo del valore della cella.
Il file di origine utilizzato nello snippet di codice seguente è allegato per il tuo riferimento.
Codice di esempio
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))) |