Ottieni stringa HTML5 dalla cella

Possibili Scenari di Utilizzo

Aspose.Cells restituisce la stringa HTML della cella utilizzando il metodo getHtmlString(boolean html5). Se passi false come parametro, ti restituirà HTML normale ma se passi true come parametro, ti restituirà la stringa HTML5.

Ottieni una stringa HTML5 dalla cella

Il seguente codice di esempio crea un oggetto workbook e aggiunge del testo nella cella A1 del primo foglio di lavoro. Ottiene quindi la stringa HTML normale e HTML5 dalla cella A1 utilizzando il metodo getHtmlString(boolean html5) e le stampa sulla console.

Codice di Esempio

// 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);

Output della console

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>