java读取excel

14年前
           try
           {
               InputStream is=new FileInputStream("E:/test.xls");
               //声名一个工作薄
                rwb= Workbook.getWorkbook(is);
               //获得工作薄的个数
               rwb.getNumberOfSheets();
               //在Excel文档中,第一张工作表的缺省索引是0
               Sheet st = rwb.getSheet("Table1");
               //通用的获取cell值的方式,getCell(int column, int row) 行和列
               int rows=st.getRows();
               int cols=st.getColumns();
               System.out.println("当前工作表的名字:"+st.getName());
               System.out.println("总行数:"+rows);
               System.out.println("总列数:"+cols);
             for(int i=1;i<rows;i++){
               Cell c1=st.getCell(0,i);
               Cell c2=st.getCell(1,i);
               Cell c3=st.getCell(2,i);
               println "卡号:${c1.getContents()}、密码:${c2.getContents()}、日期:${c3.getContents()}"
             }
           }
           catch(Exception e)
           {
               e.printStackTrace();
                System.out.println("出错了");
           }finally{
             rwb.close();
           }