我只是尝试从具有正确数据的Excel工作表中读取数据,然后使用迭代器将数据存储在数组列表中。代码没有错误。但它在运行时抛出错误。
public ArrayList<String> ReadExcelData(int ColNo) throws IOException
{
FileInputStream fis = new FileInputStream("D:\\selenium\\GokulSheet2.xlsx");
XSSFWorkbook Wb = new XSSFWorkbook(fis);
XSSFSheet s = Wb.getSheet("Sheet1");
Iterator<Row> RowIt = s.iterator();
RowIt.next();
ArrayList<String> list = new ArrayList<String>();
while(RowIt.hasNext())
{
list.add(RowIt.next().getCell(ColNo).getStringCellValue());
}
//Wb.close();
System.out.println("List::"+list);
return list;
}
public static void main(String[]args) throws IOException, InterruptedException
{
POIXcell F = new POIXcell(); // POIXcell is class name
F.ReadExcelData(0);
}
}