Application Development 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: 

<?mso-application progid="Excel.Sheet"?> in XMLSS from SAP

martinborda
Explorer
0 Kudos

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.

1 ACCEPTED SOLUTION

RyanK
Explorer
0 Kudos

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

2 REPLIES 2

franois_henrotte
Active Contributor
0 Kudos

use method CREATE_SIMPLE_ELEMENT in order to create your node before the Workbook

RyanK
Explorer
0 Kudos

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