Apache POI導出Excel

// keep 100 rows in memory, exceeding rows will be flushed to disk測試

 // SXSSFWorkbook.DEFAULT_WINDOW_SIZE == 100this

//SXSSFWorkbook 不支持Excel 2003版本excel

SXSSFWorkbook workBook = new SXSSFWorkbook(SXSSFWorkbook.DEFAULT_WINDOW_SIZE);it

Row row = null;file

Cell cell = null;im

Sheet sheet = wb.createSheet();數據

long start = System.currentTimeMillis();di

for(int i = 0;i < 1000000;i++){時間

    //親自測試excel中的一個sheet可以存放下100萬條數據,若是數據量更大能夠考慮使用多個sheetmemory

    row = sheet.createRow(i);

    cell = row.createCell(0);

    cell.setCellValue("a" + i);

    //System.out.println(i);

}

FileOutputStream out = new FileOutputStream("E:\\a.xlsx");

wb.write(out);

out.close();

// dispose of temporary files backing this workbook on disk

wb.dispose();

//花費2秒左右時間,固然我每行只建立了一個單元格,建立多個單元格時間可能會增長

System.out.println("花費:" + (System.currentTimeMillis() - start) + "毫秒");

相關文章
相關標籤/搜索