The problem I am facing arises whenever I am trying to obtain a cell. The funny part is that this function works fine till it reaches this part of the code.
        for (i = 1; i < 555; i++) 
        {           
            try
            {
                cell = sheet2.getRow(i).getCell(columnNo);              
            }
            catch (NullPointerException e)
            {               
                cell = sheet2.getRow(i).createCell(columnNo);
            }
            value = "NOT(ISERROR(MATCH(C" + (i + 1) + ",$N$2:$N$710,0)))";
            cell.setCellFormula(value);
        }
Because of try catch i get the error for createCell, but i believe that the problem lies at the line where i use getCell. I get the following error : Exception in thread "main" java.lang.NullPointerException
Just before this part, i have a for loop(pasted below) which works just fine.
        for (i = 1; i <= incorrect.size(); i++) {
            cell = sheet2.getRow(i).getCell(columnNo);
            if (cell == null)
                cell = sheet2.getRow(i).createCell(columnNo);
            value = incorrect.get(i - 1);
            cell.setCellValue(value);
        }
