Xlsx to html conversion issue

@hasithwijerathna,

The feature of exporting all required resources to a single html file has been in our roadmap or plan list. However, it is a bit complicated and we are afraid we cannot support it soon.

As a workaround, we think you may try the solution, i.e., exporting all resources of the html to a zip file, then uploading the zip file to server and unzip it at the server for subsequent processes.

If this solution is suitable for your scenario, please confirm us and we will provide the sample code of saving html to zip file.

@Amjad_Sahi

Please provide that as well I can try and let you know.

Thank you

@hasithwijerathna,

Thanks for the confirmation. We will compile the sample code and provide it to you soon.

1 Like

@hasithwijerathna,

Please refer to the below code for your reference:


        Workbook book = new Workbook(filepath);

        HtmlSaveOptions saveOptions = new HtmlSaveOptions();
        final HashMap entries = new HashMap();
        saveOptions.setStreamProvider(new IStreamProvider() {
            public void initStream(StreamProviderOptions options) throws Exception
            {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                entries.put(options.getDefaultPath(), baos);
                options.setStream(baos);
            }
            public void closeStream(StreamProviderOptions options) throws Exception
            {
                entries.put(options.getDefaultPath(),
                        ((ByteArrayOutputStream)entries.remove(options.getDefaultPath())).toByteArray());
            }
        });

        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("res.zip"));
        zos.putNextEntry(new ZipEntry("res.html"));
        book.save(zos, saveOptions);
        zos.closeEntry();
        if(entries.size() > 0)
        {
            for(Object es : entries.entrySet())
            {
                Map.Entry entry = (Map.Entry)es; 
                zos.putNextEntry(new ZipEntry((String)entry.getKey()));
                zos.write((byte[])entry.getValue());
                zos.closeEntry();
            }
        }
        zos.close();

Hope, this helps a bit.

@Amjad_Sahi Thanks you for the reply and this will help us a lot I think.

Appreciated.

@hasithwijerathna,

You are welcome.

The issues you have found earlier (filed as CELLSJAVA-43533) have been fixed in this update. This message was posted using Bugs notification tool