用poi生成excel2007 创建XSSFWorkbook对象
Workbook workbook = new XSSFWorkbook(new FileInputStream(path));
Sheet sheet = workbook .createSheet("这里第一页");
FileOutputStream fos = new FileOutputStream("D://test//test0215.xlsx");
for (int i = 0; i < 100000; i++) {
sheet.createRow(i).createCell(0).setCellValue(1);
}
workbook .write(fos);[size=small]
fos.close();
上面测试例子,写入excel第一列,全为1,写入10w行,超过一定的数据量,比如10w,就会报“Exception in thread "main" java.lang.OutOfMemoryError: Java heap space” ,求解决方案????