Obtener cadena HTML5 de Cell
Contents
[
Hide
]
Obtener cadena HTML5 de Cell
Usando Aspose.Cells for Python via Java, puede obtener la cadena HTML de la celda. Esto se puede lograr usando elgetHtmlString(booleano html5) método proporcionado por el API. Si pasafalsocomo parámetro te devolverá Normal HTML pero si pasasverdaderocomo parámetro, devolverá una cadena HTML5.
El código de ejemplo siguiente crea un objeto de libro y agrega texto en la celda A1 de la primera hoja de cálculo. Luego obtiene la cadena Normal HTML y HTML5 de la celda A1 usando elgetHtmlString(booleano html5) y los imprime.
Código de muestra
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
# Load the Sample Workbook | |
workbook = Workbook() | |
# Access first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Access cell A1 and put some text inside it. | |
cell = worksheet.getCells().get("A1") | |
cell.putValue("This is some text.") | |
# Get the Normal and Html5 strings. | |
strNormal = cell.getHtmlString(False) | |
strHtml5 = cell.getHtmlString(True) | |
# Print the Normal and Html5 strings | |
print("Normal:\r\n" + strNormal) | |
print("Html5:\r\n" + strHtml5) |
El siguiente es el resultado generado por el fragmento de código proporcionado anteriormente.
Producción
Normal:
<Font Style="FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;">This is some text.</Font>
Html5:
<div Style="FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;">This is some text.</div>