In order to prevent alteration of the data previously entered into an Excel worksheet but allow editing and additional data entry in the remaining empty spaces, I'm attempting to lock the data within the worksheet. I tried setting the cell style throughout the entire sheet using the code provided below, but it is only the pertinent code, therefore it doesn't work, which is consistent with the previously posed question.
Lock single column in Excel using Apache POI
XSSFCellStyle lockCell = getFileWriter().getWorkbook().createCellStyle();
lockCell.setLocked(true);
for(Row row : sheet){
for(Cell mycell : row){
mycell.setCellStyle(lockCell);
}
}
The exact opposite: I've tried locking the entire sheet and setting the cell styles for the relevant rows to unlock, but the cells without any data don't unlock, thus it doesn't work for me. In any event, how much space is required for the unknowable amount of data to be added, hence how far and wide should one unlock the cells?