/** to compile this java file, u need to download poi-src-2.5.1-final-20040804.jar and it should be in classpath. You can download this jar file from http://apache.mirrors.pair.com/jakarta/poi/release/src/ */ import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.util.*; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; public class POIHSSFMoreRows{ short colNo=0,rowNo=0; HSSFWorkbook wb=null; HSSFSheet sheet=null; HSSFRow row=null; HSSFCell cell=null; OutputStream outStream=null; public void print() throws Exception{ FileOutputStream fos=null; File f=null; try{ f=new File("sample.xls"); fos=new FileOutputStream(f); }catch(Exception e){ System.out.println("error while creating the file..."); } wb = new HSSFWorkbook(); sheet = wb.createSheet("MySheet1"); sheet.setColumnWidth((short)0,(short)(20*256)); //(colNo,width) : x*256=1 point in Excel int rowCount=1; int sheetNo=2; for(int rowNo=1;rowNo<=3000;rowNo++){ if(rowCount==1000){ sheet=wb.createSheet("MySheet"+sheetNo); sheetNo++; rowCount=1; } row=sheet.createRow(rowCount); for(short col=1;col<150;col++){ //cell=row.createCell((short)1); cell=row.createCell(col); cell.setCellValue("RowNo="+rowNo); //putValue("RowNo="+rowNo); } rowCount++; }//for(int rowNo=1;... wb.write(fos); fos.close(); } public static void main(String args[]) throws Exception{ POIHSSFMoreRows obj=new POIHSSFMoreRows(); obj.print(); }//main }//class