Hi All,
I have gone through SDN and am following this weblog to read an Excel file using POI api. I am using JSPDynpage.
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1405
I basically want to read the contents of an excel file and pass them to a function module.
Following is my code :
public void readfile(){
System.err.println("readfile called");
try{
System.err.println("inside try");
InputStream fs = new FileInputStream("c:/GL/Book3.xls");
//POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Book3.xls"));
System.err.println("created filesystem");
HSSFWorkbook wb = new HSSFWorkbook(fs);
System.err.println("created workbook");
HSSFSheet sheet = wb.getSheetAt(0);
System.err.println("picked up sheet");
for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {
HSSFRow row = (HSSFRow)rit.next();
System.err.println("first FOR printing row :- " + row);
for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {
HSSFCell cell = (HSSFCell)cit.next();
System.err.println("second FOR printing cell :- " + cell.getStringCellValue()+"\t");
}
}
}catch(Exception e){
System.out.print("Exception Occured " + e.toString());
}
}
The problem that im facing with the above code is that It prints till the line : System.err.println("inside try"); and after that there is no output.
Any suggestions ?
Request clarification before answering.
I think the problem seems to be here :
InputStream fs = new FileInputStream("c:/GL/Book3.xls");
I have attached the excel sheet in my project folder which is below the "dist" folder. It is like this MyProject->Book3.xls
Any Ideas on how I can pass this excel sheet from the above project folder to
InputStream fs = new FileInputStream(".....xls");
Thanks,
Edited by: S.B on May 27, 2008 4:07 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.