Paroksh Saxena Paroksh Saxena - 1 year ago 192
Java Question

Apache POI : creating unprotected cells by default on a protected sheet

When I am creating protected sheets using Apache POI, all cells are protected by default. I have to unlock each cell individually. Is it possible to protect a sheet will all cells unprotected by default (so that I protect only cells why I want).

(code used)

/*for sheet protection*/
/*creating style to unlock cell */
CellStyle unlockedCellStyle = workbook.createCellStyle();

/*applying unlock style to cell */

Answer Source

It is not possible to have created cells default to unlocked; locked is the default. But you are on the right track by creating a CellStyle with locked set to false. Make sure that you set locked to false on any and all of your new CellStyle objects that you want to be unlocked. Additionally, Excel has a limit on the number of cell styles that can be created in a Workbook, so re-use your CellStyle object(s) with each Cell you create.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download