Results 1 to 12 of 12
Like Tree4Likes
  • 1 Post By gimbal2
  • 1 Post By Tolls
  • 1 Post By Tolls
  • 1 Post By Tolls

Thread: is it possible to proctect entire excel HSSF Workbook using apache POI ?

  1. #1
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Hi Team,

    We are generating 3 sheets( sheet1,sheet2,sheet3) in excel workbook using POI. We are able to protect sheet but we are not able to protect the entire workbook using POI.
    But in MSExcel there is a feature to protect entire workbook . is workbook protection possible through POI?

    My actual requirement is like :
    I am hiding one sheet (sheet2), so if user will download excel he will get excel workbook with two sheets (sheet1,sheet3) visible and one sheet (sheet2) hidden .
    I don't want the user to see sheet2.I want to disable UNHIDE option in the downloaded excel workbook so that the user thinks that there are only two sheets (sheet1,sheet2).
    APPROACH 1: If we protect the entire workbook it will disable HIDE ,UNHIDE options . is it possible using APACHE POI ?
    Is there any other approach to solve this ??
    Last edited by raviteja saddala; 09-24-2013 at 10:20 AM. Reason: giving more description thread

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,083
    Rep Power
    4

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    I know little about POI from memory, its been years since I used it. I see your question and figure out the answer in 10 seconds.

    Step 1: go to the API. Google found it for me in a couple of seconds. POI API Documentation
    Step 2: scan method list of HSSFWorkbook

    Guess what: there is a method in there that matches your description. I'll leave it as an exercise for you to find it.
    Last edited by gimbal2; 09-24-2013 at 09:36 AM.
    PhHein likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Quote Originally Posted by gimbal2 View Post
    I know little about POI from memory, its been years since I used it. I see your question and figure out the answer in 10 seconds.

    Step 1: go to the API. Google found it for me in a couple of seconds. POI API Documentation
    Step 2: scan method list of HSSFWorkbook

    Guess what: there is a method in there that matches your description. I'll leave it as an exercise for you to find it.
    Hi Gimbal,
    Thanks for reply .
    I tried with hssfWorkBook.writeProtectWorkbook("test", "test"); to protect the entire workbook .
    It is no longer working ..
    Cold you suggest any other approach which suites my requirement ..

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,083
    Rep Power
    4

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    If it doesn't work as documented there is a bug there which should be reported. But only if you are using the latest version of POI.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    You could always make the hidden sheet very hidden instead.
    raviteja saddala likes this.
    Please do not ask for code as refusal often offends.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,083
    Rep Power
    4

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Quote Originally Posted by Tolls View Post
    You could always make the hidden sheet very hidden instead.
    yeah, by removing it. I'd just provide two downloads; one for the gods with all sheets, one for the people with only the two sheets. Why make life any more difficult than it should be.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Excel does have a "very hidden" thing for sheets.
    You can only unhide them with VB.
    The setSheetHidden has two version, the basic one with the boolean (hidden/unhidden), and the other one with an int for one of the following states:
    SHEET_STATE_VISIBLE
    SHEET_STATE_HIDDEN
    SHEET_STATE_VERY_HIDDEN
    raviteja saddala likes this.
    Please do not ask for code as refusal often offends.

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,083
    Rep Power
    4

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    I win! Using my way you can't even do it using VB ;)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Unless the hidden sheet contains all the calculations etc that are used on the visible ones...:)
    Please do not ask for code as refusal often offends.

  10. #10
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Thanks Tolls,

    "very hidden" is working fine . Unhide option is disabled .

    is there any way to see the " very hidden" sheet ?

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    As I said, VB.
    Exactly how, I don't know.
    raviteja saddala likes this.
    Please do not ask for code as refusal often offends.

  12. #12
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: is it possible to proctect entire excel HSSF Workbook using apache POI ?

    Hi Tolls,
    I have tried VB . It is working fine .
    Thanks for your reply ..

Similar Threads

  1. Java to Open Excel Workbook
    By jo15765 in forum New To Java
    Replies: 11
    Last Post: 08-09-2013, 04:55 PM
  2. Replies: 3
    Last Post: 06-28-2012, 12:33 PM
  3. I am getting problem read excel file with 30000 rows using hssf
    By satyendra.kumar in forum Advanced Java
    Replies: 4
    Last Post: 06-29-2011, 02:43 PM
  4. Open an Excel workbook
    By ch7787 in forum New To Java
    Replies: 5
    Last Post: 07-20-2010, 05:20 PM
  5. APACHE HSSF on Netbeans
    By dgajudo in forum NetBeans
    Replies: 2
    Last Post: 12-10-2007, 04:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •