I'm trying to write a java class that computes the age of the person by getting his/her birth year on excel file. I was successful in computing it and displaying the age on console using System.out.print(age);
, however, I'm getting java.lang.NullPointerException
on cell.setCellValue(age);
Here's a snippet of my code:
int year = Calendar.getInstance().get(Calendar.YEAR);
int age;
for(int i = 0; i < birthdate.size(); i++){
String bday = birthdate.get(i).toString();
String y = bday.substring(7, 11);
age = year - Integer.parseInt(y);
cell = sheet.getRow(i+1).getCell(5);
cell.setCellValue(age);
System.out.print(cell + " \t ");
}