poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MSB <markbrd...@tiscali.co.uk>
Subject Re: DO NOT REPLY [Bug 48900] XSSF doesn't have the method protectSheet as we have for HSSF API
Date Mon, 15 Mar 2010 17:45:14 GMT

Yep, that works.

All I did was;

1. Open Excel - Excel 2007 in my case.
2. Create a new blank workbook.
3. Click on the Review menu option and select Protect Sheet. I did not
bother selecting any other of the check boxes in that list, just left the
top two selected.
4. Typed in a password and then confirmed that password.
5. Saved the file as a normal Excel 2007 workbook with the .xlsx extension.
6. Closed the workbook.

Then I simply opened up my IDE and typed in the following code;

public static void main(String[] args) {
        File inputFile = null;
        File outputFile = null;
        FileInputStream fis = null;
        FileOutputStream fos = null;
        XSSFWorkbook workbook = null;
        XSSFSheet sheet = null;
        XSSFRow row = null;
        XSSFCell cell = null;
        XSSFCellStyle style = null;
        try {

            inputFile = new File("C:/temp/Protected Workbook.xlsx");
            fis = new FileInputStream(inputFile);
            workbook = new XSSFWorkbook(fis);


            style = workbook.createCellStyle();

            sheet = workbook.getSheetAt(0);
            row = sheet.createRow(0);
            cell = row.createCell(0);

            outputFile = new File("C:/temp/Populated Protected
            fos = new FileOutputStream(outputFile);

        catch(IOException ioEx) {
            System.out.println("Caught an: " + ioEx.getClass().getName());
            System.out.println("Message: " + ioEx.getMessage());
            System.out.println("Stacktrace follows:.....");
        finally {
            if(fos != null) {
                try {
                catch(IOException ioEx) {
                    // Ignore - too late to recover anything now.

Compiled it, ran it and then opened the newly created workbook - I called it
Populated Protected Workbook.xlsx and saved it that way to enable me to
reuse the template - using Excel and simply tried to modify cell A1, it
would not allow me to do so as the cell was locked and the sheet password

The only drawback with this method is that you will need to know in advance
how many sheets your workbook should contain and then you will need to
create a template with that number of sheets and protect each and every
sheet in the workbook. That is the only problem as far as I can see.


Mark B

Bugzilla from bugzilla@apache.org wrote:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=48900
> --- Comment #2 from viveckrshastri@gmail.com 2010-03-15 15:29:19 UTC ---
> (In reply to comment #1)
>> Please don't abuse Bugzilla. Changing the priority of a bug to Blocker
>> will not
>> help us to fix it sooner. 
>> If you are really interested in fixing this issue - you are welcome to do
>> a
>> research and figure out which bits of the SpreadsheetML are missing. If
>> you
>> need a
>> guidance, please ask, I will be happy to help.
>> Yegor
> Hey Yegor,
> we have the same method sheet.protectSheet("qq"); in the HSSF API and i
> need
> the same for XSSF API.
> Let me know if there is any workaround in XSSF API to protect worksheet
> with a
> password.
> This a kind of show stopper for my project currently. Any help is
> appreciated.
> Thanks,
> Vivek
> -- 
> Configure bugmail:
> https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org

View this message in context: http://old.nabble.com/DO-NOT-REPLY--Bug-48900--New%3A-XSSF-doesn%27t-have-the-method-protectSheet-as-we-have-for-HSSF-API-tp27878972p27907823.html
Sent from the POI - Dev mailing list archive at Nabble.com.

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

View raw message