cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting table to excel.

Former Member
0 Kudos

Hello,

I followed this [excellent blog|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3596] [original link is broken] [original link is broken] [original link is broken]; and able to export table into excel. Although, when I open the file, the file download pop-up shows a random name for the file. Is it possible to use a pre-defined name based on context attribute ?

When I click open the file, I then get another pop-up with 3 radio buttons to choose from

As an XML list

As a read-only workbook

Use the XML Sourse task pane.

How can I by pass this pop-up and directly open the excel file ?

Thanks

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

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,

Try to use jexcelapi to export the data to excel.

jexcelapi is a open source java API enabling developers to read, write, and modifiy Excel spreadsheets dynamically.

Check this blog

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

Regards,

Saleem

tom_cole3
Explorer
0 Kudos

Another library to consider is the POI from Apache: [Apache POI|http://poi.apache.org]

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Srinivas,

You need to specify the schema while creating the xml file in your code.

Refer this blog

/people/amitkumar.singh/blog/2008/11/30/formatted-excel-using-on-demand-stream-without-ext-apis

In this blog he talks about excel formatting. Here you will get an idea how to give style sheet to the xml document.

A Sample xml which will open without that dialog box..

-


<?xml version="1.0"?><ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"><ss:Styles><ss:Style ss:ID="1"><ss:Font ss:Color="red" ss:Bold="1"/></ss:Style></ss:Styles><ss:Worksheet ss:Name="Excel Sheet"><ss:Table ><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Column ss:Width="150"/><ss:Row ss:StyleID="1"><ss:Cell><ss:Data ss:Type="String">Value12</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">Value23</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">Value34</ss:Data></ss:Cell></ss:Row><ss:Row><ss:Cell><ss:Data ss:Type="String">0StingVale1</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">String0</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">0Value3</ss:Data></ss:Cell></ss:Row><ss:Row><ss:Cell><ss:Data ss:Type="String">1StingVale1</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">String1</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">1Value3</ss:Data></ss:Cell></ss:Row><ss:Row><ss:Cell><ss:Data ss:Type="String">2StingVale1</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">String2</ss:Data></ss:Cell><ss:Cell><ss:Data ss:Type="String">2Value3</ss:Data></ss:Cell></ss:Row></ss:Table></ss:Worksheet></ss:Workbook>

-


Best Wishes

Idhaya R

Former Member
0 Kudos

Hi,

Folllow the code snippet as given below:

IWDResource resource = WDResourceFactory.createResource(new FileInputStream(f), formattedReportName,WDWebResourceType.XLS,true);

IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(

resource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal()),formattedReportName);

window.show();