Reputation: 4815
I am creating a excel sheet from java program and user can update the excel sheet. I will read the same excel file from another program.
I want to restrict a user from deleting a cell from excel sheet. Can I achieve the same in Java? I searched over internet but I didn't get any solution for this.
The same thing may possible using VBA scripts but I want solution for this in java.
Upvotes: 1
Views: 228
Reputation: 15872
Make the sheet-protection is what you are looking for, see Sheet.protectSheet():
Workbook wb = ...
Sheet sheet = wb.createSheet();
assertFalse(sheet.getProtect());
sheet.protectSheet("Test");
assertTrue(sheet.getProtect());
sheet.protectSheet(null);
assertFalse(sheet.getProtect());
wb.close();
Upvotes: 2