HI Every one
Iam using POI in my application.I have 76281 records.It took more
than an 1 hour.Iam not sure,being unpatient i stopped running it iam sure
some thing is wrong .Iam pasting my code here by.
Can any one help me out please
public class NewWorkbook
{
public static void main(String[] args)
throws Exception
{
CustomerProfileDAO cDAO=new CustomerProfileDAO();
TestExcelDAO tDAO=new TestExcelDAO();
List excelList=(List)tDAO.getExcelReport();
System.out.println("list size"+excelList.size());
String fields[][]={ {"shipperCode","Shipper",""},
{"packageQuantity","Quantity",""},
{"billOptionDesc","Bill Option",""},
{"netAmount","Net Charges",""},
{"incentiveAmount","Discount",""},
{"trackingNumber","Tracking Number",""},
{"billedWeight","Billed Weight",""},
{"enteredWeight","Actual Weight",""},
{"billedWeightUnitOfMeasure","Measure",""},
{"billedWeightType","Weight Type",""},
{"packageDimensions","Pack Dim",""},
{"zone","Zone",""},
};
NewWorkbook newWorkbook=new NewWorkbook();
OutputStream f2 = new FileOutputStream("D:/POI/testing.xls");
newWorkbook.makeExcel(excelList,fields,f2 );
f2.close();
}
public void makeExcel(List l,String fields[][],OutputStream out) throws
Exception
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
HSSFRow r = null;
HSSFCell c = null;
HSSFCellStyle cs = wb.createCellStyle();
HSSFDataFormat df = wb.createDataFormat();
HSSFCellStyle special = wb.createCellStyle();
HSSFCellStyle csDate = wb.createCellStyle();
HSSFFont f = wb.createFont();
f.setFontHeightInPoints((short) 12);
f.setColor( (short)0xc );
f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
cs.setFont(f);
wb.setSheetName(0, "HSSF Test1",
HSSFWorkbook.ENCODING_COMPRESSED_UNICODE );
Iterator it =l.iterator();
int maxCount=65000;
short fieldSize=0;
Urgent::POI is too slow for generating excel for more than 60000 rows
int rownum=0;
r = s.createRow(rownum++);
for(short j=0;j<fields.length;j++)
{
c=r.createCell(j);
c.setCellValue(fields[j][1]);
c.setCellStyle(cs);
}
IBean iBean=null ;
boolean flag=true;
while(it.hasNext())
{
r = s.createRow(rownum++);
iBean = (IBean)it.next();
if(rownum>=maxCount && flag)
{
flag=false;
s= wb.createSheet();
wb.setSheetName(1, "HSSF Sheet2",
HSSFWorkbook.ENCODING_COMPRESSED_UNICODE );
rownum=0;
}
// System.out.println("rownum="+rownum);
for(short i=0;i<fields.length;i++)
{
try
{
Object
value=PropertyUtils.getNestedProperty(iBean,fields[i][0]);
s.autoSizeColumn((short)i);
if(value == null)
value=""; // initialize the null values to empty.
c=r.createCell((short)i);
c.setCellValue( (value).toString() );
}
catch(Exception ex)
{
throw ex;
}
}
}
wb.write(out);
}
}
--
View this message in context:
http://www.nabble.com/Urgent%3A%3APOI-is-too-slow-for-generating-excel-for-more-than-60000-rows-tp17646122p17646122.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]