cancel
Showing results for 
Search instead for 
Did you mean: 

Export an internal table as a downloadable Excel file

Former Member
0 Kudos

Hi,

I'm making an ABAP Web Dynpro where an user can extract some data as an Excel spreadsheet (XLS or XLSX format).

I have the data in an internal table.

I would like to generate a valid Excel file (i.e. not a CSV with an XLS extension, if that is possible) by taking a subset of the columns of my internal table and using a custom header line (i.e. the headers should not be taken from the data domain - e.g.: field with type Datum should show "First day" instead of the generic "Date").

The resulting Excel file should then be offered to the user to be downloaded.

Can someone suggest me a way to achieve that?

Let me know if what I've written isn't clear.

Thanks!

Pietro

Accepted Solutions (1)

Accepted Solutions (1)

matteo_montalto
Contributor
0 Kudos

Hi Pietro,

you could try implementing an ALV table with your data, it directly offers an "export to xls" button which could make your job easier... I think you could the customize the standard behaviour from there.

Check out this tutorial to make an ALV table within a WD application: http://www.sapdev.co.uk/sap-webapps/sap-webdynpro/wdp-alv.htm

Former Member
0 Kudos

Hi Matteo,

thank you for your reply.

What if I shouldn't show the table to the user but only have to offer him to download the data (i.e. show a single "Export to Excel" button?

Is there another way to achieve that?

Thanks,

Pietro

matteo_montalto
Contributor
0 Kudos

There are multiple approaches, as far as I've seen.

Have a look at the following tutorial:

http://saptechnical.com/Tutorials/WebDynproABAP/Export/toexcel3.htm

(I linked the third page as it contains a sketch of code which could help you, but you'd better read the whole article).

This is imho the simplest approach.

The following one is a bit more complicated as it builds up an XML (quite verbose) :

http://scn.sap.com/docs/DOC-25024

Hope it helps

Former Member
0 Kudos

This message was moderated.

Answers (0)