Currently, the way we convert a range within a worksheet to HTML is to manipulate the worksheet by taking the following actions:
- Determining the used range in the worksheet.
- Hide all rows and columns that are outside the target range.
- Iterate all worksheet Shapes and remove any that are outside the range.
- Remove any background image on the sheet.
- Save the workbook as HTML with the appropriate HtmlSaveOptions.
The problem is that we need to restore the workbook to its original state after the range is saved as HTML. This includes restoring the Workbook’s underlying FileFormatType to XLSX (which becomes HTML after step 5 above).
It would be really great in terms of performance and usability if Cells (for Java) provides a new API that would allow us to export a given range as HTML - leaving the original Workbook intact and without any modifications.
Please note that Excel currently provides this feature via:
- The UI: Select any range > File > Save As > Save as type “Web Page (*.html)” > Save Selection
Excel VBA/Interop: using the following code:
ThisWorkbook.PublishObjects.Add(xlSourceRange, "Name.html", "Sheet1", "A1:E10", xlHtmlStatic).Publish(true)
Please consider adding this enhancement.