cancel
Showing results for 
Search instead for 
Did you mean: 

how to export the data from table to excel sheet

Former Member
0 Kudos

hi experts i have some problem am trying to export the data fro table to Excel sheet in the view controller i have created one button wit public void onActionCLEAR(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionCLEAR(ServerEvent)

//wdContext.nodeBapi_Salesorder_Getlist_Input().

//wdContext.nodeBapi_Salesorder_Getlist_Input().invalidate();

//@@end

}

//@@begin javadoc:onActionExporToExcel(ServerEvent)

/** Declared validating event handler. */

//@@end

public void onActionExporToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionExporToExcel(ServerEvent)

try{

FileOutputStream fos=new FileOutputStream("Test.xls");

PrintStream ps=new PrintStream(fos);

ps.println("<html><body><table border=1>");

int size=wdContext.nodeBapi_Salesorder_Getlist_Input().size();

Iterator attributes=wdContext.getNodeInfo().iterateAttributes();

ps.println("<tr>");

while(attributes.hasNext()){

ps.println("<th>");

DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();

ps.println(attrName.getName());

ps.println("</th>");

}

ps.println("</tr>");

for(int i=0; i<wdContext.nodeBapi_Salesorder_Getlist_Input().size();i++)

{

attributes=wdContext.getNodeInfo().iterateAttributes();

ps.println("<tr>");

IWDNodeElement ele=wdContext.getElementAt(i);

while(attributes.hasNext()){

ps.println("<td>");

DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();

ps.println(""+ele.getAttributeAsText(attrName.getName()));

ps.println("</td>");

}

ps.println("</tr>");

}

ps.println("</table></body></html>");

ps.flush();

ps.close();

fos.close();

}

catch(Exception e){

wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);

}

finally{

//return("Test.xls") ;

}

//@@end

}h action and i have return the code

its running sucessfully but am not able to perform the action plz help me

Accepted Solutions (0)

Answers (3)

Answers (3)

ratish_rao
Explorer
0 Kudos

How can i import DataAttributeInfo..? i am using CE 7.2.. pls help

Qualiture
Active Contributor
0 Kudos

Hi,

You shouldn't use DataAttributeInfo as it is an internal object, if I'm correct.

Use IWDAttributeInfo instead of DataAttributeInfo and it should work

(See also API doc of IWDNodeInfo.iterateAttributes() at http://help.sap.com/javadocs/nwce/ce711sp02/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDNo...)

Cheers,

Robin

Former Member
0 Kudos

its running sucessfully but am not able to perform the action plz help me

What do you mean by that, can you be more clear?

Regards,

Anton

Edited by: Anton Dimitrov on Jan 22, 2010 5:51 PM

ratish_rao
Explorer
0 Kudos

How can i import DataAttributeInfo..? i am using CE 7.2.. pls help

Former Member
0 Kudos

hi

check this link

/docs/DOC-8061#58 [original link is broken]

you can download the sap standard project and use the component in your project for export to execel

functionality .

Thanks