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)