将Excel转换为带有标题的HTML
Contents
[
Hide
]
将 Excel 转换为带有标题的 HTML
Aspose.Cells提供了在将Excel转换为HTML时导出行和列标题的选项。这可以通过使用API提供的HtmlSaveOptions.ExportHeadings属性来实现。HtmlSaveOptions.ExportHeadings的默认值为False。将True作为参数传递以在输出HTML文件中呈现标题。以下图片显示了以下代码生成的输出文件。
以下示例代码演示了使用HtmlSaveOptions.ExportHeadings属性在输出HTML文件中呈现标题。
示例代码
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) |