导出打印区域范围为HTML
Contents
[
Hide
]
可能的使用场景
这是一个常见的场景,我们只需要导出打印区域,即选定的单元格范围,而不是整个工作表到 HTML。此功能已可用于 PDF 渲染,但是,现在您也可以为 HTML 执行此任务。首先在工作表的页面设置对象中设置打印区域。稍后,使用HtmlSaveOptions.ExportPrintAreaOnly仅导出选定范围的标志。
示例代码
以下示例代码加载工作簿,然后将打印区域导出到 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-.NET | |
// Load the Excel file. | |
Workbook wb = new Workbook(sourceDir + "sampleInlineCharts.xlsx"); | |
// Access the sheet | |
Worksheet ws = wb.Worksheets[0]; | |
// Set the print area. | |
ws.PageSetup.PrintArea = "D2:M20"; | |
// Initialize HtmlSaveOptions | |
HtmlSaveOptions options = new HtmlSaveOptions(); | |
// Set flag to export print area only | |
options.ExportPrintAreaOnly = true; | |
//Save to HTML format | |
wb.Save(outputDir + "outputInlineCharts.html", options); |