セルから HTML5 文字列を取得

可能な使用シナリオ

Aspose.Cells for Python via .NETは、ブール値を受け入れるget_html_string(html5)メソッドを使用してセルのHTML文字列を返します。ブール値としてfalseを渡すと、通常のHTMLが返されますが、trueを渡すとHTML5文字列が返されます。

セルからHTML5文字列を取得

次のサンプルコードはワークブックオブジェクトを作成し、最初のワークシートのセルA1にテキストを追加します。そして、get_html_string(html5)メソッドを使用してセルA1から通常のHTMLとHTML5文字列を取得し、それらをコンソールに出力します。

サンプルコード

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)

コンソール出力

 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>