on 05-09-2008 6:10 AM
Hi Experts
I am following the Blog to upload a file in to the webdynpro context,but my problem is after uploading a excel file i need to extract the content from that Excel file and that content should be displayed in the webdynpro table.Can any body please guide me how to read the content from excel and to Display in the Table.
Thanks and Regards
Kalyan
HI,
Take for example, if Excel file contains 4 fields,
Add jxl.jar to JavaBuild path and Use this snippet
File f=new File("sample.xls");
Workbook w=Workbook.getWorkbook(f);
Sheet sh=w.getSheet(0);
int cols=sh.getColumns();
int rows=sh.getRows();
Cell c=null;
String s1=null;
String s2=null;
String s3=null;
String s4=null;
ArrayList al=new ArrayList();
int j=0;
for(int i=1;i<rows;i++)
{
ITableElement table=wdContext.createTableElementz
s1=sh.getCell(0,i).getContents();
s2=sh.getCell(1,i).getContents();
s3=sh.getCell(2,i).getContents();
s4=sh.getCell(3,i).getContents();
table.setName(s1);
table.setAddress(s2);
table.setDesignation(s3);
table.setDummy(s4);
al.add(j,table);
j++;
}
wdContext.nodeTable().bind(al);
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can make use of POI from apache to do the reading of excel.
other option is to make use of jxl http://jexcelapi.sourceforge.net/
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.