Save as HTML: allow saving specific range



In Excel, when saving as HTML, I can specify a specific range to include.
It would be useful to have the same feature in Aspose Cells.

Kind regards,



Thanks for your query.

Yes, the feature is supported, you can render specific range to HTML. See the document for your reference:

Hope, this helps a bit.



Thank you, that’s exactly what I was looking for.

Kind regards,


@ TarasTielkes,

Good to know that it suits your needs well. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.


Hi @Amjad_Sahi

While the suggestion works, it has an undesired side-effect: as expected, it actually modifies the print area for the worksheet(s) in question.

In out scenario, we save a number of parts from various sheets to HTML, perform a bit of processing, then store the file in our system. Using the approach you suggests will show the print areas in Excel when the file is opened again.

In order to work around this, we would have to, for each HTML export that we perform:

  • check if the sheet defines a print selection, and if so, store it
  • set out custom print selection to limit the content range we want to save to HTML
  • afterwards, restore the previously defined print area (if any), since we want to leave the workbook in a state close to the original

This is an API design problem at the side of Aspose Cells: in order to adjust the range of data that I am exporting to HTML, I should not need to midify/mutate the underlying workbook. Instead of conflating different usages into single setPrintArea method, the area to export should simply be specified in the SaveOptions. That way the distinction is clear:

  • to modify the actual print area configured for the worksheet, use the method you suggested
  • to restrict the HTML (or PDF) export to a specific range, use parameters specific to the save/export process

Note that a similar problem is present for the setActiveWorkbookOnly() save option. This requires me to modify/mutate the active sheet state of the workbook, only to allow me to export a specific sheet. Similar to the issue above, this should be cleanly separated out into SaveOptions, so that I can configure the export/save process without making changes to the actual workbook being exported.

Kind regards,



I am not entirely certain if this is an issue with Aspose.Cells APIs (by design). Also, how could you export specific print areas only to be exported in HTML via MS Excel, I do not see this feature is present in MS Excel. Please provide sample files and demo code to show the issue(s). We will check it soon. Aspose.Cells should follow MS Excel standards and specifications when parsing or rendering HTML files.


Hi @Amjad_Sahi,

The Excel specifications from Microsoft relate to the file format only. The specific user-accessible features change by Excel version, and when using Office 365, sometimes on a weekly basis.

While Aspose Cells should be able to read and write workbook files compatible with Excel, this does not mean that Aspose Cells should be restricted to the functionality provided by Excel. And indeed many features offered by Aspose Cells are not present in Excel as such.

The problem with HtmlSaveOptions#setExportActiveWorksheetOnly() is that it requires me to modify the workbook by changing which sheet is “current”. The problem with HtmlSaveOptions#setExportPrintAreaOnly() is that is requires me to change the given print area for a given worksheet. If I export HTML from different sheets in the workbook, and persist the workbook (in XLSX format) afterwards, as a side-effect of exporting HTML, I now end up with undesired changes in the workbook, unless I take additional effort to back-up and restore the active workbook and per-sheet print areas.

Things would be much simpler if I could simply tell the HtmlSaveOptions which sheet, and which print area(s) I want to export to HTML. That way, there is no need to modify the state of the backing workbook during the HTML export process. Just because the user interface of Excel does things a certain way does not mean that Aspose Cells should limit itself to the same flow of interaction.

That said, regarding your question, Excel does in fact allow me to pick a custom range to export to HTML - see attached screenshot.

I hope my issue is clear: it would be nice to export parts of a workbook without implicitly changing some state of the same workbook.

Kind regards,

export.png (8.2 KB)


We have understood your requirement but we need to look into it more. We have logged the requirement in our database for investigation and for a fix(if possible). Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-43018 – Export print area range to HTML without implicitly changing some state of the same workbook