0
package Work;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.net.NetworkUtils;

public class excelData {
    static FileInputStream fis;
    static Workbook wb;

    public static void main(String[] args) throws EncryptedDocumentException, InvalidFormatException, IOException {
        try {
            fis = new FileInputStream("C:\\Users\\user\\Desktop\\Selenium.xlsx");

            wb = WorkbookFactory.create(fis);
            Sheet sh = wb.getSheet("Input");
            Row rw = sh.getRow(2);
            Cell cs = rw.getCell(2);
            String a = cs.getStringCellValue();
            System.out.println(cs);
        } catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("NULL");
        }

    }






}

i am getting nullpointer exception in this basic code. You can see my excel sheet.Excel Image

Can you please guide me through this. java.lang.NullPointerException at Work.excelData.main(excelData.java:29)

Sidhant
  • 675
  • 1
  • 7
  • 13
  • You should spend some time learning how to debug simple scripts. If you look at [ask] at the bottom of the page is one link. You can also probably find help with this in the help topics of the IDE that you use. – JeffC Jan 14 '17 at 17:35
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – JeffC Jan 14 '17 at 17:36

0 Answers0