I have tried the below code,
import org.apache.poi.poifs.crypt.Decryptor;
import org.apache.poi.poifs.crypt.EncryptionInfo;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("D://protectedfile.xlsx"));
EncryptionInfo info = new EncryptionInfo(fs);
Decryptor d = new Decryptor(info); //Error
d.verifyPassword(Decryptor.DEFAULT_PASSWORD);
It throws an error compilation error : Cannot instantiate the type Decryptor
But eventually this method will need me to copy and create new workbook in which i can read the data.
- Why i'm not able to instantiate Decryptor?
- Is there any other way than this, so that i can simply read the password protected excel file without creating a copy of it?
Note : I have looked at this post reading excel file, but doesn't help my exact situation