我拆过的坑cycx

查询一下!

POI-处理大EXCEL文件 00M

 

package cn.51crh.web;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;

public class excelmils {
    public static void main(String[] args) throws IOException {
        XSSFWorkbook wb = new XSSFWorkbook();

        XSSFSheet sheet = wb.createSheet("sheet1");
        for (int i = 0; i < 5520; i++) {

            XSSFRow row = sheet.createRow(i);

            XSSFCell cell = row.createCell(0);
            // 给Excel的单元格设置样式和赋值
            cell.setCellValue("第?行"+i);

            FileOutputStream os = new FileOutputStream("d:\\workbook.xlsx");
            wb.write(os);
            os.close();
        }
    }
}

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-BlogPHP 1.7.3

Copyright Your WebSite.Some Rights Reserved.