title: java.lang.NullPointerException error after reading data from Excel using Apache poi
body: <p>In the following below code after reading data from Excel when I try to insert that field value in to UI textbox it is throwing error as <code>java.lang.nullpointerexception</code>.</p>
  
  <p>In the below code when I try to read the values from Excel by keeping syst.out it is showing me the correct values.</p>
  
  <p>I am facing issue at this piece of code</p>
  
  <pre><code>      Cell=ExcelWSheet.getRow(1).getCell(0);
        Cell1=ExcelWSheet.getRow(1).getCell(1);
  
        String Celldata=Cell.getStringCellValue();
        String Celldata1=Cell1.getStringCellValue();
        System.out.println(Celldata);
        System.out.println(Celldata1);
        System.out.println("username value");
        Thread.sleep(2000);
        ****driver.findElement(By.id("Email")).sendKeys(Celldata);
  </code></pre>
  
  <p>I am getting syst.out for Celldata and Celldata1 and then after when I am trying to insert the Celldata value to Email field am getting this error.</p>
  
  <p>My complete code:      </p>
  
  <pre><code>public class NewTest {
  
   public WebDriver driver;
  
   private static XSSFSheet ExcelWSheet;
  
      private static XSSFWorkbook ExcelWBook;
  
      private static XSSFCell Cell;
      private static XSSFCell Cell1;
  
      private static XSSFRow Row;
  
  @Test
  public void f() throws Exception {
   // This method is to set the file path and open the excel file
  
    try{
    WebDriver driver=new FirefoxDriver();
    //driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    driver.get("http://gmail.com");
    Thread.sleep(3000);
    FileInputStream Excelfile=new FileInputStream("D:\\TestData\\Login.xlsx");
    ExcelWBook=new XSSFWorkbook(Excelfile);
    ExcelWSheet=ExcelWBook.getSheet("Sheet1");
  
    } catch (Exception e){
        throw(e);
    }
  
  // This code is used to read data from excel file
  
    try{
  
        Cell=ExcelWSheet.getRow(1).getCell(0);
        Cell1=ExcelWSheet.getRow(1).getCell(1);
  
        String Celldata=Cell.getStringCellValue();
        String Celldata1=Cell1.getStringCellValue();
        System.out.println(Celldata);
        System.out.println(Celldata1);
        System.out.println("username value");
        Thread.sleep(2000);
        ****driver.findElement(By.id("Email")).sendKeys(Celldata);
        driver.findElement(By.id("next")).click();
  
        driver.findElement(By.id("Passwd")).sendKeys(Celldata1);****
  
  
    }catch (Exception e){
        throw(e);
    }
  
   // This code is used to write data to the excel sheet
  
    try{
  
        Row=ExcelWSheet.getRow(1);
        Cell=Row.getCell(2,Row.RETURN_BLANK_AS_NULL);
        if(Cell==null){
  
            Cell=Row.createCell(2);
            Cell.setCellValue("Pass");
  
            FileOutputStream fileout=new FileOutputStream("Login.xlsx");
            ExcelWBook.write(fileout);
            fileout.flush();
            fileout.close();
            }}catch(Exception e){
            throw(e);
  
  
        }
  </code></pre>