writing in Excek sheet



Share on Google+Share on Google+

writing in Excek sheet
2 Answer(s)      8 years ago
Posted in : JSP-Servlet
View Answers

June 12, 2009 at 1:06 PM

Hi Friend,

Follow these steps:
1) Create form.jsp
<form name="userform" method="post" action="excelFile.jsp">
<tr><td>Enter ID:</td><td><input type="text" name="id"></td></tr>
<tr><td>Enter Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Enter Class:</td><td><input type="text" name="class"></td></tr>
<tr><td>Enter Age:</td><td><input type="text" name="age"></td></tr>
<tr><td>Enter Address:</td><td><input type="text" name="address"></td></tr>
<tr><td><input type="submit" value="Export to excel"></td></tr>

June 12, 2009 at 1:07 PM


2) Create excelFile.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 value1=request.getParameter("id");
String value2=request.getParameter("name");
String value3=request.getParameter("class");
String value4=request.getParameter("age");
String value5=request.getParameter("address");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("Student ID");
rowhead.createCell((short) 1).setCellValue("Name");
rowhead.createCell((short) 2).setCellValue("Class");
rowhead.createCell((short) 3).setCellValue("Age");
rowhead.createCell((short) 4).setCellValue("Address");

HSSFRow row = sheet.createRow((short)1);
FileOutputStream fileOut = new FileOutputStream("c:\\StudentData.xls");
out.println("Data is saved in excel file.");
}catch ( Exception ex ){


Related Tutorials/Questions & Answers:
writing in Excek sheet - JSP-Servlet
writing in Excek sheet  Hello Dear sir, i got one scenario where i have to pick the data of the student like id , name , class , age & address from jsp & then i have to store these data into Excel Sheet
style sheet properties
style sheet properties  What are style sheet properties
writing characters
writing characters  how to write a group of characters to a string ... i mean for writing single character using charAt in java
connect many access sheet to one access sheet
connect many access sheet to one access sheet   hellow sir. i have six application page it has attribute name rollno(primary key) and attendance... access sheet as name rollno attendance of 1,2nd,3rd.....6th
Ghost Writing
Ghost Writing Ghost Writing is the kind of writing when someone... of writing it. So ghostwriter is a person who works behind the scene on a writing project in return of certain amount. The write-ups of the writer
Blog Writing
Blog Writing A blog, the short form of web log is an online user... on that. But the professionals are a better choice for writing the blog for commercial or promotional purpose. We provides the services of writing blogs for the commercial
Writing Actions
Writing Actions The Action is responsible for controlling of data flow within an application. You can make any java class as action. But struts have some built in interface and class for making action easily. To make an Action class
insert excel sheet into mysql as a table
insert excel sheet into mysql as a table  sir, i want to import an excel sheet into mysql5.0 database as in the table format using tomcat 6.0 by jsp
reading excel sheet in java
reading excel sheet in java  can anyone tell me a proper java code to read excel sheet using poi   Here is a java code that reads an excel file using POI api and display the data on the console. import java.io.
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
Copy Mails to Xl sheet - JavaMail
Copy Mails to Xl sheet  Can somebody give me the Java code to copy outlook mails into an Xl sheet
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel sheet for employee details "i retrieve particular datas from given excel sheet and display it into another excel sheet using jsp
Web Writing
Web Writing       The art of writing for the web is far removed from writing for the print world.... Following is the prime aspect you need to keep in mind while writing for the web
writing plugin - WebSevices
writing plugin  can anyone help me in writing plugin for internet explorer browser using c++ in .net environment
writing HTML entirely by hand
writing HTML entirely by hand  How comfortable are you with writing HTML entirely by hand
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
SEO Writing
SEM and SEO Article Writing SEM and SEO article helps your business to grow... the intended traffic through SEM and SEO article writing in addition to other tools... is the demand of SEM and SEO article writing services. A good command over
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
how to display data in excel sheet?
how to display data in excel sheet?  According to the user Id,some links will be generated from the database,and if we click a link,data would... the button and to display the data in excel sheet
how to create exce sheet using java
how to create exce sheet using java  how to create excel sheet using java
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
Cascading Style Sheet(CSS)
Cascading Style Sheet(CSS)       Cascading Style Sheet (CSS) is known as style sheet language.... The application of style sheet is to style the web pages written in HTML and XHTML
Excel sheet image reading issue
Excel sheet image reading issue   Hello every one.I?m trying to read images from an excel sheet using OleDbDataReader. My excel file has 6 columns of data, the first 5 are all text but the last is image. While I?m
Create Excel Sheet Using JSP
create excel sheet using jsp       In this example we create excel sheet and insert values into table of the excel sheet . In this example we use page directive
Selecting Excel Sheet File
selecting excel sheet file       In this program we are going to select the excel sheet... sheet .  The package we need to import is java.io.* 
Printing data into Excel sheet - Java Beginners
Printing data into Excel sheet  Hi all i am writing one application where there is need to bring the data into "Excel Sheet" with proper format.My... database then showing it(data) to in "Excel Sheet" is it possible to do ? if yes
Version of com.gordonwong>material-sheet-fab dependency
List of Version of com.gordonwong>material-sheet-fab dependency
Set Sheet Name Compressed Unicode
Set Sheet Name Compressed Unicode   ... the sheet name and compress it. The methods can be used for built in data format: setSheetName(int sheet, String name):  This method is used to set the sheet
Excel Sheet Footer
Excel Sheet Footer In this section, you will learn how to create footer on a sheet using Apache POI. In the given below example, we will create footers having different position on sheet. These footers will appear on the hardcopy
Excel Sheet Header
Excel  Sheet Header In this section, you will learn how to create header on a sheet using Apache POI. In the given below example, we will create... on the hardcopy(print out) . You can see this by taking print preview of the sheet. Given


Advertisement null