Export Worksheet CSS Separately in Output HTML

Possible Usage Scenarios

Aspose.Cells provides the feature to export worksheet CSS separately when you convert your Excel file to HTML. Please use the HtmlSaveOptions.ExportWorksheetCSSSeparately property for this purpose and set it to true while saving an Excel file to HTML format.

Export Worksheet CSS Separately in Output HTML

The following sample code creates an Excel file, adds some text to cell B5 in red color, and then saves it in HTML format using the HtmlSaveOptions.ExportWorksheetCSSSeparately property. Please see the output HTML generated by the code for reference. You will find stylesheet.css inside it as a result of the sample code.

Sample Code

Export single sheet workbook to HTML

When a workbook with multiple sheets is converted to HTML using Aspose.Cells, it creates an HTML file along with a folder containing CSS and multiple HTML files. When this HTML file is opened in a browser, the tabs are visible. The same behavior is required for a workbook with a single worksheet when it is converted to HTML. Previously, no separate folder was created for single‑sheet workbooks, and only an HTML file was generated. Such an HTML file does not show tabs when opened in a browser. MS Excel creates a proper folder and HTML for a single sheet as well, and hence the same behavior is implemented using Aspose.Cells APIs. The sample file can be downloaded from the following link for use in the sample code below:

sampleSingleSheet.xlsx

Sample Code