Obtener cadena HTML5 de Cell
Contents
[
Hide
]
Posibles escenarios de uso
Aspose.Cells devuelve la cadena HTML de la celda usando elgetHtmlString(booleano html5)método. si pasasfalsocomo parámetro te devolverá Normal HTML pero si pasasverdaderocomo parámetro, devolverá una cadena HTML5.
Obtener cadena HTML5 de Cell
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)método y los imprime en la consola.
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Create workbook. | |
Workbook wb = new Workbook(); | |
//Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access cell A1 and put some text inside it. | |
Cell cell = ws.getCells().get("A1"); | |
cell.putValue("This is some text."); | |
//Get the Normal and Html5 strings. | |
String strNormal = cell.getHtmlString(false); | |
String strHtml5 = cell.getHtmlString(true); | |
//Print the Normal and Html5 strings on console. | |
System.out.println("Normal:\r\n" + strNormal); | |
System.out.println(); | |
System.out.println("Html5:\r\n" + strHtml5); |
Salida de consola
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>