将Excel导出为带有网格线的HTML
Contents
[
Hide
]
如果要用带网格线的HTML导出Excel文件,请使用 HtmlSaveOptions.export_grid_lines 属性并设置为 true。
将Excel导出为带有网格线的HTML
以下示例代码创建一个工作簿,并用一些值填充其工作表,然后设置 HtmlSaveOptions.export_grid_lines 为 true 后保存为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
from aspose.cells import HtmlSaveOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create your workbook | |
wb = Workbook() | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Fill worksheet with some integer values | |
for r in range(10): | |
for c in range(10): | |
ws.cells.get(r, c).put_value(r * 1) | |
# Save your workbook in HTML format and export gridlines | |
opts = HtmlSaveOptions() | |
opts.export_grid_lines = True | |
wb.save(dataDir + "ExportToHTMLWithGridLines_out.html", opts) |