Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Export to Excel with Column Header

ratana_pouy
Participant
0 Likes
3,831

Dear All,

I develop one report in SAP by using ABAP code, but i wonder, when i export as a excel file, it doesn't show the column header.

So, i do i do?

Please help....

Thank,

Ratana, Cambodia

Hi Ratana,

Please Check dis Demo Program which is given by SAP .

BCALV_GRID_08

BCALV_GRID_DEMO

BCALV_GRID_01

========================

Using OLE automation (download data in Excel with header)

RSDEMO01

Regard's

Smruti

8 REPLIES 8
Read only

gouravkumar64
Active Contributor
0 Likes
1,896

Hi,

R u using TOP OF PAGE? For header purpose.

check for related code &

Then check this thread for ur explanation.

http://scn.sap.com/thread/3160322

This is the link that will help u for Overview of EXCEL download.

http://scn.sap.com/community/abap/blog/2010/07/12/abap2xlsx--generate-your-professional-excel-spread...

Check sap notes 1517329 also.

Hope it helps.

Thanks

Gourav.

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,896

Hi,

Recently I wrote this program.

It is for sending mail using cl_bcs.

In "FORM mail_1_prep_3" I am sending csv file (compatible with excel) that is based on internal table.

The heading in this csv file is based on the resut of cl_salv_ddic=>get_by_data .

I hope it will help.

Regards.

Read only

0 Likes
1,896

Hi Ratana,

Are you downloading the excel from an ALV output or directly by using FM?

Read only

0 Likes
1,896

Hi Aniket Zanzan,

I am downloading the excel from an ALV output.

What's wrong with this?

Read only

0 Likes
1,896

Hi Ratana,

There is nothing wrong in it. If the file has to be downloaded everytime the report executes, then maybe you could directly download it using an FM as you have the required data in an internal table.

Read only

Former Member
0 Likes
1,896

Hi Ratana,

Please Check dis Demo Program which is given by SAP .

BCALV_GRID_08

BCALV_GRID_DEMO

BCALV_GRID_01

========================

Using OLE automation (download data in Excel with header)

RSDEMO01

Regard's

Smruti

Read only

Former Member
0 Likes
1,896

Hi Ratana,

Refer to thelink

http://scn.sap.com/thread/3160322

Hope this helps.

Thanks,

Tooshar Bendale

Read only

Former Member
0 Likes
1,896

Hi Ratana ,

As you said u are using the ALV output for exporting the excel file.

Please use the below snippet.

I was having the same problem like you, when user export to excel. I fixed it by using :-

w_layo-colwidth_optimize = 'X'. <<<<<<<<<<<<This

perform generate_fcat_reftab

    using 'PRUEFLOS' 'T_INPUT' '' '' 'Inspection Lot' 0.

form generate_fcat_reftab  using    p_fieldname

                                    p_tabname

                                    p_ref_tabname

                                    p_ref_fieldname

                                    p_output_text

                                    p_output_lenght.

clear w_fcat.

  w_fcat-fieldname = p_fieldname.

  w_fcat-tabname   = p_tabname.

  w_fcat-ref_fieldname = p_ref_fieldname.

  w_fcat-ref_tabname = p_ref_tabname.

  w_fcat-seltext_s = p_output_text.

  w_fcat-seltext_m = p_output_text.

  w_fcat-seltext_l = p_output_text.

  w_fcat-outputlen = p_output_lenght.

  w_fcat-ddictxt = 'L'. <<<<<<<<<<<<<<<<<<This

  append w_fcat to t_fcat.

endform.

Hope  : This will resolve your issue.