如何从第二行获取数据

我正在试图获取数据基于标题在下面第一我geting第一行,并存储它在地图上的键。 但问题是我想从第二行获取数据,但我得到iterator.how我可以从第二行获取数据?

DataFormatter df=new DataFormatter(); Map<String,Integer> m=new HashMap<String,Integer>(); FileInputStream file = new FileInputStream(new File("/root/Documents/xyz.xlsx")); //Get the workbook instance for XLS file XSSFWorkbook workbook = new XSSFWorkbook(file); //Get first sheet from the workbook XSSFSheet sheet = workbook.getSheetAt(0); Row row=sheet.getRow(0); XSSFRow rowe = (XSSFRow)row; int s=row.getLastCellNum(); System.out.println(s); for(int i=0;i<s-1;i++){ String data= df.formatCellValue(rowe.getCell(i)); System.out.println(data); m.put(data,i); } Iterator<Row> rows = sheet.rowIterator(); while (rows.hasNext()) { XSSFRow rowa = (XSSFRow) rows.next(); System.out.println(df.formatCellValue(rowa.getCell(m.get("Member.Member Card Number")))); } 

这是你想要的 ?

  int count =0; while (rows.hasNext()) { XSSFRow rowa = (XSSFRow) rows.next(); if(count !=0){ System.out.println(df.formatCellValue(rowa.getCell(m.get("Member.Member Card Number")))); } count++; } 

尝试这样的事情

 Vector cellVectorHolder = new Vector(); XSSFSheet mySheet = myWorkBook.getSheetAt(0); Iterator rowIter = mySheet.rowIterator(); while(rowIter.hasNext()){ XSSFRow myRow = (XSSFRow) rowIter.next(); Iterator cellIter = myRow.cellIterator(); List list = new ArrayList(); while(cellIter.hasNext()){ XSSFCell myCell = (XSSFCell) cellIter.next(); list.add(myCell); } cellVectorHolder.addElement(list); }