Home Answers Viewqa JSP-Servlet retrieving of value from excel file

 
 


harini
retrieving of value from excel file
2 Answer(s)      3 years and a month ago
Posted in : JSP-Servlet

Dear sir,
Thanks for sending a code now i am getting a particular column value i.e EmailId column for snding a massmails,now i have to get a particular column values i.e Name(A),EL(B),CL(C),Bonus(D),EmailId(E) soon...(A,B,C,D,E.. are column names) i have to get and send a mail that contains a matter i.e

Dear A,
U r CL is C ,EL is B,and bonus is D.
Thanks and Regards,
Hr.

i have to send this message to all the employees that are in the excel sheet.So in the previous code i have got onl single column value i.e EmailId values to send for a different employees mailids,so how to get a different column values please help me sir,giveme some code or if any modification in the previous code tell me sir.

Thanks in advance sir...
Regards
harini.

View Answers

April 28, 2010 at 11:15 AM


Hi Friend,

Try the following code:
1)column.jsp:
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@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"%>
<form action="mail.jsp">
<%
short a=0;
short b=1;
short c=2;
short d=3;
short e=4;
String filename ="C:/excelFile.xls";
if (filename != null && !filename.equals("")) {
try{
FileInputStream fs =new FileInputStream(filename);
HSSFWorkbook wb = new HSSFWorkbook(fs);
for (int k = 0; k < wb.getNumberOfSheets(); k++){
HSSFSheet sheet = wb.getSheetAt(k);
int rows = sheet.getPhysicalNumberOfRows();
for (int r = 1; r < rows; r++){
HSSFRow row = sheet.getRow(r);
if (row != null) {
int cells = row.getPhysicalNumberOfCells();
%><br><%
HSSFCell cell1 = row.getCell(a);
if (cell1 != null){
String value = null;
switch (cell1.getCellType()){
case HSSFCell.CELL_TYPE_FORMULA :
value = "FORMULA ";
break;
case HSSFCell.CELL_TYPE_NUMERIC :
value = ""+cell1.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_STRING :
value = cell1.getStringCellValue();
break;
default :
}
%>
<input type="text" name="name" value="<%=value%>">
<%
}
HSSFCell cell2 = row.getCell(b);
if (cell2 != null){
String value = null;
switch (cell2.getCellType()){
case HSSFCell.CELL_TYPE_FORMULA :
value = "FORMULA ";
break;
case HSSFCell.CELL_TYPE_NUMERIC :
value = ""+cell2.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_STRING :
value = cell2.getStringCellValue();
break;
default :
}
%>
<input type="text" name="el" value="<%=value%>">
<%
}
HSSFCell cell3 = row.getCell(c);
if (cell3 != null){
String value = null;
switch (cell3.getCellType()){
case HSSFCell.CELL_TYPE_FORMULA :
value = "FORMULA ";
break;
case HSSFCell.CELL_TYPE_NUMERIC :
value = ""+cell3.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_STRING :
value = cell3.getStringCellValue();
break;
default :
}
%>
<input type="text" name="cl" value="<%=value%>">

April 28, 2010 at 11:16 AM


continue..

<%
}
HSSFCell cell4 = row.getCell(d);
if (cell4 != null){
String value = null;
switch (cell4.getCellType()){
case HSSFCell.CELL_TYPE_FORMULA :
value = "FORMULA ";
break;
case HSSFCell.CELL_TYPE_NUMERIC :
value = ""+cell4.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_STRING :
value = cell4.getStringCellValue();
break;
default :
}
%> <input type="text" name="bonus" value="<%=value%>">
<%
}
HSSFCell cell5 = row.getCell(e);
if (cell5 != null){
String value = null;
switch (cell5.getCellType()){
case HSSFCell.CELL_TYPE_FORMULA :
value = "FORMULA ";
break;
case HSSFCell.CELL_TYPE_NUMERIC :
value = ""+cell5.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_STRING :
value = cell5.getStringCellValue();
break;
default :
}
%>
<input type="text" name="email" value="<%=value%>">
<%
}
}
}
}
}
catch (Exception ex){
ex.printStackTrace();
}
}
%>
<input type="submit" value="submit">
</form>

2)mail.jsp:
<table>
<%String name[]=request.getParameterValues("name");
String el[]=request.getParameterValues("el");
String cl[]=request.getParameterValues("cl");
String bonus[]=request.getParameterValues("bonus");
String email[]=request.getParameterValues("email");

for(int i=0;i<name.length;i++){
%>
<tr><td>CC</td><td><input type="text" size="53" value="<%=email[i]%>"></td></tr>

<tr><td>Content</td><td><textarea rows="5" cols="40">Dear <%=name[i]%>,
Your CL is <%=cl[i]%> ,EL is <%=cl[i]%>, and bonus is <%=bonus[i]%>.
Thanks and Regards,
Hr.
</textarea></td></tr>
<%

}

%>
</table>

Thanks









Related Pages:
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending... this message to all the employees when i upload a file then it fetch a data from that excel sheet i.e this matter will take a para meter values from the excel
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending... this message to all the employees when i upload a file then it fetch a data from that excel sheet i.e this matter will take a para meter values from the excel
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending a code now i am getting a particular column value i.e EmailId column... to all the employees that are in the excel sheet.So in the previous code i have got
Retrieving specific data from excel
Retrieving specific data from excel  Hello everyone, i have written a simple code to retrieve data from excel sheet and working fine, the excel file... to be printed. here is my sample code try { FileInputStream file = new
Retrieving attribute value from XML
Retrieving attribute value from XML  I have an XML as below to parse...; ..... But am not able to fetch the value of LoadTicketId attribute. My code...-values-from-a-nodel.shtml http://www.roseindia.net/xml/dom/GetData.shtml Thanks
retrieving excel data when file uploading
retrieving excel data when file uploading  <%@page import...); } } %> when i gave full path name i got excel data but when file...\\hp\\Desktop\\Book1.xls"; String filename=request.getParameter("excel
importing excel file and drawing multiple graphs from one excel file
importing excel file and drawing multiple graphs from one excel file  ... time from one excel file using different columns..and instead of passing column... can i do that?? and also help me how can i get date and time value from excel
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
check radio button on retrieving the value from database.
check radio button on retrieving the value from database.  HI i am new to jsp.In my applcation i having a problem. I am retrieving user payment from... checked.If user has done payment through cash then when i am retrieving user
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want... FROM ( SELECT * FROM month1 UNION ALL SELECT * FROM month2 UNION ALL SELECT * FROM month3 ) AS somealias GROUP BY uname
reading data from excel file and plotting graph
reading data from excel file and plotting graph  I am doing a project using NetBeans in which i have to take input an excel file and then using... at the same time from one excel file using different columns..how can i do that? waiting
insert rows from Excel sheet into a database by browsing the file
insert rows from Excel sheet into a database by browsing the file  hello, I am trying to insert rows from Excel sheet into SQL database by browsing Excel file in java(JSP). I can insert rows using ODBC connetion. But using odbc
insert excel value in to oracle data base
the data from the excel file using JDBC. For this you need to create dsn...insert excel value in to oracle data base  Hi All I am using this code for saving excel value to oracle database table. code is working properly
JavaScript get excel file data
is the example which gets the data from the excel file with the cell and row index... from this sheet. It works with Internet Explorer browser. Excel file data... JavaScript get excel file data
retrieving from db - JSP-Servlet
retrieving from db  hello' I am trying to write my first application...; Hi Retrive value from database Retrive data from...: rst=stmt.executeQuery("select * from books_details"); 27: %> 28
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
retrieving from oracle database using jsp combo box
retrieving from oracle database using jsp combo box  hi this is my... name of the server has to display in the process name field from the oracle... error = ""; if (!(document.getElementById("startpath").value
insert values from excel file into database
insert values from excel file into database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel... the following link: Insert values from excel file to database
read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : http://www.roseindia.net/java/poi/ Thanks
How to upload a large excel file - JSP-Servlet
How to upload a large excel file   Dear sir , How to upload a large excel file and how to read a that large excel file or how to get a each column values from that large excel file.For small file i am getting values
Access Excel file through JDBC
Access Excel file through JDBC In this section, you will learn how to access excel file through Jdbc and display records in JTable. As you know Excel comes... and the excel file. Here the name of the worksheet is equivalent to any database
Insert data in Excel File from Database using JSP
Insert data in Excel File from Database  using JSP ... developed a application to insert data  in excel file from database in JSP. We... the data from database, create an excel file and data insert into newly
connection of java file to excel file and put data from excel file into oracle db
connection of java file to excel file and put data from excel file into oracle db  how to create button on excel sheet using java swing and how we give action to that button excel sheet? how we connect excel file to java file
Create and Save Excel File in JSP
and saving Excel file from JSP application. In this example we are going... Create and Save Excel File in JSP  ... file.  To create an excel sheet we can use third party API which is Apache
how to display the data from excel to webpage
search for the value 4024 in a excel file and to display the remaining values...how to display the data from excel to webpage  Hi, I need help... that reads the excel file and store data into table. <%@page import="java.io.*"%>
importing excel file
importing excel file  Hi All I am developing a java application whre we upload a excel file in to database and all excel value should import... it is not showing real excel sheet value. please suggest good way to solve this problem
how to get a column values from a excel file after attaching it - JSP-Servlet
how to get a column values from a excel file after attaching it  hi sir, How to get a column values from a excel file after attaching it while... and get a values from that store that value in To input box.Please help me sir
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i am try to develop a tool which reads from a excel file and then appends the same... used JDBC ODBC to read from excel file. i am not able to append it using
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file that should go to database which exists. am using SQL Server management studio
Saving and Retrieving The Preferences
("Got PrefsValue '" + prefs_value + "' from prefs"); // This prints the got... Saving and Retrieving The Preferences Preference values are the constant  key/value pairs. In the pairs of key and value the key
Retrieving Tables from a Database
Retrieving Tables from a Database   ... for retrieving tables from a specific database through an example. In relational... the connection between the MySQL database and Java file. We will retrieve
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
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database for scientific research analysis. My team members sends research data in excel file
Retrieving JTree structure from database
Retrieving JTree structure from database       This example shows how to retrieving data from... the steps required to create tree retrieving the data from the database. Here
How to import data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase??
How to import data from sql server table into an excel file by creating... data from sql server table into an excel file by creating the rows dynamically... to create an excel file according to that and keep updating the same
Linking an Excel File with the Application tool
on the questions that are in the excel file like extracting the questions from the excel file...Linking an Excel File with the Application tool  I have to link an excel file with a application software which I am developing.I have this code
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
Retrieving XML Data Using GWT
Retrieving XML Data Using GWT       This Example Describes the way of retrieving XML file Data from... are describing below is explained here in stepwise:- Step1:-Create a java File
retrieving of data from one jsp to another jsp - JSP-Servlet
retrieving of data from one jsp to another jsp  using jsp i m displaying a table ,in table i m displaying a radio button then values like id,name etc ,if i click on an radio button i have to get a corresponding id value
Retrieve Data from the database and write into excel file
Retrieve Data from the database and write into excel file. In this section, we are going to retrieve data from the database and write into the excel file...); fileOut.close(); System.out.println("Data is saved in excel file
excel
excel  how to read columns values of excel file in java and store in array list in java like col1 col2 2 3 1 7 7 9 then list1 have values of col1 and list2 have values of col2...  
excel
excel  how to save excel sheet data into the database using poi api... into person(Name,Address) value('"+name+"','"+address+"')"); System.out.println...=stat.executeUpdate("insert into person(Name,Address) value('"+name+"','"+address
Inserting data in Excel File - Java Beginners
Inserting data in Excel File  Dear Sir, How can we fill the excel with fetched data from the database like Oracle, DB2? Is it possible to create an excel with filled data? Kindly give me the solutions to questions
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...)excel.jsp: Read And Edit Excel File  continue
excel to database
excel to database   How to export data from excel sheet to mysql database by using java with request parameter Here q=40 is a request parameter...(); Workbook workbook = Workbook.getWorkbook(new File("C:/data.xls"), ws
Wrong parameter values while exporting data from jsp to excel
Wrong parameter values while exporting data from jsp to excel   ..., specifically, if the parameter value is ALL, it gets translated to NO in excel...(); out.println("Data is saved in excel file."); }catch ( Exception ex ){ } %>
Retrieving XML Data Using GWT
Retrieving XML Data Using GWT       This Example Describes the way of retrieving XML file Data from the server using GWT. The basic building block for running
retrieving data from database to the textbox depending upon the id in jsp
retrieving data from database to the textbox depending upon the id in jsp  Hi, our project involves fetching of data from database into textbox depending upon another textbox value which is productid.First the id entered by us