I am using the same code as is from http://poi.apache.org/encryption.html
by passing the existing file in my local.
Please find below the stacktrace.

Requirement in my project is to create a password protected xlsx file thru
the code and user should be able to download the encrypted file instead of
plain file. Please let me know if there is any other way to achieve this
org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to
save: an error occurs while saving the package : null
at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:500)
at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1417)
at com.cisco.hr.aims.offline.EncryptExcel.main(EncryptExcel.java:37)
Caused by: java.lang.NullPointerException
at
org.apache.poi.poifs.filesystem.DirectoryNode.createDocument(DirectoryNode.java:219)
at
org.apache.poi.poifs.filesystem.DirectoryNode.createDocument(DirectoryNode.java:415)
at
org.apache.poi.poifs.crypt.DataSpaceMapUtils.createEncryptionEntry(DataSpaceMapUtils.java:72)
at
org.apache.poi.poifs.crypt.DataSpaceMapUtils.addDefaultDataSpace(DataSpaceMapUtils.java:42)
at
org.apache.poi.poifs.crypt.agile.AgileEncryptor$ChunkedCipherOutputStream.writeToPOIFS(AgileEncryptor.java:343)
at
org.apache.poi.poifs.crypt.agile.AgileEncryptor$ChunkedCipherOutputStream.close(AgileEncryptor.java:339)
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:149)
at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:310)
at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:498)
... 2 more

Thanks,
Sunanda

On Mon, Sep 15, 2014 at 5:16 AM, kiwiwings [via Apache POI] <
[email protected]> wrote:

>
> > at the line  opc.save(os);
> > org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to
> > save: an error occurs while saving the package : null
>
> I have seen this error before, but I can't reproduce it (by using the
> trunk version).
> Are you using the example as-is (of course the example assumes, you have
> an existing OPC file ...)?
> -> if not, please post your code.
>
> Please also post the stacktrace, i.e. the cause for the exception in the
> zip-package.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=5716621&i=0>
> For additional commands, e-mail: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=5716621&i=1>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-poi.1045710.n5.nabble.com/Encrypt-xlsx-file-with-POI3-9-tp5716609p5716621.html
>  To unsubscribe from Encrypt xlsx file with POI3.9, click here
> <http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5716609&code=c3VuYW5kYS5yYW5pQGdtYWlsLmNvbXw1NzE2NjA5fDE2NzE5OTY3NDU=>
> .
> NAML
> <http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Encrypt-xlsx-file-with-POI3-9-tp5716609p5716622.html
Sent from the POI - User mailing list archive at Nabble.com.

Reply via email to