Export print area range to HTML

Possible Usage Scenarios

This is a common scenario where we need to export only print area i.e. selected range of cells instead of the entire sheet to HTML. This feature is already available for PDF rendering, however, now you can perform this task for HTML as well. First set the print area in the page setup object of the worksheet. Later on, use HtmlSaveOptions.export_print_area_only flag to export selected range only.

Sample Code

Following sample code loads a workbook and then exports print area to the HTML. Sample file for testing this feature can be downloaded from the following link:

sampleInlineCharts.xlsx

from aspose.cells import HtmlSaveOptions, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load the Excel file.
wb = Workbook(sourceDir + "sampleInlineCharts.xlsx")
# Access the sheet
ws = wb.worksheets[0]
# Set the print area.
ws.page_setup.print_area = "D2:M20"
# Initialize HtmlSaveOptions
options = HtmlSaveOptions()
# Set flag to export print area only
options.export_print_area_only = True
# Save to HTML format
wb.save(outputDir + "outputInlineCharts.html", options)