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

Free Support Forum - aspose.com

Export to HTML fails when using Streams

Hi to the support team,

The code opens an Excel document and exports the document to html via a FileStream.

static void Main(string[] args)
// Open simple XLS file
Aspose.Cells.Workbook w = new Workbook(“C:\Temp\Excel1.xls”, new LoadOptions(LoadFormat.Excel97To2003));

HtmlSaveOptions saveopt = new HtmlSaveOptions(SaveFormat.Html);
saveopt.AttachedFilesDirectory = “C:\Temp\Excel1-Dateien”;
saveopt.AttachedFilesUrlPrefix = “Excel1-Dateien”;
saveopt.PageTitle = “Excel1”;

FileStream fOut = new FileStream(“C:\Temp\Excel1.htm”, FileMode.Create);

w.Save(fOut, saveopt);


Saving the document causes the following exception:

Aspose.Cells.CellsException: sheet Name must not be null if exp html to a stream
bei x6e160ea926530ce7.xa58dbe0dcaf7bad2…ctor(Workbook book, Stream stream, String sheetName, String pageTitle)
bei Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)
bei Aspose.Cells.Workbook.Save(Stream stream, SaveFormat saveFormat)
bei de.egov.AsposeDcs.ExcelConverter.ConvertFormat(String strDestFile, String strFormat)

Aspose.Cells Version 5.1.0

Dotnet framework 2.0

What is wrong?

Thanks in advance, Martin


I have tested the code and I am able see the problem.

As far as I can see, you are saving the contents into FileStream object and then creating an HTML file from it. I think its better to use the code given below to convert the excel file into HTML file

Aspose.Cells.Workbook w = new Workbook(“C:\Demo.xls”, new LoadOptions(Aspose.Cells.LoadFormat.Excel97To2003));
w.Save(“C:\Excel1_inHTML.htm”, Aspose.Cells.SaveFormat.Html);


i posted only some sample code to keep it clear. In the real world the html stream ouput is further processed befor its written to disk. So, writing html export to a file isn’t very efficient.

By the way, to html export to a file is buggy too.

If you save html to a file, it ignores the HtmlSaveOptions.AttachedFilesDirectory property. The html artefacts are always writen to “C:\Temp\Excel_files”. Instead of “C:\Temp\Excel-Dateien” as in my example.


We have fixed the issue regarding export to html using stream. Please try the new version v5.1.1 (new hot fix we released)

As the api document describes, HtmlSaveOptions.AttachedFilesDirectory and HtmlSaveOptions.AttachedFilesUrlPrefix properties only work for saving to html stream.

Saving html to disk file will work as manually saving excel file to html in MS Excel.

Thank you