Note that there are some explanatory texts on larger screens.

plurals
  1. POcreate an excel sheet and insert data from database
    text
    copied!<pre><code>response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet "); response.setHeader("Content-Disposition", "attachment;filename=\"j.xls\" "); //int ch=Integer.parseInt(request.getParameter("id")); Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String url = "jdbc:sqlserver://"; Connection con = DriverManager.getConnection(url,"sa","sql1423#3"); Statement stmt = con.createStatement(); HSSFWorkbook hwb=new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("new sheet"); HSSFSheet sheet1 = hwb.createSheet("new sheet1"); HSSFRow rowhead= sheet.createRow((short)0); String select[] = request.getParameterValues("id"); if (select != null &amp;&amp; select.length != 0) { for (int i = 0; i &lt; select.length; i++) { //out.println(select[i]); int ch=Integer.parseInt(select[i]); switch(ch) { case 1 : rowhead.createCell((short) 0).setCellValue("INDEX_FLG"); ResultSet rs=stmt.executeQuery("select INDEX_FLG from FFIX"); while(rs.next()) { rowhead.createCell((short) 0).setCellValue(rs.getString("INDEX_FLG")); //out.println(rs.getString("INDEX_FLG")); } rs.close(); break; case 2 : rowhead.createCell((short) 0).setCellValue("SYMBOL"); ResultSet rsS=stmt.executeQuery("select SYMBOL from FFIX");; while(rsS.next()) { rowhead.createCell((short) 0).setCellValue(rsS.getString("SYMBOL")); } rsS.close(); break; case 3 : rowhead.createCell((short) 0).setCellValue("SERIES"); ResultSet rsSE=stmt.executeQuery("select SERIES from FFIX"); while(rsSE.next()) { rowhead.createCell((short) 0).setCellValue(rsSE.getString("SERIES")); } rsSE.close(); break; } } </code></pre> <p>Hi this is my jsp code,i am retriving the value from html page and checks that checkbox values in switch cases.i am trying to create an excel sheet using jsp and inserting records from database into that excel. but when i execute the above code it gives output as white blank excel file..even excel sheet is also not displaying what should i do now plz help me PLZ Thanx Kajal</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload