09-04-2007 4:20 PM
I must generate an XML StyleSheet file, like this:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
...
My problem is that when I can't generate the line:
<?mso-application progid="Excel.Sheet"?>
as the first line SAP generates automatically, and then I add the first element "Workbook".
My code:
TYPE-POOLS: abap.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
CONSTANTS c_encoding TYPE string VALUE 'UTF-8'.
DATA: o_ixml TYPE REF TO if_ixml,
o_stream_factory TYPE REF TO if_ixml_stream_factory,
o_encoding TYPE REF TO if_ixml_encoding,
o_ostream TYPE REF TO if_ixml_ostream,
o_xmldoc TYPE REF TO if_ixml_document.
DATA: i_xml_table TYPE STANDARD TABLE OF xml_line,
v_xml_size TYPE i.
o_ixml = cl_ixml=>create( ).
o_stream_factory = o_ixml->create_stream_factory( ).
o_encoding = o_ixml->create_encoding(
character_set = c_encoding
byte_order = if_ixml_encoding=>co_little_endian ).
o_ostream = o_stream_factory->create_ostream_itable(
i_xml_table ).
o_ostream->set_encoding( encoding = o_encoding ).
o_xmldoc = o_ixml->create_document( ).
o_xmldoc->set_encoding( o_encoding ).
o_xmldoc->set_standalone( abap_true ).
DATA: o_workbook TYPE REF TO if_ixml_element.
o_workbook = o_xmldoc->create_simple_element(
name = 'ss:Workbook'
parent = o_xmldoc ).
DATA: o_renderer TYPE REF TO if_ixml_renderer.
o_renderer = o_ixml->create_renderer( ostream = o_ostream
document = o_xmldoc ).
o_renderer->render( ).
v_xml_size = o_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = v_xml_size
filename = 'c:\Documents and Settings\martin.borda\Desktop\a.xml'
filetype = 'BIN'
CHANGING
data_tab = i_xml_table.
Thanks in advance.
09-28-2007 9:45 PM
Here is how I did it in my app:
excel_pi = xml_doc->create_pi_parsed( name = 'mso-application' ).
excel_pi->set_attribute( name = 'progid'
value = 'Excel.Sheet').
xml_doc->append_child( excel_pi ).
- Ryan
09-28-2007 10:48 AM
use method CREATE_SIMPLE_ELEMENT in order to create your node before the Workbook
09-28-2007 9:45 PM
Here is how I did it in my app:
excel_pi = xml_doc->create_pi_parsed( name = 'mso-application' ).
excel_pi->set_attribute( name = 'progid'
value = 'Excel.Sheet').
xml_doc->append_child( excel_pi ).
- Ryan