Protect excel file with java

。_饼干妹妹 提交于 2019-12-24 10:46:39

问题


Is there a way to create open protected excel file in Java? I'm looking at JExcelApi and Apache Poi projects but with both of them I cannot figure out how to protect generated xls file. I want to assure that generated file can be opened only by people that know password phrase.


回答1:


I would recommend using JACOB (COM->Java bridge), and control Excel via COM automation. This will, of course, require that Excel be installed on the machine in question.




回答2:


One trick I've found when using POI is to create an Excel file with the feature I want embedded in it (e.g. a macro), and then use POI to open the file, modify it and then write it out.

So you may get what you want by creating a password-protected file, and then seeing if you can open and modify (and save) via POI. Of course, if password-protecting encrypts as well, then you're out of luck.




回答3:


you can think it another way as with logic...

Runtime runtime = Runtime.getRuntime();
        Process exec;
        try {
            exec = runtime.exec("attrib -h C:\\exce.csv");
            int waitFor = exec.waitFor();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
        }


来源:https://stackoverflow.com/questions/1092027/protect-excel-file-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!