Files created w. POI 2.02/3 crashes excel if rows > 1800 Here is the sample code: Working fine with POI 1.51/1.8 import java.io.* ; import org.apache.poi.hssf.usermodel.* ; import org.apache.poi.hssf.util.*; public class exceltest { public static void main(String[] args){ if(args.length < 2){ System.out.println("Please pass rows and cols"); return; } process_request(Integer.parseInt(args[0]),Integer.parseInt(args [1])) ; } public static void process_request(int r, int c) { System.out.println("Excel Rows:" + r + ", Cols:" + c); HSSFWorkbook wb = new HSSFWorkbook() ; HSSFSheet sheet = wb.createSheet("ExcelTest") ; int col_cnt=0, rw_cnt=0 ; col_cnt = c;//Integer.parseInt(request.getParameter ("COLUMN_CNT")) ; rw_cnt = r;//Integer.parseInt(request.getParameter("ROW_CNT")) ; HSSFRow rw = null ; HSSFCell cell =null; rw = sheet.createRow((short)0) ; //Header row for(short j=0; j<col_cnt; j++){ cell = rw.createCell((short)j) ; cell.setCellValue("Col " + (j+1)) ; } for(int i=1; i<rw_cnt; i++){ rw = sheet.createRow((short)i) ; for(short j=0; j<col_cnt; j++){ cell = rw.createCell((short)j) ; cell.setCellValue("Row:" + (i+1) + ",Column:" + (j+1)) ; } } sheet.setDefaultColumnWidth((short) 18) ; System.out.println("Excel Object Created" ); try { FileOutputStream out = new FileOutputStream ("test.xls") ; wb.write(out) ; out.close() ; System.out.println("Excel write to File :"); } catch(IOException io_Excp) { System.out.println(io_Excp.getMessage()) ; } } }
Created attachment 7908 [details] java test file to generate excel
Created attachment 7909 [details] java test file to generate excel
Ignore 1st attachment (id=7908)
*** This bug has been marked as a duplicate of 15375 ***