Exception occurs when saving a Excel file into HTML format

Hi there

I am using Aspose Cells 17.5 to convert Excel file into HTML format.

Here is my code for test:

String fileName = “59_.xlsx”;

Workbook book = new Workbook(“custom/input/xlsx/” + fileName);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

File dir = new File(“custom/output/xlsx/” + fileName + “/”);

for (int page = 0; page < book.getWorksheets().getCount(); page++) {

for (int i = 0; i < book.getWorksheets().getCount(); i++) {

for (int i = 0; i < book.getWorksheets().getCount(); i++) {
// only one page for test
if (i != page) {
HtmlSaveOptions saveOps = new HtmlSaveOptions();

saveOps.setStreamProvider(new IStreamProvider() {

  public void initStream(StreamProviderOptions arg0) throws Exception {
  	arg0.setStream(new ByteArrayOutputStream());

  public void closeStream(StreamProviderOptions arg0) throws Exception {
  	OutputStream stream = arg0.getStream();
  	if (stream instanceof ByteArrayOutputStream) {
  		ByteArrayOutputStream bb = (ByteArrayOutputStream) stream;
  				new FileOutputStream("custom/output/xlsx/" + arg0.getDefaultPath()));

book.save(baos, saveOps);
new FileOutputStream(“custom/output/xlsx/” + fileName + “/” + page + “.html”));

An NullPointerException will be thrown from internal of the library with a Excel file like this:

	at com.aspose.cells.zra.a(Unknown Source)
	at com.aspose.cells.zamk.a(Unknown Source)
	at com.aspose.cells.zamk.b(Unknown Source)
	at com.aspose.cells.Font.getColor(Unknown Source)
	at com.aspose.cells.zafj.a(Unknown Source)
	at com.aspose.cells.zafj.b(Unknown Source)
	at com.aspose.cells.zafj.a(Unknown Source)
	at com.aspose.cells.zafi.c(Unknown Source)
	at com.aspose.cells.zafi.a(Unknown Source)
	at com.aspose.cells.zafn.a(Unknown Source)
	at com.aspose.cells.Workbook.a(Unknown Source)
	at com.aspose.cells.Workbook.save(Unknown Source)

This Exception occurs with Cells 17.1.0 and above.
And I tried 16.12.0, there is no Exception thrown.

I have uploaded the Excel file.
Please check this issue, thank you~


59_.zip (374.1 KB)

P.S. I suggest that it should be allowed to upload Excel files directly in the forum.(.xlsx file extension is banned)


Thanks for using Aspose APIs.

Such issues are being fixed by Aspose Website Team, please spare us some time. Hopefully, these issues will be fixed soon.

We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-42357 - Exception occurs when saving an Excel file into HTML format


Workbook wb = new Workbook(dirPath + "59_.xlsx");
wb.save(dirPath + "out.html");


This is to inform you that we have fixed your issue “CELLSJAVA-42357” now. We will soon provide you the fix after performing QA and incorporating other enhancements and fixes.

Thank you


Please try the latest version/fix: Aspose.Cells for Java v17.7.7:

Your issue should be fixed in it.

Let us know your feedback.

Thank you.


I checked this issue, and it is fixed.
Thanks for your help



Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSJAVA-42357) have been fixed in Aspose.Cells for Java 17.8.