I am trying to edit existing sheet,add new values to it and protect newly created workbook. From searching on net I came to know that sheet.protectSheet("some_password") is helpful. But in my case the compiler gives error that protectSheet method is not there. Then I tried using sheet.setProtect(true), but on execution it gives following error:
java.lang.NullPointerException
at org.apache.poi.hssf.usermodel.HSSFSheet.setProtect(HSSFSheet.java:890)
Here is my code:
FileInputStream fsIP= new FileInputStream(new File(request.getSession().getServletContext().getRealPath(".")+ "/Cheque Printing.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fsIP);
HSSFSheet worksheet = wb.getSheetAt(0);
Is the problem that I am accessing sheet via getSheetAt and not via createSheet ?