Hi, I am using poi3.8 and generating excel files of type xls and xlsx. the generated files will have some locked cells and some unlocked cells where user can enter data into the unlocked cells. The locking works fine for both xls and xlsx file types with cell styles. But user can unprotect the sheet by clicking on review tab and unprotect sheet option. And password locking is working only for xls type and if i apply password to xlsx type the file getting corrupted. any idea why? please suggest a solution.
And also even after locking the files, user can insert or delete sheets. How to restrict the user from modifying sheets? The following is the code i am using to lock the workbooks: if(isXls){ ((HSSFSheet)sheet).protectSheet(ResBundleHelper.getAppPropertyValue("sheet.password")); }else if (isXlsx) { XSSFSheet xssfSheet = (XSSFSheet) sheet; xssfSheet.lockDeleteColumns(); xssfSheet.lockDeleteRows(); xssfSheet.lockFormatCells(); xssfSheet.lockFormatColumns(); xssfSheet.lockFormatRows(); xssfSheet.lockInsertColumns(); xssfSheet.lockInsertRows(); xssfSheet.enableLocking(); //xssfSheet.protectSheet(ResBundleHelper.getAppPropertyValue("sheet.password")); ((XSSFWorkbook) workbook).lockStructure(); ((XSSFWorkbook) workbook).lockWindows(); } Thanks & Regards, Madhavi. -- View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-protect-xlsx-files-with-a-password-tp5710752.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@poi.apache.org For additional commands, e-mail: user-h...@poi.apache.org