I want to insert data from excel file to MySQL database using JSP. once i select the excel file from jsp and give upload the entire file is getting uploaded. but i want to read the datas from excel sheet and insert that data into mysql database thanks in advance. can anyone tel me whether it is possible?
Asked
Active
Viewed 3,053 times
1 Answers
2
public void readExcelFile(InputStream file) {
try {
POIFSFileSystem myFileSystem = new POIFSFileSystem(file);
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
HSSFSheet mySheet = myWorkBook.getSheetAt(0);
Iterator rowIter = mySheet.rowIterator();
rowIter.next();
while (rowIter.hasNext()) {
HSSFRow myRow = (HSSFRow) rowIter.next();
Iterator cellIter = myRow.cellIterator();
cellIter.next();
System.out.println(((HSSFCell)cellIter.next()).toString());
}

Ramesh Kotha
- 8,266
- 17
- 66
- 90