Necesito escribir un conjunto de resultados de más de 65000 filas en el archivo xlsx. Así que estoy tratando de usar Apache POI 3.7. Pero obtengo el error de OutOfMemoryError: espacio de pila de Java. ¿Cómo resuelvo este problema además de aumentar la memoria JVM que no parece resolver el problema? Por favor ayuda.Apache POI 3.7 OutOfMemoryError: espacio de pila de Java al escribir en un gran número de filas en archivos xlsx
simple código de ejemplo:
public static void main(String[] args) throws IOException {
Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
for (int i=0;i<65000;i++){
Row row = sheet.createRow((int) i);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
}
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("test1.xls");
fileOut.flush();
wb.write(fileOut);
fileOut.close();
}
Me pregunto si se puede eludir este problema escribiendo en un archivo CSV e importando a Excel 2007? –