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

Free Support Forum - aspose.com

Aspose.Cells conversion of Multiple Worksheet of Excel byte to HTML


I am upgrading Aspose.cell to Aspose.Cells .Net) in my project.

I am trying to convert Excel file having multiple worksheet which is saved in byte format in DataBase to HTML. It is working correct for single worksheet in a Excel File. But, when we have multiple worksheet, it is not creating any node in the HTML. So when we try to save that HTML and display it in application no content is displayed. I need to show the first Worksheet data in my application.
I tried this with previous version of Aspose(Aspose.cell and it worked correctly.

PFA for the Sample Code screenshot and the excel file I am trying to convert to HTML.


Thanks for your posting and using Aspose.Cells.

We have converted your source excel file into html using the following code with the latest version: Aspose.Cells for .NET v16.10.8.0 and found it is ok.

Please download the output html generated with this code and let us know where the problem is? Some screenshots illustrating the issue will be helpful for understanding your issue precisely.

Workbook wb = new Workbook(dirPath + “Multiple+Sheets+Test.xlsx”);
wb.Save(dirPath + “output.html”);


Thanks for the reply.
I have tried by opening the Excel file and saving it in HTML format, and it is working. But in our case we are working on byte[], and when we are trying to convert that byte[] into stream and then saving it to HTML, we are getting different results for old and new Aspose dll. Also the HTML saved by new Aspose is not opening as it is corrupted, but the same is working when old Aspose dll is used.
PFA for the code sample and the output we are getting.

File Names(in the zip):

NewAsposeHTML.html - HTML file created from new Aspose dll.
NewAsposeTXT.txt - HTML structure created from new Aspose dll

OldAsposeHTML.html - HTML file created from old Aspose dll.
OldAsposeTXT.txt - HTML structure created from old Aspose dll



Thanks for providing us further details and sample files.

After an initial test, I observed the issue as you mentioned by using the following sample code with your template file. I found that by saving an HTML stream (of an XLSX file) to byte array corrupted the file. I also tested and found that it works fine for a single worksheet in an Excel File (if we use HtmlSaveOptions.ExportActiveWorksheetOnly to set to “true”). But, if we do not set the option, it is not working and render a corrupted HTML file. Also, I tried your scenario/case with previous version of Aspose.Cells v8.1.0.0 and it works fine and does not render corrupted file.
Sample code:

Aspose.Cells.License license = new Aspose.Cells.License();

var workbook = new Workbook(“e:\test2\Multiple+Sheets+Test.xlsx”);

var stream = new MemoryStream();

HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);
// options.ExportActiveWorksheetOnly = true; //It works fine
// workbook.Save(“e:\test2\output.html”, options); //It also works fine.
workbook.Save(stream, options);

string filename = “e:\test2\out1.html”;

FileStream fstream = new System.IO.FileStream(filename, FileMode.OpenOrCreate);
stream.Position = 0;
byte[] data = stream.ToArray();
fstream.Write(data, 0, data.Length);

I have logged a ticket with an id “CELLSNET-44891” for your issue. Our concerned developer from product team will investigate and look into it if this is a bug or expected behavior in newer versions when saving an Excel file to streams. Also, you might know when saving an Excel file to memory streams, you can save single worksheet only.

Once we have an update on it, we will let you know here.

Thank you.


We did evaluate you issue further. I am afraid, we will not support exporting Excel file to a single file which includes all resources such as images, css and all document pages as an embedded resources i.e. get a single html file as a result which will contain all resources in it.
If you want to implement it, please export every worksheet one by one using the following codes, and then combine result files by yourselves.
Sample code:

Workbook wb = new Workbook(filePath + “a.xlsx”);
HtmlSaveOptions options = new HtmlSaveOptions();
options.ExportActiveWorksheetOnly = true;
options.ExportImagesAsBase64 = true;
int sheetCount = wb.Worksheets.Count;
for (int i = 0; i < sheetCount; i++)
wb.Worksheets.ActiveSheetIndex = i;
wb.Save(filePath + “sheet00” + i + “.html”, options);

Your issue is closed with status “as Won’t Fix”.

Thank you.