jsp excel code

jsp excel code

Hi
how to insert form data into excel file using jsp?
View Answers

June 2, 2010 at 10:39 AM

Hi Friend,

Try the following code:

1)register.jsp:

<html>
<body>
<center><h3>Registration Form</h3></center>
<form method="POST" action="insertIntoExcel.jsp">
<center>
<table>
<tr><td>First Name:</td><td><input type="text" name="firstname" size="20"></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lastname" size="20"></td></tr>
<tr><td>User Name:</td><td><input type="text" name="username" size="20"></td></tr>
<tr><td>Password:</td><td><input type="text" name="password" size="20"></td></tr>
<tr><td>Address </td><td><input type="text" name="address" size="20"></td></tr>
<tr><td>Contact No </td><td><input type="text" name="contact" size="20"></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" size="20"></td></tr>
<tr><td>City: </td><td><input type="text" name="city" size="20"></td></tr>
<tr><td>State: </td><td><input type="text" name="state" size="20"></td></tr>
<tr><td>Country: </td><td> <input type="text" name="country" size="20"></td></tr>
<tr><td><input type="submit" value="Submit" name="B1"></td><td><input type="reset" value="Reset" name="B2"></td></tr>
</table>
</center>
</form>
</body>
</html>

2)insertIntoExcel.jsp:

<%@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.HSSFCell"%>
<%
String fname= request.getParameter("firstname");
String lname= request.getParameter("lastname");
String uname= request.getParameter("username");
String pass= request.getParameter("password");
String address= request.getParameter("address");
String contact=request.getParameter("contact");
String email=request.getParameter("email");
String city=request.getParameter("city");
String state=request.getParameter("state");
String country=request.getParameter("country");
try{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("First Name");
rowhead.createCell((short) 1).setCellValue("Last Name");
rowhead.createCell((short) 2).setCellValue("User Name");
rowhead.createCell((short) 3).setCellValue("Password");
rowhead.createCell((short) 4).setCellValue("Address");
rowhead.createCell((short) 5).setCellValue("Contact No");
rowhead.createCell((short) 6).setCellValue("Email");
rowhead.createCell((short) 7).setCellValue("City");
rowhead.createCell((short) 8).setCellValue("State");
rowhead.createCell((short) 9).setCellValue("Country");

HSSFRow row = sheet.createRow((short)2);
row.createCell((short)0).setCellValue(fname);
row.createCell((short)1).setCellValue(lname);
row.createCell((short)2).setCellValue(uname);
row.createCell((short)3).setCellValue(pass);
row.createCell((short)4).setCellValue(address);
row.createCell((short) 5).setCellValue(contact);
row.createCell((short) 6).setCellValue(email);
row.createCell((short) 7).setCellValue(city);
row.createCell((short) 8).setCellValue(state);
row.createCell((short) 9).setCellValue(country);

FileOutputStream fileOut = new FileOutputStream("c:\\excelFile.xls");
wb.write(fileOut);
fileOut.close();
out.println("Data is saved in excel file.");
}
catch(Exception e){}
%>

Thanks

October 13, 2011 at 11:09 PM

hi..i tried the above code.but i m facing an error stated below.pls provide a solution.

An error occurred at line: 18 in the jsp file: /xcel.jsp HSSFWorkbook cannot be resolved to a type 15: String state=request.getParameter("state"); 16: String country=request.getParameter("country"); 17: try{ 18: HSSFWorkbook wb = new HSSFWorkbook(); 19: HSSFSheet sheet = wb.createSheet("Excel Sheet"); 20: HSSFRow rowhead = sheet.createRow((short)0); 21: rowhead.createCell((short) 0).setCellValue("First Name");


October 13, 2011 at 11:10 PM

hi..i tried the above code.but i m facing an error stated below.pls provide a solution.

An error occurred at line: 18 in the jsp file: /xcel.jsp HSSFWorkbook cannot be resolved to a type 15: String state=request.getParameter("state");

16: String country=request.getParameter("country");

17: try{

18: HSSFWorkbook wb = new HSSFWorkbook();

19: HSSFSheet sheet = wb.createSheet("Excel Sheet");

20: HSSFRow rowhead = sheet.createRow((short)0);

21: rowhead.createCell((short) 0).setCellValue("First Name");









Related Tutorials/Questions & Answers:
jsp excel code - JSP-Servlet
jsp excel code  Hi how to insert form data into excel file using jsp?  Hi Friend, Try the following code: 1)register.jsp: Registration Form First Name: Last Name: User Name: Password
jsp excel code - JSP-Servlet
jsp excel code  hi how to store html form data into excel sheet by using jsp? and repeat this process continuously for entire sheet
Advertisements
Read code from excel sheet and upload into database using JSP
Read code from excel sheet and upload into database using JSP  I want to upload data to database from an excel worksheet using jsp ...Please help
JSP TO EXCEL
JSP TO EXCEL  Hi sir/mam, How to import data to excel using jsp without retrieving database.   friend, you can't import excel data into the middle of an HTML pages (your JSP will result in an HTML page
JSP to Excel - JSP-Servlet
JSP to Excel  Need an example of JSP and Excel database connection. Thanks
jsp to excel - JSP-Servlet
jsp to excel  Hi All, I'm writing a program of jsp to Excel conversion with Using POI. My problem is i'm unable to put multiple data into excel...)); } FileOutputStream fileOut = new FileOutputStream("c:\\excel\\wct.xls
Excel - JSP-Servlet
Excel  How to export data from jsp to excel sheet. I am using struts1.2 in my application.  Hi friend, Code to data from Jsp to excel... "success.jsp" For more information on excel sheet Using
jsp data in excel - JSP-Servlet
jsp data in excel  i have create jsp page which has button for excel.this calls jsp which contains code which has and then code for present data... and this query data has come from beans and using beans i put it in excel jsp in table
excel uploading in jsp
excel uploading in jsp  could you provide the source code for: 1)have to upload an empty excel sheet at client side i.e if client clicks an excel... given and printing them in a jsp page. could you please provide the code in spring
JSP/Servlet to read and update Excel
JSP/Servlet to read and update Excel  Hi Team, My requirement is based upon my input(name) value via one jsp, the program(jsp/servlet) should fetch all the column values which is related to my input(name) from Excel(.xls
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
jsp code
jsp code  what are the jsp code for view page in online journal
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel... given excel sheet and display it into another excel sheet using jsp" i am using 'session' to get the empid from one page to another jsp
excel report fro jsp mysql
excel report fro jsp mysql  Dear Sir, I am facing some problem while generating excel report form mysql database using jsp code. With the help from your site, I can able to generate excel file for all data types other than blob
JSP CODE
JSP CODE  what is the code for downloading images from database using JSP?   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml
jsp code
jsp code  hi i am Ruchi can anybody plz tell me the jsp code... visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml www.roseindia.net/jsp/searchbook.shtml
jsp - excel generating problem - JSP-Servlet
jsp - excel generating problem  Hi, I worked with the creating excel through jsp, which is the first example in this tutorial...://www.roseindia.net/jsp/poi/generatingExcelSheet.shtml In this page create excel sheet
jsp code
jsp code  i want health management system project code using jsp.its urgent
jsp with excel sheet data uploading into database
jsp with excel sheet data uploading into database  how to upload data in excel sheet with jsp into oracle 10g database
read excel data from jsp - JSP-Servlet
read excel data from jsp  Hi how to read excel file from jsp? Excel file is created manually entered data having many sheets? and read the entire sheet and also edit with jsp? pls suggest me?   Hi Friend, 1
Reading excel via JSP
Reading excel via JSP   The problem is while reading cells values which all are having "space" between the word, I can read only till space after that space the word has been dropped. for Example Name
JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code
To save table format data in pdf/excel in jsp
through jsp code. So please suggest some sample code of jsp and there api which...To save table format data in pdf/excel in jsp  Hello, I am doing web application project in jsp. In webform ,I am displaying database data in html
jsp code
jsp code  i want to jsp code which are working as,i have three drop down menu 1st menu for class second menu for subject and third menu as chapter... according to selectde menu,,,,please send me such type code,,,,plz help me
code for attendence in excel sheet - Java Magazine
code for attendence in excel sheet  When i enter an "Empid "in an an HTML page, time of the system should save in the excel file of that Empid row(IE... enter in to the other cell of that row . It is like attendance".Give jsp code
jsp code - JSP-Servlet
jsp code  Can anyone help me in writing jsp/servlet code to retrieve files and display in the browser from a given directory.  Hi Friend, Try the following code: Thanks
jsp code
jsp code  how to display date in drop down list by jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months
jsp code - JSP-Servlet
jsp code  sample code for change password example Old Password: new Password: confirm Password
Jsp to Excel
Jsp to Excel     ... an excel file and write data into it using jsp. For this, you have to import... is the code of excel.jsp <%@ page import
JSP code
JSP code  I get an error when i execute the following code : <... = con.createStatement(); st.executeQuery(query); %> <jsp:forward page="address.jsp"></jsp:forward> HTTP Status 500 - type Exception report message
jsp code - JSP-Servlet
jsp code  I need code for bar charts using jsp. I searched some code but they are contain some of their own packages. Please give me asimple code... friend, Code to solve the problem : Thanks
jsp code - JSP-Servlet
jsp code  sample code to create hyperlink within hyperlink example: reservation: train: A/C department non A/c Department
jsp code - JSP-Servlet
jsp code  how to count no of clicks made on a link and save it on database( using jsp)  Hi Friend, Try the following code: 1)click.jsp var numberOfClicks = 0; function hello(){ numberOfClicks
jsp code - JSP-Servlet
jsp code  in a jsp a table is existed ,in table each row contain one checkbox and name and desription how to delete specific rows in a table .  Hi Friend, Try the following code: 1)form.jsp: Name
JSP code - JSP-Servlet
me how to link these pages with each other using JSP..and how to write the code using JSP.. requriment for Newuser: 1>fname,lastname 2>Loginname...JSP code  hello,i working in project with JSP technology,i have one
how to create a jave version excel in jsp
how to create a jave version excel in jsp  I would like to create a java version excel in JSP. so the excel like document can be published... to save the data. questions: 1 can any body share some code samples
jsp code - JSP-Servlet
jsp code  in my table there are 3 fields named orderid ,itemname, itemqty. i want code that fetch orderid in dropdown... on select dropdown get table of item details of that orderid... there are multiple items at one orderid
JSP Code - JSP-Servlet
JSP Code  Create a html reader JSP tag that read the html page from a link and will display the contents on the JSP. Do not use include directive
code in jsp
code in jsp  hi.. I had started a project on college admission system in which two operators has been introduced one is admin who can view all... want a code to sort a list of students on the basis of there 12% marks and AIEEE
jsp code - JSP-Servlet
jsp code  how to write a code in jsp with out using servelts finding sum and avg of 40 numbers  Hi Friend, Try the following code: Thanks  Hi Friend, Do one change in the provided code.As we
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... from jsp? Pls.....   Hi Friend, Try the following code: 1
JSP Excel report download for .xlsx format
JSP Excel report download for .xlsx format  <%@ page contentType...; The above code works fine because i am trying to save/open excel file in .xls format... the code like this <%@ page contentType="application/vnd.ms-excel
jsp code - JSP-Servlet
jsp code  hi my requirement is generate dynamic drop down lists... statement? pls provide code how to get first selected drop down list value to generate second drop down list by using jsp? pls ?   Hi Friend
jsp code - JSP-Servlet
jsp code   the value did not passed from script and not inserted in to database in the code u given . var numberOfClicks = 0; function hello(){ numberOfClicks++; alert( numberOfClicks ); document.form1.text.value
JSP code - JSP-Servlet
JSP code  hi i want to clear text box fields after click on submit.... thanking u......... This is what my code is. Jam Name...;   Hi Friend, Try the following code: Jam Name
jsp code - JSP-Servlet
jsp code  Hello Everybody, can anyone help me to findout the modules as i am developing a whiteboard application using jsp? this application is my dream application. Thank you
JSP Code - JSP-Servlet
JSP Code  Hi, Do we have a datagrid equivalent concept in JSP..., Please visit the following links: http://www.roseindia.net/jsp/data-grid.shtml http://www.roseindia.net/jsp/paging.shtml Thanks
jsp code - JSP-Servlet
jsp code  i want to add below code data in mysql database using jsp... using below code we got data in text box i want to add multiple data in database... Add/Remove dynamic rows in HTML table
JSP Code - JSP-Servlet
JSP Code  Hi, I have a problem in limiting the number of row... to display only 10 records per pages in jsp, then how can i achieve this concept... Rai.  Hi Friend, Try the following code: Pagination
jsp code - JSP-Servlet
jsp code  hello frns i want to display image from the database along... from database in Jsp to visit.... http://www.roseindia.net/jsp/retrieve-image.shtml http://www.roseindia.net/jsp/downloadimage.shtml Thanks

Ads