cancel
Showing results for 
Search instead for 
Did you mean: 

exporting table data to excel sheet

Former Member
0 Kudos

Hi Experts,

I have a requirement in which I have to download the content of the table into excel sheetor CSv.How to acheive this .

As I am new to wdjava so please share me any tutorial or demo project which can solve my problem.

regards,

Anand

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anand

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-tec...

/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache

/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities

Ready to use project available in this code gallery

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/webDynproJava-ExportingTableDataUsingOn-DemandStreams-SAPNW+7.0

Thanks

Tulasi Palnati

Edited by: Tulasi Palnati on Jun 19, 2009 11:21 AM

Edited by: Tulasi Palnati on Jun 19, 2009 11:41 AM

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

Call this method to export data from a node to excel.

public com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource Export2Excel( com.sap.tc.webdynpro.progmodel.api.IWDNode node )

{

IWDResource ExcelFile = null;

String xmlfile ="";

xmlfile=xmlfile+ "<?xml version='1.0' encoding='ISO-8859-1'?>";

xmlfile=xmlfile+ "<TableData>";

int size = node.size();

node.moveFirst();

// Looping for all the records..

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

{

xmlfile=xmlfile+"<Data>";

//Looping for all the attributes

for (java.util.Iterator j= node.getNodeInfo().iterateAttributes(); j.hasNext();)

{

IWDAttributeInfo AttInfo = (IWDAttributeInfo)j.next();

xmlfile=xmlfile"<"AttInfo.getName()">" ; xmlfile=xmlfilenode.getCurrentElement().getAttributeValue(AttInfo.getName());

xmlfile=xmlfile"</"AttInfo.getName()+">" ;

}

xmlfile=xmlfile+"</Data>";

node.moveNext();

}

xmlfile=xmlfile+ "</TableData>";

ExcelFile = (IWDResource) WDResourceFactory.createResource(xmlfile.getBytes(),"Table Data",WDWebResourceType.XLS);

return ExcelFile;

}

Use This method.. Pass the node which you want to export the data.

This method will return a variable of Resource type set that in ur context attribute say 'ExcelFile'.

Create a FileDownload Ui Element.Bind the context attribute 'ExcelFile' to data and resorce.

Best Wishes

Idhaya R

Former Member
0 Kudos

Hi,

There are two ways for downloading the table data to MS Excel.

1. Using WD Binary Cache:

Tutorial: "Excel Export Using the Web Dynpro Binary Cache" in the below link:

[original link is broken]

2. Using JXL Api:

Tutorial: /people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache

As per my analysis and knowledge JXL Api approach is the better approach than WebDynpro binary cache approach in both performace and usability.

Some disadvantages using WebDynpro binary cache:

When we download the table data to excel using WebDynpro binary cache, At runtime first it converts the data into XML file and using this xml data the Excel sheet creates the schema.

Converting the runtime data to xml takes some time when there is huge data. So this is a performance issue.

Along with this there is usability issue also. That is it opens a popup by showing the below options to the user while downloading:

As an XML list

An XML list is created in a new workbook.

The contents of the file are imported into the XML list. If the XML data file does not refer to a schema, then Microsoft Excel will infer the schema of the XML data file.

As a read-only workbook

The XML data file is opened as a read-only workbook. The structure of the file is flattened.

Use the XML Source task pane

The schema of the XML data file is displayed in the XML Source task pane. You can then drag elements of the schema to the worksheet to map those elements to the worksheet. If you are opening an XML data file that does not refer to a schema, then Excel will infer the schema of the XML data file.

We can test this scenario by just opening an xml file with MS Excel also.

Hope this gives you requried information.

Regards,

Charan

Former Member
0 Kudos

Hi Anand,

Please check the following links:

/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a9...

Regards.

Rajat