首页 > 其他 > 详细

poi操作excel

时间:2018-01-18 21:42:38      阅读:219      评论:0      收藏:0      [点我收藏+]
    static void create(String path) throws Exception {

        //读取文件
        FileInputStream in = new FileInputStream(path);
        XSSFWorkbook wb = new XSSFWorkbook(in);
        // 获得该工作区的第一个sheet
        XSSFSheet sheet = wb.getSheetAt(0);
        int rowNum = sheet.getLastRowNum();//
        int columnNum = sheet.getRow(0).getPhysicalNumberOfCells();//
        System.out.println(rowNum + "条数据," + columnNum + "列");

        XSSFRow row;

        String bm;
        String mm;
        for (int i = 1; i <= rowNum; i++) {
            row = sheet.getRow(i);
            //读取值
            bm = (long) row.getCell(0).getNumericCellValue() + "";
            mm = jia(bm);
            //设置值
            row.getCell(4).setCellValue(mm);
            System.out.println(mm);
        }
        //另存为
        FileOutputStream out = new FileOutputStream("/Users/1111/Desktop/112000000.xlsx");
        //写出
        wb.write(out);
        out.close();
    }

 

poi操作excel

原文:https://www.cnblogs.com/chenglc/p/8313048.html

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