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



Home Answers Viewqa JSP-Servlet writing in Excek sheet
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


prashant
writing in Excek sheet
2 Answer(s)      5 years and 6 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

June 12, 2009 at 1:06 PM


Hi Friend,

Follow these steps:
1) Create form.jsp
<html>
<body>
<form name="userform" method="post" action="excelFile.jsp">
<table>
<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>
</table>
</form>
</body>
</html>


June 12, 2009 at 1:07 PM


continue.............

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");
try{
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);
row.createCell((short)0).setCellValue(value1);
row.createCell((short)1).setCellValue(value2);
row.createCell((short)2).setCellValue(value3);
row.createCell((short)3).setCellValue(value4);
row.createCell((short)4).setCellValue(value5);
FileOutputStream fileOut = new FileOutputStream("c:\\StudentData.xls");
wb.write(fileOut);
fileOut.close();
out.println("Data is saved in excel file.");
}catch ( Exception ex ){
}
%>
Thanks


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
Advertisements
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
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.
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
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
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
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
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
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
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
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
how to create exce sheet using java
how to create exce sheet using java  how to create excel sheet using java
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
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
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
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 HTML entirely by hand
writing HTML entirely by hand  How comfortable are you with writing HTML entirely by hand
writing plugin - WebSevices
writing plugin  can anyone help me in writing plugin for internet explorer browser using c++ in .net environment
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.* 
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
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
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
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
exporting data to excel sheet - JDBC
(); final HSSFWorkbook wb = new HSSFWorkbook(); final HSSFSheet sheet = wb.createSheet("Excel Sheet"); try{ Connection con = null
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
extract data from excel sheet to mysql
extract data from excel sheet to mysql  sir, i want to extract data from excel sheet and save the data in mysql5.0 database in the form of table
 

 

 

DMCA.com