将Excel导出为带有网格线的HTML
Contents
[
Hide
]
如果您想要将Excel文件导出为带有网格线的HTML,请使用 HtmlSaveOptions.ExportGridLines 属性并将其设置为 true。
将Excel导出为带有网格线的HTML
以下示例代码创建一个工作簿,并在其工作表中填充一些值,然后在将 HtmlSaveOptions.ExportGridLines 设置为 true 后将其保存为HTML格式。
下面的截图显示了使用此示例代码生成的输出HTML。正如您所见,它还在输出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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExportExceltoHTML.class); | |
// Create your workbook | |
Workbook wb = new Workbook(); | |
// Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Fill worksheet with some integer values | |
for (int r = 0; r < 10; r++) { | |
for (int c = 0; c < 10; c++) { | |
ws.getCells().get(r, c).putValue(r * 1); | |
} | |
} | |
// Save your workbook in HTML format and export gridlines | |
HtmlSaveOptions opts = new HtmlSaveOptions(); | |
opts.setExportGridLines(true); | |
wb.save(dataDir + "output.html", opts); |