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

Free Support Forum - aspose.com

Saving Excel files into HTML format with Visio object embed

Hi there


We are working on saving Excel files into HTML format with Aspose Cells.

With Aspose Cells 17.4.0, Visio object in Excel files seems not rendered in the HTML result.

Here is our test code:

String fileName = “PusheenVisio-20170427.xlsx”;

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

File f = new File(“custom/output/xlsx/” + fileName + “/”);
f.mkdirs();

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

baos.reset();

for (int i = 0; i < book.getWorksheets().getCount(); i++) {
book.getWorksheets().get(i).setVisible(true);
}

for (int i = 0; i < book.getWorksheets().getCount(); i++) {
// only one page for test
if (i != page) {
book.getWorksheets().get(i).setVisible(false);
}
}
HtmlSaveOptions saveOps = new HtmlSaveOptions();
saveOps.setClearData(false);
saveOps.setCreateDirectory(false);
saveOps.setExportActiveWorksheetOnly(false);
saveOps.setExportHiddenWorksheet(false);
saveOps.setParseHtmlTagInCell(true);
saveOps.setEncoding(Encoding.getUTF8());
saveOps.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.REMOVE);
saveOps.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE);
saveOps.setExportImagesAsBase64(true);

saveOps.setStreamProvider(new IStreamProvider() {

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

@Override
public void closeStream(StreamProviderOptions arg0) throws Exception {
System.out.println(arg0.getDefaultPath());
OutputStream stream = arg0.getStream();
if (stream instanceof ByteArrayOutputStream) {
ByteArrayOutputStream bb = (ByteArrayOutputStream) stream;
IOUtils.write(bb.toByteArray(),
new FileOutputStream(“custom/output/xlsx/” + arg0.getDefaultPath()));
}
}
});
book.save(baos, saveOps);
IOUtils.write(baos.toByteArray(),
new FileOutputStream(“custom/output/xlsx/” + fileName + “/” + (page + 1) + “.html”));
}

I also uploaded a example Excel file and the result.
Please check the attachment.
If there is any option to enable it, please tell me, thank you~

Craig

Hi,


Thanks for your posting and using Aspose.Cells.

Please provide us your runnable Java file. Suppose your Java file is sample.java, then change its extension to .txt and attach it like sample.java.txt or you can zip it and attach it.

We were able to observe this issue partially that Aspose.Cells is generating images in a directory even though the images should be embedded, however images are being generated OK.

We were not able to run your code completely so if you provide us runnable java file, then it will be helpful for us to look into this issue more precisely and we will log it in our database after replication.

Thanks for your cooperation in this regard and have a good day.

Hi


Please check the unit test code in the attachment, thank you~

Craig

Hi,


Thanks for your posting and using Aspose.Cells.

We have looked into this issue and found, the implemented methods of your stream provider are not called because of this line.

saveOps.setExportHiddenWorksheet(false); //comment this line

Once, you will comment this line, then your stream provider interface methods will be called successfully. However, we need to look into this issue in more detail. We were able to generate good html file but not in a right manner. I have attached the output html file for your reference.

Hi


We need this:

saveOps.setExportHiddenWorksheet(false);

because we noticed that if there is only one sheet not hidden and others hidden, the output will be a single one html file with the specific sheet content, without html frame.
I also remove the method about the stream provider

I still uploaded the result again and updated code snippet again, please check the attachment.

Craig

Hi,


Thanks for your posting and using Aspose.Cells.

We were able to observe this issue and found that image does not get displayed in the output Html when we set the export hidden worksheet option to false. However, when we set this option true or just comment the line, everything works fine.

This issue has been logged as

  • CELLSJAVA-42277 - Image does not get displayed in the output Html when HtmlSaveOptions.setExportHiddenWorksheet is set false

Java
String dirPath = “F:/Download/”;
String fileName = “PusheenVisio-20170427.xlsx”;

Workbook book = new Workbook(dirPath + fileName);

book.getWorksheets().get(“工作表2”).setVisible(false);
book.getWorksheets().get(“工作表3”).setVisible(false);

HtmlSaveOptions saveOps = new HtmlSaveOptions();
saveOps.setClearData(false);
saveOps.setCreateDirectory(false);
saveOps.setExportActiveWorksheetOnly(false);
saveOps.setExportHiddenWorksheet(false); //Comment this line and image will display fine
saveOps.setParseHtmlTagInCell(true);
saveOps.setEncoding(Encoding.getUTF8());
saveOps.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.REMOVE);
saveOps.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE);
saveOps.setExportImagesAsBase64(true);

book.save(dirPath + “outputsetExportHiddenWorksheetFalse.html”, saveOps);

Hi,


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

Thank you.

Hi,


Please try our latest version/fix: Aspose.Cells for Java v17.5.3 (attached):

Your issue should be fixed in it.

Let us know your feedback.

Thank you.

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan