将打印区域范围导出为HTML

将打印区域范围导出为HTML

Aspose.Cells for Python via Java支持将仅打印区域即选定的单元格范围而不是整个工作表导出为HTML。为此,API提供了HtmlSaveOptions.ExportPrintAreaOnly属性。将此属性设置为True将仅导出打印区域。

以下示例代码演示了使用HtmlSaveOptions.ExportPrintAreaOnly属性仅将打印区域导出到HTML。

source_directory = "Examples/SampleFiles/SourceDirectory/"
output_directory = "Examples/SampleFiles/OutputDirectory/"
# Load the Sample Workbook
workbook = Workbook(source_directory + "sampleInlineCharts.xlsx")
# Access the firs worksheet
worksheet = workbook.getWorksheets().get(0)
# Set the print area.
worksheet.getPageSetup().setPrintArea("D2:M20")
# Initialize HtmlSaveOptions
saveOptions = HtmlSaveOptions()
# Set flag to export print area only
saveOptions.setExportPrintAreaOnly(True)
# Save the excel file.
workbook.save(output_directory + "outputInlineCharts.html", saveOptions)