0

I am trying to update some entries in existing excel sheet .Below is my code

 System.out.println("Update excel block");
         FileInputStream fsIP= new FileInputStream("C:\\Users\\SXR8036\\Downloads\\LANE-804.xls"); 
        // System.out.println(Path);
         System.out.println("Trying to update the file");
         HSSFWorkbook wb = new HSSFWorkbook(fsIP);//Access the workbook
         HSSFSheet worksheet = wb.getSheetAt(0);//Access the worksheet, so that we can update / modify it

         Cell cell = null;
         cell = worksheet.getRow(2).getCell(2);// Access the second cell in second row to update the value

         cell.setCellValue("OverRide Last Name");
         fsIP.close(); //Close the InputStream

         FileOutputStream output_file =new FileOutputStream(new File("C:\\Users\\SXR8036\\Downloads\\LANE-804.xls"));  //Open FileOutputStream to write updates

         wb.write(output_file); //write changes

         output_file.close();  //close the stream   

I am getting NUll pinter exception as error >i have read quite about null pointer exception now but not able to find a solution to this.

rishav kumar
  • 57
  • 2
  • 11
  • 1
    What is giving a null pointer? – bmarkham Mar 02 '16 at 08:36
  • Null pointer error occured during this step.Please look at objects used in this step. If error is due to page object, set 'ManagePOMObjects=true' if page object is set in previous step. Else initialize all page objects in BaseStepDefn class constructor. BaseStepDefn is where i have all my objects declared – rishav kumar Mar 02 '16 at 09:02
  • cell = worksheet.getRow(2).getCell(2); Check if the 3rd cell in 3rd row has any value or not.If it doesn't have a value,it will throw NullPointerException – S.B Mar 02 '16 at 09:38

0 Answers0