NPOIFSFileSystem fs = new NPOIFSFileSystem(new File("C://Users//RK5026051//Downloads//500_Lanes.xls"));
EncryptionInfo info = new EncryptionInfo(fs);
Decryptor d = Decryptor.getInstance(info);
if (d.verifyPassword("manh.com")) {
HSSFWorkbook wb = new HSSFWorkbook(d.getDataStream(fs));
} else {
System.out.println("wrong password");
}
// TODO Auto-generated method stub
}
Error--
Exception in thread "main" java.io.FileNotFoundException: no such entry: "EncryptionInfo", had: [_VBA_PROJECT_CUR, SummaryInformation, DocumentSummaryInformation, Workbook]
at org.apache.poi.poifs.filesystem.DirectoryNode.getEntry(DirectoryNode.java:370)
at org.apache.poi.poifs.filesystem.DirectoryNode.createDocumentInputStream(DirectoryNode.java:177)
at org.apache.poi.poifs.crypt.EncryptionInfo.<init>(EncryptionInfo.java:51)
at org.apache.poi.poifs.crypt.EncryptionInfo.<init>(EncryptionInfo.java:47)
at auto.excel.main(excel.java:15)
I am downloading a file from a application using selenium , I need to update some fields in the excel file and then upload it again.**
I know the password of the excel file i am downloading , Now i need to write a code so that it updates specific rows and columns , But I am unable to any operation on that excel file and i guess that is because its password protected .
I have tried some answers on stack Overflow but i is not working. Also i did not get many materials on internet about this topic. Here is a sample code i tried
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File("D://protectedfile.xlsx"));
EncryptionInfo info = new EncryptionInfo(fs);
Decryptor d = Decryptor.getInstance(info);
if (d.verifyPassword("password")) {
XSSFWorkbook wb = new XSSFWorkbook(d.getDataStream(fs));
} else {
// Password is wrong
}