package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
public class test {
public static void main(String[] args) {
String file="C:\\Users\\Documents\\file.xls";
File excelfile=new File(file);
FileInputStream excleFileInputStream;
try {
excleFileInputStream = new FileInputStream(excelfile);
HSSFWorkbook wb = new HSSFWorkbook(excleFileInputStream);
int noOfsheet =wb.getNumberOfSheets();
for(int i=0;i<noOfsheet;i++){
HSSFSheet sheet = wb.getSheetAt(i);
String wbName =sheet.getSheetName();
Iterator<Row> rowIterator = sheet.iterator();
while(rowIterator.hasNext()){
Row row = rowIterator.next();
Iterator<Cell> cellIterator = row.iterator();
String rowString="";
while(cellIterator.hasNext()){
Cell cell = cellIterator.next();
rowString=rowString+cell.toString()+" ; ";
System.out.println(rowString);
}
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}