首页 > 其他 > 详细

从excel表中导出数据

时间:2016-04-20 11:16:54      阅读:167      评论:0      收藏:0      [点我收藏+]

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);

       }

从excel表中导出数据

原文:http://www.cnblogs.com/lzw0414/p/5411549.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!