見出しを含めてExcelをHTMLに変換する
Contents
[
Hide
]
見出しを使用したExcelからHTMLへの変換
Excel ファイルを HTML に変換する際、Aspose.Cells は列と行の見出しをエクスポートするオプションを提供しています。API が提供する HtmlSaveOptions.ExportHeadings プロパティを使用することで、これを実現できます。HtmlSaveOptions.ExportHeadings のデフォルト値は False です。出力の HTML ファイルで見出しをレンダリングするには、パラメータとして True を渡します。以下の画像は、このコードによって生成された出力ファイルを示しています。
以下のサンプルコードは、HtmlSaveOptions.ExportHeadings プロパティを使用して、出力の HTML ファイルで見出しをレンダリングする方法を示しています。
サンプルコード
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
# 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) |