Java Read/Write Excel – Error : The constructor XSSFWorkbook(FileInputStream) is undefined

apacheexceljarjava

enter image description hereI am trying to read data from an excel file, i am using the following code :

File src = new File("T:\\SeleniuminputFiles\\input.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet1 = wb.getSheetAt(0);

but i am getting the compilation error as The constructor XSSFWorkbook(FileInputStream) is undefined.

I have downloaded External Jar files from The latest stable release Apache POI 3.16 http://poi.apache.org/download.html#POI-3.16

Your help would be highly appreciated.

please find attached screenshot of code with output or error

Best Answer

Try using FileInputStream :

public void ReadExcel()
    {
       String excelFilePath = "D://Selenium Training//ExcelSearch//Configurations.xlsx";

       FileInputStream inputStream = new FileInputStream(new File(excelFilePath));

       Workbook workbook = new XSSFWorkbook(inputStream);

       Sheet firstSheet = workbook.getSheetAt(0);
    }
Related Topic