cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting data to Excel

Former Member
0 Kudos

Hi Experts ,

I have a requirement where i would like to display the data from an internal table into an Excel sheet on the click of a user defined button .

I am not displaying a ll these fields in an ALV , yet i want them to be exported to the excel .

Can anyone help me out with this .

Thanks and Regards ,

Radhika .

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi radhika........

you will be having your values in an internal table.

now in the on action method,

call the function gui_download and pass teh internal table to it.

the file type must be 'ASC' and the filename must be <filename>.xls.

---regards,

alex b justin

Former Member
0 Kudos

Can i use 'Gui_Download ' in Webdynpro..

Former Member
0 Kudos

hi radhika......

right now i am not able to work on that.... anyway you can try it.

---regards,

alex b justin

Former Member
0 Kudos

1) First read all the table data into an internal table using get_static_attributes_table.

2) Then take all the internal table data into a string variable.

ex:

READ TABLE itab INTO wa_itab INDEX 0.

LOOP AT itab INTO wa_itab.

CONCATENATE wa_itab-carrid

wa_itab-connid

wa_date

wa_price

wa_currency

cl_abap_char_utilities=>newline INTO lo_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

endloop.

3) Convert the string variable to XSTRING format using FM.

ex:

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = lo_final_string

IMPORTING

buffer = lo_xstring.

4) Use below method:

wdr_task=>client_window->client->attach_file_to_response(

i_filename = " path to the word file

i_content = " lo_xstring-> your xstring variable

i_mime_type = 'EXCEL/WORD/NOTEPAD' ).

Hope that it does help you out. Award points if useful

Former Member
0 Kudos

Thanks Uday...

Very very useful answer...Got the desired output ..

Hey but 1 Question , the header is not getting displayed .

Any clue on that .

Radhika .

Former Member
0 Kudos

hi radhika.........

the header will not be displayed automatically.

what you can do is insert the header contents in to the string expicitly before looping it.

---regards,

alex b justin

Former Member
0 Kudos

Ya i did teh same ...thnx for the reply ..

Former Member
0 Kudos

Hi Uday ,

For a few records im getting #NAME? in the cell but when i click on the cell i see the required text preceded by = sign.

Any clue on why this is happening...

Thanks ,

Radhika .

Answers (0)