Thursday, 8 August 2013

how to get last column value of respective row of excel sheet in java using Apache POI

how to get last column value of respective row of excel sheet in java
using Apache POI

i have following excel sheet
id JobId Name Dept Add Salary
101 41 Bob Editing New York $ 5000
i am passing id,jobid as request parameter to servlet from $.ajax()
method. i want to get salary cell data of excel sheet by matching request
parameters i.e id and jobid with excel sheet contents and insert it other
table. How to do this?
here is my code...
FileInputStream file = new FileInputStream(fileToBeRead);
workbook = new HSSFWorkbook(file);
if (Id == 101 && jobid==41) {
// get first sheet
HSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.iterator();
statement = conn.createStatement() ;
ResultSet resultset = statement.executeQuery("Select
job_id,Job,Name, Department from Emp,Deptname where
Department.job_id=" + jobid + " AND Emp.Id=" + Id + " ");
while (resultset.next()) {
//how to match database result with excel records and
save to database
}//resultset.next() ends here...
resultset.close();
}

No comments:

Post a Comment