Get HTML5 string from Cell

Possible Usage Scenarios

Aspose.Cells for Python via .NET returns the HTML string of the cell using the get_html_string(html5) method which accepts a boolean parameter. If you pass false as a parameter, it will return Normal HTML but if you pass true as a parameter, it will return HTML5 string.

Get HTML5 string from Cell

The following sample code creates a workbook object and adds some text in cell A1 of the first worksheet. It then gets the Normal HTML and HTML5 string from cell A1 using the get_html_string(html5) method and prints them on the console.

Sample Code

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Create workbook.
wb = Workbook()
# Access first worksheet.
ws = wb.worksheets[0]
# Access cell A1 and put some text inside it.
cell = ws.cells.get("A1")
cell.put_value("This is some text.")
# Get the Normal and Html5 strings.
strNormal = cell.get_html_string(False)
strHtml5 = cell.get_html_string(True)
# Print the Normal and Html5 strings on console.
print("Normal:\r\n" + strNormal)
print()
print("Html5:\r\n" + strHtml5)

Console Output

 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>