Bug 22568

Summary: Files created w. POI 2.02/2.03 crashes excel if rows > 1800
Product: POI Reporter: vijay_alluri
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 2.0-pre3   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: java test file to generate excel
java test file to generate excel

Description vijay_alluri 2003-08-19 22:35:04 UTC
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()) ;
		}
	}

}
Comment 1 vijay_alluri 2003-08-20 22:07:18 UTC
Created attachment 7908 [details]
java test file to generate excel
Comment 2 vijay_alluri 2003-08-20 22:12:27 UTC
Created attachment 7909 [details]
java test file to generate excel
Comment 3 vijay_alluri 2003-08-20 22:17:53 UTC
Ignore 1st attachment (id=7908)
Comment 4 Avik Sengupta 2003-10-06 09:46:55 UTC

*** This bug has been marked as a duplicate of 15375 ***