i wrote a program to retrieve data from DB to many excel sheets.but it shows one sheet only remaining excel sheets r created but it doent show..but db retrieved
im getting db from different servers..
im using jsp and mysql..HSSWorkBook
can any one help me its very urgent..
dis is my code....
<%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.text.*" %> <%@ page import="java.io.*"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%> <%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%> <%@ page import="org.apache.poi.poifs.filesystem.POIFSFileSystem"%> <html> <body> <table border=1> <tr><td>sno</td><td>mobileno</td><td>digit entered</td><td>time of call</td><td>app name</td></tr> <% try { ResultSet rs2=null,rs1=null; Connection con; Statement stmt,st; Format f,f1; String s=""; String ckt[]={"ahm","jai","ban","chen","del","ludh","lnow","gwa","del2","kol","ran"}; int i=0;int p=0,in=3,hy=0; java.util.Date date = new java.util.Date(); String d=(date.getDate())+"-"+(date.getMonth()+1)+"-"+(date.getYear()+1900); out.println(d); f = new SimpleDateFormat("d-M-yyyy"); HSSFWorkbook hyd=new HSSFWorkbook(); Class.forName("org.gjt.mm.mysql.Driver"); String ip[]={" urls here"}; for(int ii=0;ii<10;ii++) { HSSFSheet sd=hyd.createSheet(ckt[ii]); HSSFRow hr =sd.createRow((short)2); hr.createCell((short) 0).setCellValue("SNo"); hr.createCell((short) 1).setCellValue("MobileNo"); hr.createCell((short) 2).setCellValue("DigitEntered"); hr.createCell((short) 3).setCellValue("Time Of Call"); hr.createCell((short) 4).setCellValue("Appname"); String url="jdbc:mysql://"+ip[ii]+"/vas1"; con=DriverManager.getConnection(url,"telecanor","outbound"); st=con.createStatement(); stmt=con.createStatement(); rs1=stmt.executeQuery("select distinct toCall,rtime,datagot,xml from obcallss where datagot<>'' order by rtime"); while(rs1.next()) { long ss=rs1.getLong(2); java.util.Date dat = new java.util.Date(ss); s=f.format(dat); f1 = new SimpleDateFormat("dd-M-yyyy hh:mm::ss"); if(s.equals(d)) { HSSFRow row =sd.createRow((short)in); row.createCell((short) 0).setCellValue(hy++); row.createCell((short) 1).setCellValue(rs1.getString(1)); row.createCell((short) 2).setCellValue(sd1); row.createCell((short) 3).setCellValue(rs1.getString(3)); row.createCell((short)4).setCellValue(rs1.getString(4)); } in++; } FileOutputStream fileOut = new FileOutputStream("d:\\prasad\\rep.xls"); hyd.write(fileOut); fileOut.close(); rs1.close(); con.close(); } out.println("report generated..."); } catch(Exception e) { out.println(e); } %> </table> </body> </html>