It's not a secret anymore!*
The moose likes Java in General and the fly likes reading password protected excel sheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "reading password protected excel sheet" Watch "reading password protected excel sheet" New topic
Author

reading password protected excel sheet

sagarika kar
Greenhorn

Joined: Jan 02, 2010
Posts: 2
I am trying to read a password protected excel sheet using apache POI.The code works fine with any other excel sheet.However when I am trying to read the protected sheet i am getting the following exception

java.lang.NoSuchMethodError: java.lang.RuntimeException: method <init>(Ljava/lang/String;Ljava/lang/Throwable;)V not found
at org.apache.poi.hssf.record.RecordFormatException.<init>(RecordFormatException.java:36)
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:208)
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:126)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:246)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:169)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:151)

the java code I am using is



It is throwing an exception at the line HSSFWorkbook wb = new HSSFWorkbook(fileSystem);

Any help is greatly appreciated
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Welcome to JR

You're not supposed to read the password protected excel file. Please use following method to check whether its protected or not.
http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html#isWriteProtected%28%29


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41598
    
  55
It sounds as if you may be using jar files from different POI versions together. Make sure that all the files you have are from the same POI version.


Ping & DNS - my free Android networking tools app
sagarika kar
Greenhorn

Joined: Jan 02, 2010
Posts: 2
hey ...i m using all files from poi 3.0 jar.and only the first two rows of the workbook are password protected...so i should be able to modify data inthe other rows...but i m getting this exception
Even if i m using the jexcel api i m getting exception as

the workbook is password protected
is their any way out??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41598
    
  55
POI 3.0 is rather old; try a newer version such as 3.6.
 
 
subject: reading password protected excel sheet