Skip to Content
author's profile photo Former Member
Former Member

how to export the data from table to excel sheet

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2010 at 11:11 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2010 at 04:51 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 24, 2012 at 05:44 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.