Skip to Content
avatar image
Former Member

pbm with downloading internal table to excel

Hi Experts ,

I have to download an internal table to an excel sheet. I have tried the code given below.

But this is not giving me desired output in excel.

method ATTACH_FILES .

*data:

  • conv_out type ref to cl_abap_conv_out_ce,

  • content type xstring.

*

*

*

*

  • conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

*

data : itab_sflight type table of sflight.

data: xml_out TYPE string.

data: conv_out type ref to cl_abap_conv_out_ce.

data: content1 type xstring.

import itab_sflight1 to itab_sflight from MEMORY ID 'ZCA'.

call transformation ('ID') source tab = itab_sflight result xml xml_out.

conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = xml_out

  • MIMETYPE = ' '

  • ENCODING =

IMPORTING

BUFFER = content1

  • EXCEPTIONS

  • FAILED = 1

  • OTHERS = 2

.

  • attach the first file

conv_out->convert( exporting data = content1 ).

cl_wd_runtime_services=>attach_file_to_response(

i_filename = 'file1.XLS'

i_content = content1

i_mime_type = 'application/msexcel'

i_in_new_window = i_in_new_window

i_inplace = i_inplace ).

endmethod.

The output in excel is coming in Xml format.

like <carrid>lh<\carrid><seatno>value<\seatno> and so on

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jul 12, 2007 at 02:27 PM

    Hello shaheen,

    yups i have same problem here.See if you try to open up your XML output

    in MS- Excel 2003 version (11.8117.8107 OR later ) SP2 you will face problem beacuse excel will not ask you for wherther you want to open file as "XML LIST".But my colleague in diffrent country they have version 2003 (11.5612.5606)

    you can see its not the latest whenever they open downloaded file,excel ask them to open in "XML LIST" and output is perfect.So i guess its problem with EXCEL.

    NIRAD

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      See we swtched to ALV and ALV gives us perfect output in EXCEL.You install office 2003 and check it out or try to open that as XML lsit...or there is a XML reader add on available in excel so install that add on and check can u do it or not.

      Nirad