Structure of HTML output

When converting an Excel FIle with a single sheet to HTML, a single HTML file is obtained. When converting an Excel FIle with multiple sheets, the HTML code of each sheet is stored in a separate folder as sheet001.htm, sheet002.html…

Is there any way to keep the structure when converting single sheet files just like when converting multiple sheet files?

Are there any other case in which this structure changes?

@dharanikumar7998,
Well, Aspose.Cells follows MS Excel standards and specifications in rendering HTML files. Such folders and files are also created when you convert an MS Excel workbook to HTML in MS Excel manually, you may confirm this. You have two options and you may choose any the following approaches to accomplish the task:

  1. Use MHtml file format as an output file format from Excel workbooks. It will generate single output file.
  2. Try to export every worksheet (in the workbook) to single HTML and then group these individual HTMLs to one (final) HTML by yourselves via e.g some tag control or code. In a loop, you may set active for each sheet and then render separate HTML file (based on every worksheet) via Aspose.Cells APIs. Please note, when exporting every worksheet to separate HTML, you would need to export the image as base64 format (you will use HtmlSaveOptions class here) otherwise it will create folders. See the sample code for your reference:
var wb = new Workbook("Book1.xlsx");
             
// Save worksheets to separate html files 
for (int i = 0; i < wb.Worksheets.Count; i++)
{
    wb.Worksheets.ActiveSheetIndex = i;
    var options = new HtmlSaveOptions
    {
        ExportActiveWorksheetOnly = true,
        ExportImagesAsBase64 = true
    };
    wb.Save(string.Format(@"out1sheet1{0}.html", i), options);
}

Please note, you should have a valid license and you should set the license before using Aspose.Cells APIs least setting/activating sheets might not work.

1 Like

Thanks a lot!

@dharanikumar7998,

You are welcome and in the event of further queries or issue, feel free to write us back, we will be happy to assist you soon.