Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading password protected excel sheet

 
sagarika kar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sagarika kar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POI 3.0 is rather old; try a newer version such as 3.6.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic