Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

DTAB to Excel-Download


i'm trying to "convert" an DATB to an Excel-XML-file.

For realizing this, i'm using the cl_ixml-class and different if_ixml_...-interfaces.

The structure of an Excel-XML-file I copied from an example-file which I created with Excel.

When an user accesses a certain homepage, as the result he will get an excel-file-download (xstring).

Basically the file is successfully created but I can't open it with excel. But when I show the xml-string in the browser, copy it from there to an extra-file and start it with excel, it is working. But if i try to save it via "File -> Save Page as..." it does not work too.

In the last case, if I remove all indentions it does work.

Does anybody know what I'm doing wrong? I think it has to do anything with the charset!?

Thanks for your help, Stefan

Some Code that may help to find my problem:

* Variables for rendering
  DATA:   lirv_renderer  TYPE REF TO if_ixml_renderer,       "Renderer
          lirv_encoding  TYPE REF TO if_ixml_encoding,       "Encoding
          lirv_ostream   TYPE REF TO if_ixml_ostream,        "Octetstream
          lirv_factory   TYPE REF TO if_ixml_stream_factory, "Streamfactory
          lv_xstring     TYPE xstring.

* create factory
  lirv_factory = lr_if_ixml->create_stream_factory( ).

* create ostream
  lirv_ostream = lirv_factory->create_ostream_xstring( string = lv_xstring ).

* set encoding
  lirv_encoding = lr_if_ixml->create_encoding( character_set = 'iso-8859-1' byte_order = 0 ).  "iso-8859-1
  lirv_ostream->set_encoding( encoding = lirv_encoding ).

* Set Pretty Print
  lirv_ostream->set_pretty_print( pretty_print = 'X' ).

* create renderer
  lirv_renderer = lr_if_ixml->create_renderer( ostream  = lirv_ostream document = lr_if_document ).

* render
  lirv_renderer->render( ).
  ev_responsexstring = lv_xstring.

  DATA: conv TYPE REF TO cl_abap_conv_in_ce.
  conv = cl_abap_conv_in_ce=>create( input = lv_xstring ).
  conv->read( IMPORTING data = content ).

  DATA l_xlength TYPE i.

    name = if_http_header_fields=>content_type
    value = 'iso-8859-1' ).
  l_xlength = XSTRLEN( lv_xstring ).
  response->set_data( data   = lv_xstring
                     length = l_xlength ).

Former Member
Not what you were looking for? View more on this topic or Ask a question