java - Get the excel workbook password using Apache POI -


i trying read excel sheet of data, able data , read using hssfworkbook works well, able data.

i have set password workbook, manually in excel sheet protect workbook "abcxyz" , while opening excel file ask me password , after password in correct lets me in write or read excel file.

my question how password "abcxyz" in java program.

hssfworkbook wb = new hssfworkbook(inputstream); wb.iswriteprotected();--> returns false. 

as far know, can use:

(in excel 2003)

poifsfilesystem pfs = new poifsfilesystem(new fileinputstream("yourexcelfile.xls"));  biff8encryptionkey.setcurrentuserpassword("abcxyz");  hssfworkbook wb = new hssfworkbook(pfs); 

(in excel 2007)

poifsfilesystem pfs = newpoifsfilesystem(poidatasamples.getpoifsinstance().openresourceasstream("yourexcelfile.xlsx"));  encryptioninfo encinfo = new encryptioninfo(pfs);  decryptor decryptor = new decryptor(encinfo);  decryptor.verifypassword("abcxyz");  xssfworkbook wb = new xssfworkbook(decryptor.getdatastream(pfs)); 

hope helps!


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -