从excel表中导出数据

File file = new File(excelFileName);// excelFileName:文件地址

       InputStream stream;

       Workbook rwb = null;

       Cell cell = null;

       Sheet sheet = null;

       try {

           stream = FawenPlugin.class.getResourceAsStream("发文表.xls");

           // stream = new FileInputStream(file);

           rwb = Workbook.getWorkbook(stream);

       } catch (FileNotFoundException e) {

           // TODO Auto-generated catch block

           e.printStackTrace();

       } catch (BiffException e) {

           // TODO Auto-generated catch block

           e.printStackTrace();

       } catch (IOException e) {

           // TODO Auto-generated catch block

           e.printStackTrace();

       }

       // 读取主表excel表格的信息存入iolist

       System.out.println("---------------读取主表中的数据---------------");

       List<String[]> iolist = new ArrayList<String[]>();

       sheet = rwb.getSheet(0);

       for (int i = 1; i < sheet.getRows(); i++) {

           String[] str = new String[sheet.getColumns()];

           for (int j = 0; j < sheet.getColumns(); j++) {

              cell = sheet.getCell(j, i);

              str[j] = cell.getContents();

           }

           // 获得文件流里的内容

           iolist.add(str);

       }

posted @ 2016-04-20 10:30  青橙。  阅读(270)  评论(0编辑  收藏  举报