使用Poi的HSSFWorkbook导出Excel大小限制,即内存溢出
2013-03-27 22:19
357 查看
这篇文章的主题是大致测试使用Poi的HSSFWorkbook到出Excel文件时,不在报内存溢出时能导出的最大的sheet与行数。
首先设置几个条件:
1.我们设置导出的excel内容如下:
,
这里有10列内容。对应代码如下:
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
row.createCell(4).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(5).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(6).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(7).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(8).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(9).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(10).setCellValue(createHelper.createRichTextString("This is a string"));
2.设置java运行内存(VM arguments)
-Xms64m -Xmx256m -XX:MaxPermSize=256m
最后测试最大行数在166772~166872之间。
导出结果截图如下:
以上就是本篇文章主题。
以下内容为批注:
如果想用HSSFWorkbook导出更大行数的excel。那需要设置更大的运行内存,最大行数取决你的运行虚拟内存。
例如:
修改VM arguments为“-Xms64m -Xmx512m -XX:MaxPermSize=512m“,那么能导出最大的行数在333680~331680之间。
首先设置几个条件:
1.我们设置导出的excel内容如下:
,
这里有10列内容。对应代码如下:
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
row.createCell(4).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(5).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(6).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(7).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(8).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(9).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(10).setCellValue(createHelper.createRichTextString("This is a string"));
2.设置java运行内存(VM arguments)
-Xms64m -Xmx256m -XX:MaxPermSize=256m
最后测试最大行数在166772~166872之间。
导出结果截图如下:
以上就是本篇文章主题。
以下内容为批注:
如果想用HSSFWorkbook导出更大行数的excel。那需要设置更大的运行内存,最大行数取决你的运行虚拟内存。
例如:
修改VM arguments为“-Xms64m -Xmx512m -XX:MaxPermSize=512m“,那么能导出最大的行数在333680~331680之间。
相关文章推荐
- poi使用HSSFWorkbook 导出excel
- 使用POI3.8导出大数据excel方法(解决内存溢出)
- org.apache.poi.hssf.usermodel.HSSFWorkbook 进行处理导出Excel操作
- 初试poi HssfWorkBook导出excel
- POI HSSFWorkbook导出excel
- HSSFWorkbook使用java代码导出excel
- poi导出Excel,HSSFWorkbook与XSSFWorkbook区别
- Jenke 使用apache的poi实现导入导出excel
- springMVC中使用POI方式导出excel至客户端、服务器实例
- hssfworkbook导出excel的问题
- 使用poi导入导出excel文件方法使用及改进
- Java中使用poi导入、导出Excel
- Java使用POI导出excel(上)——基本操作
- 使用Java POI导入导出Excel数据
- JAVA使用POI根据模版导出EXCEL
- Java中使用poi导入、导出Excel
- HSSFWorkbook导出excel
- 使用POI导出excel
- java使用poi从数据库导出Excel