You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Josh Butterworth <jo...@msp-uk.com> on 2007/12/07 17:08:59 UTC

HSSFSheet.protectSheet(String Password) Wont lock all sheets - POI-3.0.2-BETA-1

Just trying out 3.0.2 I noticed that the new protectSheet method for HSSFSheet
doesn't seem to work on all sheets, my code to attempt to lock all sheets with
the password 'joshua' is as follows: 


		int numSheets = wb.getNumberOfSheets();
		for( int i = 0; i < numSheets; i++) {
			HSSFSheet sheet = wb.getSheetAt(i);
			sheet.protectSheet("joshua");
		}

This only seems to lock the first and last sheets in my work book.

Im working in workbook with 5 sheets where the first 4 are basically a template

that I dont touch in the Java, I just open the 5th sheet and dump a load of raw

numbers and text in to be interpreted and referenced by the first 4 sheets.

So I am able to successfully lock sheets 0 and 4 with the desired password, but

the other sheets all just appear as normal in excel as if no attempt to lock

them was ever attempted.

I've tried checking that all the sheets are being locked using the following 
code:

		for( int i = 0; i < numSheets; i++) {
			HSSFSheet sheet = wb.getSheetAt(i);

			logger.info(i + " " + sheet.getProtect());
			sheet.protectSheet("joshua");
			logger.info(i + " " + sheet.getProtect());
		}

Sure enough that tells me that the protect property changes from false to true

for all my sheets after the protectSheet method is run, but still in excel the

sheets appear as unlocked.

The only distinguishing factor about those the 3 middle sheets is that they all
contain charts.


Just in case it could be relevant: My platform is jboss-4.2.1.GA


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: HSSFSheet.protectSheet(String Password) Wont lock all sheets - POI-3.0.2-BETA-1

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 7 Dec 2007, Josh Butterworth wrote:
> Just trying out 3.0.2 I noticed that the new protectSheet method for 
> HSSFSheet doesn't seem to work on all sheets, my code to attempt to lock 
> all sheets with the password 'joshua' is as follows:

Can you open a bug report, and attached the problem file (both the 
original, unprotected version and the poi protected version)? It'd also be 
helpful to know if this is happening on all your 5 sheet files, or only 
some.

(We'll almost certainly need Andy, who wrote the protection code, to take 
a look, but I'm pretty sure he'll need all of that info)

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org