HTML5 String aus Zelle abrufen
Mögliche Verwendungsszenarien
Aspose.Cells for Python via .NET gibt den HTML-String der Zelle mit der get_html_string(html5)-Methode zurück, die einen booleschen Parameter akzeptiert. Wenn Sie false als Parameter übergeben, wird es Normal HTML zurückgeben, aber wenn Sie true als Parameter übergeben, wird es einen HTML5-String zurückgeben.
Holen Sie sich HTML5-String aus der Zelle
Der folgende Beispielcode erstellt ein Arbeitsmappenobjekt und fügt etwas Text in Zelle A1 des ersten Arbeitsblatts ein. Anschließend wird der Normal HTML- und HTML5-String aus Zelle A1 mit der Methode get_html_string(html5) geholt und auf der Konsole gedruckt.
Beispielcode
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) |
Konsolenausgabe
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>