I am doing some Java code on XLS files using the POI libraries. I am trying to set some sheets as very hidden so users cannot access them at all.
Definition of very hidden sheet
http://www.kiranjholla.com/myblog/2010/03/the-very-hidden-sheet-in-excel.html
Code
// Creates and hides a sheet
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
HSSFSheet hiddenSheet = workbook.createSheet(sheetName);
workbook.setSheetHidden(workbook.getSheetIndex(sheetName), HSSFWorkbook.SHEET_STATE_VERY_HIDDEN);
Problem
Unfortunately, when I open the generated Excel files, the sheets I am trying to hide are displayed as hidden, but the users can still access them using the Format -> Sheet -> Show option.
Thanks for any help.
If you dont want your sheet to be accessed by user you must password protect it before setting it very hidden:
workbook.getSheetAt(0).protectSheet("abc");
workbook.setSheetHidden(0, HSSFWorkbook.SHEET_STATE_VERY_HIDDEN);
Hope it may help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With