将打印区域范围导出为HTML
Contents
[
Hide
]
将打印区域范围导出为HTML
Aspose.Cells for Python via Java支持将仅打印区域即选定的单元格范围而不是整个工作表导出为HTML。为此,API提供了HtmlSaveOptions.ExportPrintAreaOnly属性。将此属性设置为True将仅导出打印区域。
以下示例代码演示了使用HtmlSaveOptions.ExportPrintAreaOnly属性仅将打印区域导出到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
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) |