-3

How can I programmatically check if a workbook of an excel file is password protected? If protected, how can I read and edit it using jxl?

For background, I wanted to make a file password protected but could not find a method to do it using jxl so I used com.jexcel.util.ExcelAdapter. That set a password on excel file,but I could not find a way to unprotect file for reading and editing.

Using jxl if I set a password on sheet then I can read it but I do not know how to set password on workbook and how to unlock the password. There is that method isProtected() that just tells that it is protected but I am unsure how to unlock and open it.

Tim Post
  • 33,371
  • 15
  • 110
  • 174
blackfyre
  • 2,549
  • 5
  • 39
  • 58
  • @Lucifer I am using jxl, I wanted to make file password protected but could not find a method to do it using jxl so I used "com.jexcel.util.ExcelAdapter" that set a password on excel file...but could not find a way to unprotect file for reading and editing...Using jxl if I set a password on sheet than i can read it but I do not know how to set password on workbook and how to unlock the password..there is that method "isProtected()" that just tell that it is protected but how can I open it.... – blackfyre May 27 '12 at 16:45
  • Check the answer to this question: http://stackoverflow.com/questions/2609301/password-protected-excel-file – Hakan Serce May 27 '12 at 17:18
  • this link is helpful for working with sheets using jxl. I was looking for workbook...but now I know it can not be done by the api that I'm using. – blackfyre May 28 '12 at 01:03

1 Answers1

-1

using jexcelapi_2_6_12, a workbook can only be protected by using

workbook.setProtected(true);

It can be read and edited without making it unprotected. We can not set a password on woorkbook. If a woorkbook is already password protected then by catching "PasswordException" user can be notified to remove password.

blackfyre
  • 2,549
  • 5
  • 39
  • 58