on 02-26-2010 3:19 PM
Hi ,
I could succesfully develope an application for uploading an excel file and displaying the data in tabular format (i.e through table display ) . But on Action <<Export TO Table>> it is not showing the details in tabular format . After uploadinfg file it is providing successful msg but when i m clicking on Export to table it is not displaying table data .
Its a demo WD program in java given below
Could anybody please guide me in this approach ?
public void onActionUploadFileData(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
InputStream text = null;
int temp = 0 ;
String path ;
try
{
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
FileOutputStream output = new FileOutputStream(file);
if (wdContext.currentContextElement().getResource()!= null )
{
text = wdContext.currentContextElement().getResource().read(false);
while ((temp=text.read())!= -1)
{
output.write(temp);
}
}
output.flush();
output.close();
path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void onActionExport_To_Table(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionExport_To_Table(ServerEvent)
try {
Workbook workbook = Workbook.getWorkbook(new File(path));
Sheet sheet = workbook.getSheet(0);
int columns = sheet.getColumns();
int rows = sheet.getRows();
int i=0;
int j;
for (j=1;j<=rows;j++)
{
element = wdContext.nodeTableData().createTableDataElement();
Cell cell1 = sheet.getCell(i,j);
element.setEmpId(cell1.getContents());
Cell cell2 = sheet.getCell(i+1,j);
element.setFirstname(cell2.getContents());
Cell cell3 = sheet.getCell(i+2,j);
element.setLastname(cell3.getContents());
wdContext.nodeTableData().addElement(element);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
Edited by: Trina_Saheli on Feb 26, 2010 4:22 PM
Hi trina,
i have found two issues in this
1) check whenther you have added the JExcelApi in the class path.
2) Please remove the line String path from the 0nActionUploadFileData() method please declare the same in the global declarations part as it is using the same in the another method.
please do this you will resolve this issue.
post me further updates
Thanks,
SG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Trina,
Please have a look at below link.
GOOD- [Uploading excel file using WebDynpro for Java|http://wiki.sdn.sap.com/wiki/display/WDJava/UploadingexcelfileusingWebDynproforJava]
[Reading Multiple Sheets of Excel Sheet from Java|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4183] [original link is broken] [original link is broken] [original link is broken];
[Reading Excel Sheet from Java without using any Framework|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4113] [original link is broken] [original link is broken] [original link is broken];
Hope this helps.
Regards,
Arun
Edited by: Arun Jaiswal on Mar 12, 2010 1:45 AM
Edited by: Arun Jaiswal on Mar 12, 2010 1:45 AM
Hi Trina,
Check onAction method(onActionExporttotable) of "Export to Table ". Print the c1.getContents(), c2.getContents,c3.getContents value with MessageManager while setting vaule to node attribute.
Once the all the attribute added to node TableData, print the table attribute in onActionExporttotable method itself.
Also check the TableData node properties which is bind to table of displaying in the screen.
Hopt it helps
Regards,
Arun
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.