POI读取excel文件

原创
2015/01/09 11:59
阅读数 38

http://poi.apache.org/spreadsheet/

           HSSFWorkbook wb = null;
           POIFSFileSystem fs = null;
           try {
             fs = new POIFSFileSystem(new FileInputStream(ExcelFile));
             wb = new HSSFWorkbook(fs);
           } catch (IOException e) {
             e.printStackTrace();
           }

           HSSFSheet sheet = wb.getSheetAt(0);
           
           Iterator<Row> iterator = sheet.rowIterator();
           iterator.next();
           while(iterator.hasNext()){
               HSSFRow row = (HSSFRow)iterator.next();
               HSSFCell gameCell = row.getCell(0);
               HSSFCell packageCell = row.getCell(1);
               String gameName = gameCell.getStringCellValue(); 
               gameName = gameName.trim();
               String packageName = packageCell.getStringCellValue(); 
               packageName=packageName.trim();  System.out.println(gameName);
         }



展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部