POI Blattschutz Passwort

Status
Nicht offen für weitere Antworten.

Tom4712

Mitglied
Hallo,

ich hab ein Problem mit dem Verwenden des Blattschutzes. Den Blattschutz selbst aktivieren klappt schon, indem ich mit Hilfe einen HSSFCellStyle Objekt zuerst eine Zelle sperre:

Code:
HSSFCellStyle style = wb.createCellStyle();
style.setLocked(!editable);

Anschließend wird der Schutz noch für das Sheet aktiviert.

Code:
sheet.setProtect(true);

Danach ist der Blattschutz aktiv und die Zelle kann auch nicht mehr bearbeitet werden. Der Schutz kann allerdings vom Anwender einfach wieder aufgehoben werden weill kein Passwort gesetzt ist. Kann mir irgendwer sagen wie ich mit POI das Passwort für den Blattschutz setzen kann?
 
G

Gast

Gast
Mr. Oben,

I dont understand much German. But I think you want to activate few cells and not all.

For that you did the right thing. But now you have to set all cells.

If you want to protect a cell:
HSSFCellStyle style = wb.createCellStyle();
style.setLocked(true);
If you dont want to protect them than:
HSSFCellStyle style = wb.createCellStyle();
style.setLocked(false);

at the end you can set the sheet.setProtected(true);

This will only set those set to protected for which the style is set to true.

Regards,
Vinit
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen

Ähnliche Java Themen

Neue Themen


Oben