Tuesday, January 7, 2014

Fastest Approach to Generate Excel File


The given jar fastexcel-0.5.1-2010-12-26.jar can write thousands of records into an excel file with in few seconds.

Here is the sample code:
public Static String fastExcelSample() {
File fileObj=new File("testFile.xls");
String contentData[]={"FAST","EXCEL","EXAMPLE","TEST"};
Workbook wb=FastExcel.createWriteableWorkbook(fileObj);
wb.open();
Sheet sheet=wb.addStreamSheet("SheetA");
sheet.addRow(contentData);
wb.close();
}
addRow() method adds the Row into the sheet.  For multiple rows we can iterate and add multiple rows.
contentData[ ]  can be an object, which holds all the cell values of row and then write it into Excel file.
I have used it, it could able to write 20,000 records(each record 40 columns) in less than 20sec time.
Please find the attached jar file.



https://drive.google.com/file/d/0B25humeDHAtFMmVsNHVmenBmc3c/edit?usp=sharing

No comments:

Post a Comment