我試圖建立一個從Oracle到xlsx的報告,但是我的服務器凍結了。我這樣做:如何正確構建包含多行的xlsx文件?
int i = 0;
while (resultSet.next()) {
//Create a new row in current sheet
Row row = sheet.createRow(i);
//Create a new cell in current row
row.createCell(0).setCellValue(resultSet.getInt(1));
row.createCell(1).setCellValue(resultSet.getString(2));
row.createCell(2).setCellValue(resultSet.getString(3));
row.createCell(3).setCellValue(resultSet.getLong(4));
row.createCell(4).setCellValue(resultSet.getString(5));
row.createCell(5).setCellValue(resultSet.getString(6));
row.createCell(6).setCellValue(resultSet.getString(7));
row.createCell(7).setCellValue(resultSet.getString(8));
row.createCell(8).setCellValue(resultSet.getString(9));
row.createCell(9).setCellValue(resultSet.getString(10));
row.createCell(10).setCellValue(resultSet.getString(11));
row.createCell(11).setCellValue(resultSet.getLong(12));
i++;
}
FileOutputStream out = new FileOutputStream(new File("C:\\new.xls"));
wb.write(out);
out.close();
resultSet.close();
sqlStatment.close();
sqlConnection.close();
我的resultSet
有〜500 000行。我沒有錯誤。如何正確構建具有多行的xlsx文件?
您確實需要xlsx文件:是否可以替代生成CSV文件,然後將其導入到xlsx中使用Excel函數從文件中導入數據? – Willmore