// 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) + "毫秒");