cancel
Showing results for 
Search instead for 
Did you mean: 

How to export Table data in Excel with WebDynpro java

Former Member
0 Kudos

Hi Friend,

Can any one please tell me the code for exporting table data into an excel sheet.

The scenario is, I have a Value node called "Groups" and the Attributes are "groupId" & "groupName".

I have done the coding to display those details into a table. Now I just want to export this table values to a excel sheet through a button.

I have already created one External Library file with Apache poi 2.5.1-final.jar & poi 2.5.1-contrib.jar files. After that I have created the public checks "Compilation" & "Assembly" for each .jar files and finally I have added this ext lib file into original project as "Used DC".

But after that I am getting stuck into the coding part to exporting the table value into excel. I am very new to the Web Dynpro java and I do not have any other developer in WedDynpro java in my location. So please some one help me in this matter.

Accepted Solutions (0)

Answers (2)

Answers (2)

michael_voss2
Participant
0 Kudos

Hi!

Although I'd recommend to iterate over the underlying business object model collection (whatever that may be), you should be able to iterate over the elements of node "Groups" with something like (untested)

IPrivateMyView.IGroupsNode node = wdContext.nodeGroups();

int elements = node.size();

for (int i = 0; i < elements; i++)

{

  IGroupsElement group = wdContext.nodeGroups().getGroupsElementAt(i);

  int id = group.getGroupId();

  String groupName = group.getGroupName();

  // Do something with these objects in your poi document

  // Another way would be to iterate over the column info of the node

  // and to access the attributes using getAttributeValue(attributeName)

  // Iterator iter = node.getNodeInfo().iterateAttributes();

};

BTW this is pretty much as in Sandips example, which creates an XML file instead of using POI.

HTH

Michael

SandipAgarwalla
Active Contributor
0 Kudos

what is your Server, and NWDS version?

Refer this wiki for detailed steps

SAP Community Network Wiki - Code Gallery - Web Dynpro Java - Exporting Table Data Using On-Deman...

Sandip

Former Member
0 Kudos

Hi Sandip, thanks for your quick reply.

I am using NWDS 7.0.1.