I can offer a guess using XSSF:
sheet1.protectSheet("defaultPWXYZ");
wb.lockStructure();
((XSSFSheet) sheet1).enableLocking();
((XSSFSheet)
sheet1).getCTWorksheet().getSheetProtection().setFormatCells(false);
I use similar code to open up my sheet for inserts (setInsertRows).
Navin Kumar <[email protected]>
2012-05-22 09:10 AM
Please respond to
"POI Users List" <[email protected]>
To
"[email protected]" <[email protected]>,
cc
Subject
Formatting a locked cell in a protected worksheet
Hi All,
I am new to Apache POI HSSF. I want to create an excel document in which
few cells would be locked and the worksheet would be protected with a
password. But I would want to allow formatting on the locked cell like
striking out & changing font. How do I accomplish this?
Below is my code to lock the cell & protect the worksheet
HSSFCellStyle lockedStyle = workbook.createCellStyle();
lockedStyle.setLocked(true);
HSSFRow row1 = firstSheet.createRow(0);
HSSFCell cell = row1.createCell(0);
cell.setCellValue(new HSSFRichTextString("Test"));
cell.setCellStyle(lockedStyle);
firstSheet.protectSheet("test");
Thanks & Regards
Navin
________________________________
LEGAL NOTICE Unless expressly stated otherwise, this message is
confidential and may be privileged. It is intended for the addressee(s)
only. Access to this e-mail by anyone else is unauthorized. If you are not
an addressee, any disclosure or copying of the contents of this e-mail or
any action taken (or not taken) in reliance on it is unauthorized and may
be unlawful. If you are not an addressee, please delete this e-mail and
inform the sender immediately.
APTUIT Informatics with its principal place of business at Plot No.
100-103, Export Promotion Industrial Park, Whitefield, Bangalore 560066.