04-12-2006 6:43 PM - last edited on 02-04-2024 3:40 AM by postmig_api_4
Hello,
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.
response->set_header_field(
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 ).
04-13-2006 12:47 PM
Hello,
after searching for hours I have found the errors. The way I sent the data to the Browser was ok but anyhow I added at one position one colon to much. At another position i did have to convert an i-value into a string-value before i could attach it to the xml-structure. Unfortunately I forgot, that automatically a space would be added to the strings.
But now it is working
Kind regards, Stefan