Obtenir la chaîne HTML5 de Cell
Contents
[
Hide
]
Scénarios d’utilisation possibles
Aspose.Cells renvoie la chaîne HTML de la cellule à l’aide de laGetHtmlString méthode qui accepte un paramètre booléen. Si vous passezfaux en paramètre, il renverra Normal HTML mais si vous passezvrai en tant que paramètre, il renverra la chaîne HTML5.
Obtenir la chaîne HTML5 de Cell
L’exemple de code suivant crée un objet classeur et ajoute du texte dans la cellule A1 de la première feuille de calcul. Il obtient ensuite la chaîne Normal HTML et HTML5 de la cellule A1 à l’aide de laGetHtmlStringméthode et les imprime sur la console.
Exemple de code
This file contains hidden or 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-.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); |
Sortie 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>