Ottieni stringa HTML5 dalla cella

Possibili Scenari di Utilizzo

Aspose.Cells restituisce la stringa HTML della cella utilizzando il metodo GetHtmlString che accetta un parametro booleano. Se passi false come parametro, restituirà l’HTML normale ma se passi true come parametro, restituirà la stringa HTML5.

Ottieni una stringa HTML5 dalla cella

Il codice di esempio seguente crea un oggetto workbook e aggiunge del testo nella cella A1 della prima scheda di lavoro. Quindi ottiene l’HTML normale e l’HTML5 dalla cella A1 utilizzando il metodo GetHtmlString e li stampa sulla console.

Codice di Esempio

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Create workbook.
Workbook wb = new Workbook();
//Access first worksheet.
Worksheet ws = wb.Worksheets[0];
//Access cell A1 and put some text inside it.
Cell cell = ws.Cells["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.
Console.WriteLine("Normal:\r\n" + strNormal);
Console.WriteLine();
Console.WriteLine("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>