We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Converting workbooks into HTML format without "_files" subfolder

(Disclaimer: I use Aspose.Cells 18.9 and cannot for the moment upgrade since we need to renew the license.)

When an an Excel file is converted into HTML format with Aspose.Cells.Workbook.save(), a subfolder named like the basename of the root HTML file with "_file" suffix is is created.

Is there a way to get all the files in the current folder without any subfolders?



Thanks for your query.

I have tried to achieve the same using Excel, but could not succeed. It seems that Excel does not provide this feature. As Aspose.Cells mimics the behavior of Excel, therefor this option is not available in the API. However if Excel provides this feature, please share the steps with us. We will try to provide the same feature using Aspose.Cells.


As Ahsan Iqbal told you that Aspose.Cells follows Ms Excel standards and specifications in rendering Excel to HTML file format, so by default it will create folder containing the resource files against worksheets in the workbook. But you may still choose any of the following options to cope with it:

  1. Use MHtml file format as an output file format from Excel workbooks. It will generate single output file without any folders/sub-folders for resource files.

  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 using your own 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 image as base64 format (you will use HtmlSaveOptions class here) otherwise it will create folders. See the sample code for your reference:
    Sample code:

//Load your sample workbook
Workbook wb = new Workbook(“e:\test2\Book1.xlsx”);

//Specify HtmlSaveOptions
//Export image as bytes (base 64) as inline images
//Export active worksheet only
HtmlSaveOptions opts = new HtmlSaveOptions();
opts.ExportImagesAsBase64 = true;
opts.ExportActiveWorksheetOnly = true;//You may activate one sheet at a time.

//Save the workbook in HTML format with above HtmlSaveOptions
wb.Save(“e:\test2\out1.html”, opts);

Hope, this helps a bit.

@Amjad_Sahi & @ahsaniqbalsidiqui,

Thank you very much for your answer. I didn’t know that the HTML generations mimiced the behavior of Excel for HTML conversion. I will check the options Amjad provided, and will let a feedback about it.



Thank you for the feedback and 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.


I have one question. Regarding the second option, isn’t easier to generate the default way, moving all files located in the _file directory to the parent one and then fixing all the links inside the HTML?



Well, the second option (we suggested) is useful if you do not want to save resources (individual htm files against sheets, image files, css and other files, etc.) separately and you need everything in the HTML file(s) itself. So, you may go for your devised approach if you can implement it and it suits your needs.