Cell から HTML5 文字列を取得
Contents
[
Hide
]
Cell から HTML5 文字列を取得
Aspose.Cells for Python via Java を使用すると、セルから HTML 文字列を取得できます。これは、[getHtmlString(ブール値 html5)](https://reference.aspose.com/cells/python/asposecells.api/cell#getHtmlString(boolean))APIが提供する方法。間違いパラメータとして、Normal HTML を返しますが、渡すと真実パラメータとして、HTML5 文字列を返します。
次のサンプル コードは、ブック オブジェクトを作成し、最初のワークシートのセル A1 にテキストを追加します。次に、セル A1 から通常の HTML と HTML5 文字列を取得します。getHtmlString(ブール値 html5) メソッドを実行し、それらを出力します。
サンプルコード
This file contains 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
# Load the Sample Workbook | |
workbook = Workbook() | |
# Access first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Access cell A1 and put some text inside it. | |
cell = worksheet.getCells().get("A1") | |
cell.putValue("This is some text.") | |
# Get the Normal and Html5 strings. | |
strNormal = cell.getHtmlString(False) | |
strHtml5 = cell.getHtmlString(True) | |
# Print the Normal and Html5 strings | |
print("Normal:\r\n" + strNormal) | |
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>