Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions How to export grid into excel

Have Programming Question? Ask it here!
 
 
 


vanchinathan R
How to export grid into excel
2 Answer(s)      a year and 10 months ago
Posted in : JavaScript Questions


Hi, i created a grid panel i have to export it to the excel. please help me by some sample code. thanks in advance. cool day dude.


Advertisement
View Answers

October 3, 2012 at 4:38 PM


Here is a jsp application that retrieves database records in a table and export the data to excel file. You need POI api to run the given code.

1)data.jsp:

<%@page import="java.sql.*"%>
<form method="post" action="excelFile.jsp">
<table border=1>
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from employee");
while(rs.next()){
    %>
<tr><td><input type="text" name="name" value="<%=rs.getString("name")%>"></td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td><td><input type="text" name="contact" value="<%=rs.getString("contactNo")%>"></td><td><input type="text" name="email" value="<%=rs.getString("contactNo")%>"></td></tr>
<%
}
%>
</table>
<input type="submit" value="Export To Excel">
</form>

2)excelFile.jsp:

<%@page import="  java.io.*"%>  
<%@page import="  org.apache.poi.hssf.usermodel.*"%>  
<%
String name[]=request.getParameterValues("name");
String address[]=request.getParameterValues("address");
String contact[]=request.getParameterValues("contact");
String email[]=request.getParameterValues("email");

try{
String filename="c:/data.xls" ;
HSSFWorkbook hwb=new HSSFWorkbook();
HSSFSheet sheet =  hwb.createSheet("sheet");

HSSFRow rowhead=   sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("Name");
rowhead.createCell((short) 1).setCellValue("Address");
rowhead.createCell((short) 2).setCellValue("Contact No");
rowhead.createCell((short) 3).setCellValue("E-mail");
for(int i=0;i<name.length;i++){
    int j=i+1;
HSSFRow row=   sheet.createRow((short)j);
row.createCell((short) 0).setCellValue(name[i]);
row.createCell((short) 1).setCellValue(address[i]);
row.createCell((short) 2).setCellValue(contact[i]);
row.createCell((short) 3).setCellValue(email[i]);
}
FileOutputStream fileOut =  new FileOutputStream(filename);
hwb.write(fileOut);
fileOut.close();
out.println("Your excel file has been generated!");
} catch( Exception ex ) {
    System.out.println(ex);
}
%>


October 3, 2012 at 5:59 PM


hi thanks dude. here you created a table and exported to excel. but i created grid in extjs and have to export to the excel. please help me for that.. thanks dude.



Related Tutorials/Questions & Answers:
How to export grid into excel
How to export grid into excel  Hi, i created a grid panel i have to export it to the excel. please help me by some sample code. thanks in advance. cool day dude
How to export chart(graph) generated by jsp into a excel?
How to export chart(graph) generated by jsp into a excel?  How to export chart(graph) generated by jsp into a excel? I have a jsp page which generates charts . Now I need those charts to be exported into an excel.please help
Advertisements
How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java
How to export data from html to excel sheet by using java
How to export data from html to excel sheet by using java   How to export data from html to excel sheet by using java
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java    How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java   reading the data from Html file
How to add save as dialoguebox to export into excel instead of directly saving..
How to add save as dialoguebox to export into excel instead of directly saving..  Hello Sir, i followed ur tutorial to export into excel from database and generated excel file at particular directory of my system
How to export web page to excel using java or jsp or servlets
How to export web page to excel using java or jsp or servlets  Hi I am trying to export web page(jsp page ) to excel using jsp or servlets. I am... have a save as excel button, when I click this button I need these displayed
Export html data to excel
Export html data to excel  I am trying to export data from an html page to an excel sheet.Any advise
How to export data from database to excel sheet by using java in standalone project
How to export data from database to excel sheet by using java in standalone project  How to export data from database to excel sheet by using java in standalone project
export to excel - JSP-Servlet
export to excel  Hi this is priti. I need a help. What is my question is i have a report page here i need a button cllaed "Export to excel". After clicking the button all the values from the jsp page will save to a excel file
export java to excel - Java Beginners
export java to excel  How do you export java to excel?  You mean to say accessing Microsoft files in java? Then you can go for Apache POI. Its an API to access MS-Office files.Try using it. - Ramesh A.V
How to download web page table data, export the table records in an excel file and save
How to download web page table data, export the table records in an excel file and save  i have a web page(.jsp) which contains the table of 4 to 5... be exported in to the excel file. any views??? Thanks in advance
Export data in excel sheet in java in struts - Struts
Export data in excel sheet in java in struts  Hello, All how can i export data in excel file i java  Hi friend, For solving the problem visit to : http://www.roseindia.net/jsp/excelfile.shtml Thanks
export
export  how to export tabled data in jsp into excel
How to export data from database to excel sheet by using java swing in standalone project - Java Beginners
How to export data from database to excel sheet by using java swing... from u to solve my problem. my problem is i don know how to export data from database to excel sheet by using java swing in standalone project.I get solution from
Export data to Excel Sheet in STRUTS 1.3
Export data to Excel Sheet in STRUTS 1.3  hi. how can i export content present on the jsp to excel sheet on button click..... and challenging part is i have to merge few rows and columns for a particular field(Value
Java Count word occurrence and export it to excel file
Java Count word occurrence and export it to excel file Here is an example... and display the result the result into excel file in the table form. Example...;Your excel file has been generated!"); } catch(Exception e
Export Extjs Gridview data to excel in jsp
Export Extjs Gridview data to excel in jsp  i need to export the extjs girdview data to excel can you please help me thanks in advance
Java swing: Export excel sheet data to JTable
Java swing: Export excel sheet data to JTable In this tutorial, you will learn how to read data from excel file and export it to JTable. In swing applications, sometimes, it is required to display the excel file data into the jtable
export data to excel sheet - JSP-Servlet
export data to excel sheet  Hi.. how to export data to excel sheet from jsp? and how to update the excel sheet from jsp? and how to get the data from excel sheet? and how to make calculations in excel sheet like total avg
Retrieve Data into JTable and export it to Excel File
Java Retrieve Data into JTable and export it to Excel File... in the table and then export it to the Excel file. For this, we have created a table... it into Vector which is then added to table. To export the table data to excel file, we
export data from database to excel sheet - JDBC
export data from database to excel sheet  I am facing a problem about exporting required data from database table to ms-excel sheet.i mean whenever I execute a query then result will be display in MS-EXCEL sheet. please give me
Export data in excel sheet via Browse and upload button into mysql database
Export data in excel sheet via Browse and upload button into mysql database  how to create a Browse & Upload Buttons and then save the information from it in mysql database's Table Am using struts2,hibernate for making
how to insert a summary values in grid
how to insert a summary values in grid  how to insert a summary value in grid
Read data from Excel and insert in to DB and export data from DB to Excel
Read data from Excel and insert in to DB and export data from DB to Excel  Read data from Excel and insert in to DB and export data from DB to Excel Hi, I need to read the data from excel and I need to insert the same in to DB
Export SQL database schema from SQL server management studion express2005 into MS excel file
Export SQL database schema from SQL server management studion express2005 into MS excel file  HI I need to export Database Schema from SQL Server.... but i need to have Excel file contains database schema. how can i do with SQL
How to Unlock Excel Password
How to Unlock Excel Password  anyone help me how to recover lost Excel file password
How to use struts2 grid with form submission
How to use struts2 grid with form submission  Hello, I've already...; > <div class="gridSection"> > <sjg:grid... submitted successfully, action also executed successfully, but the grid becomes
how to display data in List Or grid or in table in Jsp
how to display data in List Or grid or in table in Jsp   <%@page import="java.util.Calendar"%> <%@ page import="org.apache.lucene.search.IndexSearcher"%> <%@ page import="org.apache.lucene.analysis.Analyzer"%>
how to export the query result in SQL Server to .csv file?
how to export the query result in SQL Server to .csv file?  how to write table data into CSV file using SQL SERVER 2008
how can i export a .jar file include .mbd file?
how can i export a .jar file include .mbd file?  i have a project of java.it includes a .mdb file, when i export to .jar file i eclipse, it show a error that can't export .jar file width the .mdb file ? how can i import this .mdb
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
how make excel
how make excel  how make excel spreadsheet IN JAVA. please send this code argently   Hello Friend, Try the following code: import...(filename); hwb.write(fileOut); fileOut.close(); System.out.println("Your excel file
how to display data in excel sheet?
how to display data in excel sheet?  According to the user Id,some... there will be a button called excel download,and if we click the button data will be displayed in excel sheet.can you people please help me how to create
export instance sql
export instance sql  How to export instance in sql
Ajax grid
Ajax grid  Hi, How I can create ajax grid in my program? Thanks
How to insert rows from Excel spreadsheet into database by browsing the excel file?
How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i... the excel file using file browsing dialogue through form in JSP. How can i select
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
how can i create a data grid - Java Beginners
how can i create a data grid  Nice to ur respose...thnks all of u plz help me i want make a datagrid but i have no idea about this how can i create datagrid. and how can i connect to the database plz help me give
how to connect xlsx(2007 excel) - JDBC
how to connect xlsx(2007 excel)  i am not able connect to office 2007 excel file from jdbc
How to read excel contents when uploaded
How to read excel contents when uploaded  I am working on a project where the user uploads his excel file. Jsp page must read the excel contents... files.Please do help..   user logins and he uploads his excel file. the excel
How to make a horizontally Scrollable grid in jsp using div, table, css, javascript?
How to make a horizontally Scrollable grid in jsp using div, table, css... saving data would be viewed in grid in the same page. Now problem is that, I need to display a record of 30 columns.Since the grid is made of table it becomes
Sigma grid -- Ajax-enabled JavaScript grid
Inline cell editing is possible in Sigma Grid just like in Excel Sheet. Sigma Grid... visible despite scrolling grid. Math formulas for cells Like in Excel sheet...Sigma grid -- Ajax-enabled JavaScript grid   
display:table export only data
display:table export only data  I am using display:table tag with attribute export="true". Using that I can export table data in excel. Here one of the column is in hyper link. But i need to export only data not html tag . Can
How to use Sigma grid built-in capabilities to calculate aggregates where Sortable property set to TRUE
How to use Sigma grid built-in capabilities to calculate aggregates where Sortable property set to TRUE  How to use Sigma grid built-in capabilities... ,totals row will come up and may cause mess in the grid). Sorting must be done
how to present the excel to the web browser in jsp
how to present the excel to the web browser in jsp  How to present the content of the newly created excel file in the following jsp to the web...="org.apache.poi.xssf.usermodel.XSSFWorkbook"%> <%@ page contentType="application/vnd.ms-excel
 

 

 

DMCA.com