I have created Script for Read data from excel file, but it gives me error like "C:\testdata.xls (The system cannot find the file specified)". Please Hple. This is my code.
FileInputStream file = new FileInputStream(new File ("C:\\testdata.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
String heading = sheet.getRow(0).getCell(0).getStringCellValue();
String searchText1 = sheet.getRow(1).getCell(0).getStringCellValue();
String searchText2 = sheet.getRow(2).getCell(0).getStringCellValue();
System.out.println("Heading is:" + heading);
System.out.println("Search Text 1 is:" + searchText1);
System.out.println("Search Text 2 is:" + searchText2);
file.close();
You can verify if the path is correct or not by creating file as
new File ("C:\\testdata.xls")
Then print the absolute path. Check if it is a valid path.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments