abap2xlsx/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk
Ivan Femia d3f95ed657 Macro-Enabled workbook issue #89
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@194 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2011-06-02 09:23:58 +00:00

4423 lines
252 KiB
XML

<?xml version="1.0" encoding="utf-16"?>
<CLAS CLSNAME="ZCL_EXCEL_WRITER_2007" VERSION="1" LANGU="E" DESCRIPT="Excel writer 2007" UUID="9551494D16947660E1000000C0A8FA28" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="FEMIA" CREATEDON="20100701" CHANGEDBY="FEMIA" CHANGEDON="20110601" CHGDANYON="00000000" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="702" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 ">
<implementing CLSNAME="ZCL_EXCEL_WRITER_2007" REFCLSNAME="ZIF_EXCEL_WRITER" VERSION="1" EXPOSURE="2" STATE="1" AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" RELTYPE="1" EDITORDER="0 "/>
<publicSection>class ZCL_EXCEL_WRITER_2007 definition
public
create public .
public section.
*&quot;* public components of class ZCL_EXCEL_WRITER_2007
*&quot;* do not include other source files here!!!
interfaces ZIF_EXCEL_WRITER .</publicSection>
<protectedSection>protected section.
*&quot;* protected components of class ZCL_EXCEL_WRITER_2007
*&quot;* do not include other source files here!!!
constants C_CONTENT_TYPES type STRING value &apos;[Content_Types].xml&apos;. &quot;#EC NOTEXT
constants C_DOCPROPS_APP type STRING value &apos;docProps/app.xml&apos;. &quot;#EC NOTEXT
constants C_DOCPROPS_CORE type STRING value &apos;docProps/core.xml&apos;. &quot;#EC NOTEXT
constants C_RELATIONSHIPS type STRING value &apos;_rels/.rels&apos;. &quot;#EC NOTEXT
constants C_XL_DRAWINGS type STRING value &apos;xl/drawings/drawing#.xml&apos;. &quot;#EC NOTEXT
constants C_XL_DRAWINGS_RELS type STRING value &apos;xl/drawings/_rels/drawing#.xml.rels&apos;. &quot;#EC NOTEXT
constants C_XL_RELATIONSHIPS type STRING value &apos;xl/_rels/workbook.xml.rels&apos;. &quot;#EC NOTEXT
constants C_XL_SHAREDSTRINGS type STRING value &apos;xl/sharedStrings.xml&apos;. &quot;#EC NOTEXT
constants C_XL_SHEET type STRING value &apos;xl/worksheets/sheet#.xml&apos;. &quot;#EC NOTEXT
constants C_XL_SHEET_RELS type STRING value &apos;xl/worksheets/_rels/sheet#.xml.rels&apos;. &quot;#EC NOTEXT
constants C_XL_STYLES type STRING value &apos;xl/styles.xml&apos;. &quot;#EC NOTEXT
constants C_XL_THEME type STRING value &apos;xl/theme/theme1.xml&apos;. &quot;#EC NOTEXT
constants C_XL_WORKBOOK type STRING value &apos;xl/workbook.xml&apos;. &quot;#EC NOTEXT
data EXCEL type ref to ZCL_EXCEL .
methods CREATE
returning
value(EP_EXCEL) type XSTRING .
methods CREATE_CONTENT_TYPES
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_DOCPROPS_APP
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_DOCPROPS_CORE
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_RELATIONSHIPS
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_DRAWINGS
importing
!IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_DRAWINGS_RELS
importing
!IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_RELATIONSHIPS
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_SHAREDSTRINGS
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_SHEET
importing
!IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET
!IV_ACTIVE type FLAG default &apos;&apos;
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_SHEET_RELS
importing
!IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET
!IV_DRAWING_INDEX type I
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_STYLES_COLOR_NODE
importing
!IO_DOCUMENT type ref to IF_IXML_DOCUMENT
!IO_PARENT type ref to IF_IXML_ELEMENT
!IV_COLOR_ELEM_NAME type STRING default &apos;color&apos;
!IS_COLOR type ZEXCEL_S_STYLE_COLOR .
methods CREATE_XL_STYLES
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_TABLE
importing
!IO_TABLE type ref to ZCL_EXCEL_TABLE
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_THEME
returning
value(EP_CONTENT) type XSTRING .
methods CREATE_XL_WORKBOOK
returning
value(EP_CONTENT) type XSTRING .</protectedSection>
<privateSection>private section.
*&quot;* private components of class ZCL_EXCEL_WRITER_2007
*&quot;* do not include other source files here!!!
constants C_OFF type STRING value &apos;0&apos;. &quot;#EC NOTEXT
constants C_ON type STRING value &apos;1&apos;. &quot;#EC NOTEXT
data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING .
data STYLES_COND_MAPPING type ZEXCEL_T_STYLES_COND_MAPPING .
data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING .
methods FLAG2BOOL
importing
!IP_FLAG type FLAG
returning
value(EP_BOOLEAN) type CHAR5 .
methods GET_SHARED_STRING_INDEX
importing
!IP_CELL_VALUE type ZEXCEL_CELL_VALUE
returning
value(EP_INDEX) type INT4 .</privateSection>
<localImplementation>*&quot;* local class implementation for public class
*&quot;* use this source file for the implementation part of
*&quot;* local helper classes</localImplementation>
<localTypes>*&quot;* use this source file for any type declarations (class
*&quot;* definitions, interfaces or data types) you need for method
*&quot;* implementation or private method&apos;s signature</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_CONTENT_TYPES" VERSION="1" LANGU="E" DESCRIPT="Content Type XML File Name" EXPOSURE="1" STATE="1" EDITORDER="1 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;[Content_Types].xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_DOCPROPS_APP" VERSION="1" LANGU="E" DESCRIPT="App XML File Name" EXPOSURE="1" STATE="1" EDITORDER="2 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;docProps/app.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_DOCPROPS_CORE" VERSION="1" LANGU="E" DESCRIPT="Core XML File Name" EXPOSURE="1" STATE="1" EDITORDER="3 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;docProps/core.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_OFF" VERSION="1" LANGU="E" DESCRIPT="Byte Value" EXPOSURE="0" STATE="1" EDITORDER="4 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" ATTDECLTYP="2" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_ON" VERSION="1" LANGU="E" DESCRIPT="Byte Value" EXPOSURE="0" STATE="1" EDITORDER="5 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" ATTDECLTYP="2" ATTVALUE="&apos;1&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_RELATIONSHIPS" VERSION="1" LANGU="E" DESCRIPT="Rels XML File Name" EXPOSURE="1" STATE="1" EDITORDER="6 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;_rels/.rels&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_DRAWINGS" VERSION="1" LANGU="E" DESCRIPT="xlDrawings XML File Name" EXPOSURE="1" STATE="1" EDITORDER="7 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/drawings/drawing#.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_DRAWINGS_RELS" VERSION="1" LANGU="E" DESCRIPT="xlDrawings XML File Name" EXPOSURE="1" STATE="1" EDITORDER="8 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/drawings/_rels/drawing#.xml.rels&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_RELATIONSHIPS" VERSION="1" LANGU="E" DESCRIPT="xlRels XML File Name" EXPOSURE="1" STATE="1" EDITORDER="9 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/_rels/workbook.xml.rels&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_SHAREDSTRINGS" VERSION="1" LANGU="E" DESCRIPT="xlSharedStrings XML File Name" EXPOSURE="1" STATE="1" EDITORDER="10 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/sharedStrings.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_SHEET" VERSION="1" LANGU="E" DESCRIPT="xlSheet XML File Name Template" EXPOSURE="1" STATE="1" EDITORDER="11 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/worksheets/sheet#.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_SHEET_RELS" VERSION="1" LANGU="E" DESCRIPT="xlSheetRels XML File Name Template" EXPOSURE="1" STATE="1" EDITORDER="12 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/worksheets/_rels/sheet#.xml.rels&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_STYLES" VERSION="1" LANGU="E" DESCRIPT="xlStyles XML File Name" EXPOSURE="1" STATE="1" EDITORDER="13 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/styles.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_THEME" VERSION="1" LANGU="E" DESCRIPT="xlTheme XML File Name" EXPOSURE="1" STATE="1" EDITORDER="14 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/theme/theme1.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="C_XL_WORKBOOK" VERSION="1" LANGU="E" DESCRIPT="xlWorkbook XML File Name" EXPOSURE="1" STATE="1" EDITORDER="15 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="2" ATTVALUE="&apos;xl/workbook.xml&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" EXPOSURE="1" STATE="1" EDITORDER="16 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="SHARED_STRINGS" VERSION="1" LANGU="E" DESCRIPT="Shared Strings" EXPOSURE="0" STATE="1" EDITORDER="17 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_T_SHARED_STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="STYLES_COND_MAPPING" VERSION="1" LANGU="E" DESCRIPT="Styles mapping" EXPOSURE="0" STATE="1" EDITORDER="18 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110530" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_T_STYLES_COND_MAPPING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="STYLES_MAPPING" VERSION="1" LANGU="E" DESCRIPT="Styles mapping" EXPOSURE="0" STATE="1" EDITORDER="19 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_T_STYLES_MAPPING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<interfaceMethod CLSNAME="ZCL_EXCEL_WRITER_2007" CPDNAME="ZIF_EXCEL_WRITER~WRITE_FILE">
<source>method ZIF_EXCEL_WRITER~WRITE_FILE.
me-&gt;excel = io_excel.
ep_file = me-&gt;create( ).
endmethod.</source>
</interfaceMethod>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE" VERSION="1" LANGU="E" DESCRIPT="Create Excel" EXPOSURE="1" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE" SCONAME="EP_EXCEL" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE.
* Office 2007 file format is a cab of several xml files with extension .xlsx
DATA: lo_zip TYPE REF TO cl_abap_zip,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_active_worksheet TYPE REF TO zcl_excel_worksheet,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_nested_iterator TYPE REF TO cl_object_collection_iterator,
lo_table TYPE REF TO zcl_excel_table,
lo_drawing TYPE REF TO zcl_excel_drawing,
lo_drawings TYPE REF TO zcl_excel_drawings.
DATA: lv_content TYPE xstring,
lv_active TYPE flag,
lv_xl_sheet TYPE string,
lv_xl_sheet_rels TYPE string,
lv_xl_drawing TYPE string,
lv_xl_drawing_rels TYPE string,
lv_syindex TYPE string,
lv_value TYPE string,
lv_drawing_index TYPE i.
**********************************************************************
* STEP 1: Create archive object file (ZIP)
CREATE OBJECT lo_zip.
**********************************************************************
* STEP 2: Add [Content_Types].xml to zip
lv_content = me-&gt;create_content_types( ).
lo_zip-&gt;add( name = me-&gt;c_content_types
content = lv_content ).
**********************************************************************
* STEP 3: Add _rels/.rels to zip
lv_content = me-&gt;create_relationships( ).
lo_zip-&gt;add( name = me-&gt;c_relationships
content = lv_content ).
**********************************************************************
* STEP 4: Add docProps/app.xml to zip
lv_content = me-&gt;create_docprops_app( ).
lo_zip-&gt;add( name = me-&gt;c_docprops_app
content = lv_content ).
**********************************************************************
* STEP 5: Add docProps/core.xml to zip
lv_content = me-&gt;create_docprops_core( ).
lo_zip-&gt;add( name = me-&gt;c_docprops_core
content = lv_content ).
**********************************************************************
* STEP 6: Add xl/_rels/workbook.xml.rels to zip
lv_content = me-&gt;create_xl_relationships( ).
lo_zip-&gt;add( name = me-&gt;c_xl_relationships
content = lv_content ).
**********************************************************************
* STEP 6: Add xl/_rels/workbook.xml.rels to zip
lv_content = me-&gt;create_xl_theme( ).
lo_zip-&gt;add( name = me-&gt;c_xl_theme
content = lv_content ).
**********************************************************************
* STEP 7: Add xl/workbook.xml to zip
lv_content = me-&gt;create_xl_workbook( ).
lo_zip-&gt;add( name = me-&gt;c_xl_workbook
content = lv_content ).
**********************************************************************
* STEP 8: Add xl/workbook.xml to zip
* lv_content = me-&gt;create_xl_styles_static( ).
lv_content = me-&gt;create_xl_styles( ).
lo_zip-&gt;add( name = me-&gt;c_xl_styles
content = lv_content ).
**********************************************************************
* STEP 9: Add sharedStrings.xml to zip
lv_content = me-&gt;create_xl_sharedstrings( ).
lo_zip-&gt;add( name = me-&gt;c_xl_sharedstrings
content = lv_content ).
**********************************************************************
* STEP 10: Add sheet#.xml and drawing#.xml to zip
lo_iterator = me-&gt;excel-&gt;get_worksheets_iterator( ).
lo_active_worksheet = me-&gt;excel-&gt;get_active_worksheet( ).
lv_drawing_index = 1.
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_worksheet ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
IF lo_active_worksheet-&gt;get_guid( ) EQ lo_worksheet-&gt;get_guid( ).
lv_active = abap_true.
ELSE.
lv_active = abap_false.
ENDIF.
lv_content = me-&gt;create_xl_sheet( io_worksheet = lo_worksheet
iv_active = lv_active ).
lv_xl_sheet = me-&gt;c_xl_sheet.
MOVE sy-index TO lv_syindex.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xl_sheet WITH lv_syindex.
lo_zip-&gt;add( name = lv_xl_sheet
content = lv_content ).
lv_xl_sheet_rels = me-&gt;c_xl_sheet_rels.
lv_content = me-&gt;create_xl_sheet_rels( io_worksheet = lo_worksheet
iv_drawing_index = lv_drawing_index ).
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xl_sheet_rels WITH lv_syindex.
lo_zip-&gt;add( name = lv_xl_sheet_rels
content = lv_content ).
lo_nested_iterator = lo_worksheet-&gt;get_tables_iterator( ).
WHILE lo_nested_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_table ?= lo_nested_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_content = me-&gt;create_xl_table( lo_table ).
lv_value = lo_table-&gt;get_name( ).
CONCATENATE &apos;xl/tables/&apos; lv_value &apos;.xml&apos; INTO lv_value.
lo_zip-&gt;add( name = lv_value
content = lv_content ).
ENDWHILE.
* Add drawings **********************************
lo_drawings = lo_worksheet-&gt;get_drawings( ).
IF lo_drawings-&gt;is_empty( ) = abap_false.
MOVE lv_drawing_index TO lv_syindex.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
lv_content = me-&gt;create_xl_drawings( lo_worksheet ).
lv_xl_drawing = me-&gt;c_xl_drawings.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xl_drawing WITH lv_syindex.
lo_zip-&gt;add( name = lv_xl_drawing
content = lv_content ).
lv_content = me-&gt;create_xl_drawings_rels( lo_worksheet ).
lv_xl_drawing_rels = me-&gt;c_xl_drawings_rels.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xl_drawing_rels WITH lv_syindex.
lo_zip-&gt;add( name = lv_xl_drawing_rels
content = lv_content ).
ADD 1 TO lv_drawing_index.
ENDIF.
ENDWHILE.
**********************************************************************
* STEP 11: Add media
lo_iterator = me-&gt;excel-&gt;get_drawings_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_drawing ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_content = lo_drawing-&gt;get_media( ).
lv_value = lo_drawing-&gt;get_media_name( ).
CONCATENATE &apos;xl/media/&apos; lv_value INTO lv_value.
lo_zip-&gt;add( name = lv_value
content = lv_content ).
ENDWHILE.
**********************************************************************
* STEP 12: Create the final zip
ep_excel = lo_zip-&gt;save( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_CONTENT_TYPES" VERSION="1" LANGU="E" DESCRIPT="Create &apos;[Content_Types].xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_CONTENT_TYPES" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_CONTENT_TYPES.
** Constant node name
DATA: lc_xml_node_types TYPE string VALUE &apos;Types&apos;,
lc_xml_node_override TYPE string VALUE &apos;Override&apos;,
lc_xml_node_default TYPE string VALUE &apos;Default&apos;,
&quot; Node attributes
lc_xml_attr_partname TYPE string VALUE &apos;PartName&apos;,
lc_xml_attr_extension TYPE string VALUE &apos;Extension&apos;,
lc_xml_attr_contenttype TYPE string VALUE &apos;ContentType&apos;,
&quot; Node namespace
lc_xml_node_types_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/content-types&apos;,
&quot; Node extension
lc_xml_node_rels_ext TYPE string VALUE &apos;rels&apos;,
lc_xml_node_xml_ext TYPE string VALUE &apos;xml&apos;,
&quot; Node partnumber
lc_xml_node_theme_pn TYPE string VALUE &apos;/xl/theme/theme1.xml&apos;,
lc_xml_node_styles_pn TYPE string VALUE &apos;/xl/styles.xml&apos;,
lc_xml_node_workb_pn TYPE string VALUE &apos;/xl/workbook.xml&apos;,
lc_xml_node_props_pn TYPE string VALUE &apos;/docProps/app.xml&apos;,
lc_xml_node_worksheet_pn TYPE string VALUE &apos;/xl/worksheets/sheet#.xml&apos;,
lc_xml_node_strings_pn TYPE string VALUE &apos;/xl/sharedStrings.xml&apos;,
lc_xml_node_core_pn TYPE string VALUE &apos;/docProps/core.xml&apos;,
&quot; Node contentType
lc_xml_node_theme_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.theme+xml&apos;,
lc_xml_node_styles_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml&apos;,
lc_xml_node_workb_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml&apos;,
lc_xml_node_rels_ct TYPE string VALUE &apos;application/vnd.openxmlformats-package.relationships+xml&apos;,
lc_xml_node_xml_ct TYPE string VALUE &apos;application/xml&apos;,
lc_xml_node_props_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.extended-properties+xml&apos;,
lc_xml_node_worksheet_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml&apos;,
lc_xml_node_strings_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml&apos;,
lc_xml_node_core_ct TYPE string VALUE &apos;application/vnd.openxmlformats-package.core-properties+xml&apos;,
lc_xml_node_table_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml&apos;,
lc_xml_node_drawings_ct TYPE string VALUE &apos;application/vnd.openxmlformats-officedocument.drawing+xml&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_nested_iterator TYPE REF TO cl_object_collection_iterator,
lo_table TYPE REF TO zcl_excel_table.
DATA: lv_worksheets_num TYPE i,
lv_worksheets_numc TYPE numc3,
lv_xml_node_worksheet_pn TYPE string,
lv_xml_size TYPE i,
lv_value TYPE string,
lv_drawing_index TYPE i VALUE 1,
lv_index_str TYPE string.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;UTF-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node types
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_types
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_types_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; rels node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_default
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_extension
value = lc_xml_node_rels_ext ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_rels_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; extension node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_default
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_extension
value = lc_xml_node_xml_ext ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_xml_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Theme node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lc_xml_node_theme_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_theme_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Styles node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lc_xml_node_styles_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_styles_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Workbook node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lc_xml_node_workb_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_workb_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Properties node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lc_xml_node_props_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_props_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Worksheet node
lv_worksheets_num = excel-&gt;get_worksheets_size( ).
DO lv_worksheets_num TIMES.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
MOVE sy-index TO lv_worksheets_numc.
SHIFT lv_worksheets_numc LEFT DELETING LEADING &apos;0&apos;.
lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lv_xml_node_worksheet_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_worksheet_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDDO.
lo_iterator = me-&gt;excel-&gt;get_worksheets_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_worksheet ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lo_nested_iterator = lo_worksheet-&gt;get_tables_iterator( ).
WHILE lo_nested_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_table ?= lo_nested_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_value = lo_table-&gt;get_name( ).
CONCATENATE &apos;/xl/tables/&apos; lv_value &apos;.xml&apos; INTO lv_value.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_table_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDWHILE.
&quot; Drawings
DATA: lo_drawings TYPE REF TO zcl_excel_drawings.
lo_drawings = lo_worksheet-&gt;get_drawings( ).
IF lo_drawings-&gt;is_empty( ) = abap_false.
lv_index_str = lv_drawing_index.
CONDENSE lv_index_str NO-GAPS.
CONCATENATE &apos;/&apos; me-&gt;c_xl_drawings INTO lv_value.
REPLACE &apos;#&apos; WITH lv_index_str INTO lv_value.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_drawings_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ADD 1 TO lv_drawing_index.
ENDIF.
ENDWHILE.
&quot; media mimes
DATA: lo_drawing TYPE REF TO zcl_excel_drawing,
lt_media_type TYPE TABLE OF mimetypes-extension,
lv_media_type TYPE mimetypes-extension,
lv_mime_type TYPE mimetypes-type.
lo_iterator = me-&gt;excel-&gt;get_drawings_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) = abap_true.
lo_drawing ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_media_type = lo_drawing-&gt;get_media_type( ).
COLLECT lv_media_type INTO lt_media_type.
ENDWHILE.
LOOP AT lt_media_type INTO lv_media_type.
CALL FUNCTION &apos;SDOK_MIMETYPE_GET&apos;
EXPORTING
extension = lv_media_type
IMPORTING
mimetype = lv_mime_type.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_default
parent = lo_document ).
lv_value = lv_media_type.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_extension
value = lv_value ).
lv_value = lv_mime_type.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDLOOP.
&quot; Strings node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lc_xml_node_strings_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_strings_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Strings node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_override
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_partname
value = lc_xml_node_core_pn ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_contenttype
value = lc_xml_node_core_ct ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_DOCPROPS_APP" VERSION="1" LANGU="E" DESCRIPT="Create &apos;docProps/app.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="3 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_DOCPROPS_APP" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_DOCPROPS_APP.
** Constant node name
DATA: lc_xml_node_properties TYPE string VALUE &apos;Properties&apos;,
lc_xml_node_application TYPE string VALUE &apos;Application&apos;,
lc_xml_node_docsecurity TYPE string VALUE &apos;DocSecurity&apos;,
lc_xml_node_scalecrop TYPE string VALUE &apos;ScaleCrop&apos;,
lc_xml_node_headingpairs TYPE string VALUE &apos;HeadingPairs&apos;,
lc_xml_node_vector TYPE string VALUE &apos;vector&apos;,
lc_xml_node_variant TYPE string VALUE &apos;variant&apos;,
lc_xml_node_lpstr TYPE string VALUE &apos;lpstr&apos;,
lc_xml_node_i4 TYPE string VALUE &apos;i4&apos;,
lc_xml_node_titlesofparts TYPE string VALUE &apos;TitlesOfParts&apos;,
lc_xml_node_company TYPE string VALUE &apos;Company&apos;,
lc_xml_node_linksuptodate TYPE string VALUE &apos;LinksUpToDate&apos;,
lc_xml_node_shareddoc TYPE string VALUE &apos;SharedDoc&apos;,
lc_xml_node_hyperlinkschanged TYPE string VALUE &apos;HyperlinksChanged&apos;,
lc_xml_node_appversion TYPE string VALUE &apos;AppVersion&apos;,
&quot; Namespace prefix
lc_vt_ns TYPE string VALUE &apos;vt&apos;,
lc_xml_node_props_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/extended-properties&apos;,
lc_xml_node_props_vt_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes&apos;,
&quot; Node attributes
lc_xml_attr_size TYPE string VALUE &apos;size&apos;,
lc_xml_attr_basetype TYPE string VALUE &apos;baseType&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_sub_element_vector TYPE REF TO if_ixml_element,
lo_sub_element_variant TYPE REF TO if_ixml_element,
lo_sub_element_lpstr TYPE REF TO if_ixml_element,
lo_sub_element_i4 TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_worksheet TYPE REF TO zcl_excel_worksheet.
DATA: lv_value TYPE string.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node properties
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_properties
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_props_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:vt&apos;
value = lc_xml_node_props_vt_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; Application
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_application
parent = lo_document ).
lv_value = excel-&gt;properties-&gt;application.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; DocSecurity
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_docsecurity
parent = lo_document ).
lv_value = excel-&gt;properties-&gt;docsecurity.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; ScaleCrop
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_scalecrop
parent = lo_document ).
lv_value = me-&gt;flag2bool( excel-&gt;properties-&gt;scalecrop ).
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; HeadingPairs
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_headingpairs
parent = lo_document ).
&quot; * vector node
lo_sub_element_vector = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_vector
prefix = lc_vt_ns
parent = lo_document ).
lo_sub_element_vector-&gt;set_attribute_ns( name = lc_xml_attr_size
value = &apos;2&apos; ).
lo_sub_element_vector-&gt;set_attribute_ns( name = lc_xml_attr_basetype
value = lc_xml_node_variant ).
&quot; ** variant node
lo_sub_element_variant = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_variant
prefix = lc_vt_ns
parent = lo_document ).
&quot; *** lpstr node
lo_sub_element_lpstr = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_lpstr
prefix = lc_vt_ns
parent = lo_document ).
lv_value = excel-&gt;get_worksheets_name( ).
lo_sub_element_lpstr-&gt;set_value( value = lv_value ).
lo_sub_element_variant-&gt;append_child( new_child = lo_sub_element_lpstr ). &quot; lpstr node
lo_sub_element_vector-&gt;append_child( new_child = lo_sub_element_variant ). &quot; variant node
&quot; ** variant node
lo_sub_element_variant = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_variant
prefix = lc_vt_ns
parent = lo_document ).
&quot; *** i4 node
lo_sub_element_i4 = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_i4
prefix = lc_vt_ns
parent = lo_document ).
lv_value = excel-&gt;get_worksheets_size( ).
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_sub_element_i4-&gt;set_value( value = lv_value ).
lo_sub_element_variant-&gt;append_child( new_child = lo_sub_element_i4 ). &quot; lpstr node
lo_sub_element_vector-&gt;append_child( new_child = lo_sub_element_variant ). &quot; variant node
lo_element-&gt;append_child( new_child = lo_sub_element_vector ). &quot; vector node
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; HeadingPairs
&quot; TitlesOfParts
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_titlesofparts
parent = lo_document ).
&quot; * vector node
lo_sub_element_vector = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_vector
prefix = lc_vt_ns
parent = lo_document ).
lv_value = excel-&gt;get_worksheets_size( ).
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_sub_element_vector-&gt;set_attribute_ns( name = lc_xml_attr_size
value = lv_value ).
lo_sub_element_vector-&gt;set_attribute_ns( name = lc_xml_attr_basetype
value = lc_xml_node_lpstr ).
lo_iterator = excel-&gt;get_worksheets_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
&quot; ** lpstr node
lo_sub_element_lpstr = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_lpstr
prefix = lc_vt_ns
parent = lo_document ).
lo_worksheet ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_value = lo_worksheet-&gt;get_title( ).
lo_sub_element_lpstr-&gt;set_value( value = lv_value ).
lo_sub_element_vector-&gt;append_child( new_child = lo_sub_element_lpstr ). &quot; lpstr node
ENDWHILE.
lo_element-&gt;append_child( new_child = lo_sub_element_vector ). &quot; vector node
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; TitlesOfParts
&quot; Company
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_company
parent = lo_document ).
lv_value = excel-&gt;properties-&gt;company.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; LinksUpToDate
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_linksuptodate
parent = lo_document ).
lv_value = me-&gt;flag2bool( excel-&gt;properties-&gt;linksuptodate ).
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; SharedDoc
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_shareddoc
parent = lo_document ).
lv_value = me-&gt;flag2bool( excel-&gt;properties-&gt;shareddoc ).
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; HyperlinksChanged
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_hyperlinkschanged
parent = lo_document ).
lv_value = me-&gt;flag2bool( excel-&gt;properties-&gt;hyperlinkschanged ).
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; AppVersion
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_appversion
parent = lo_document ).
lv_value = excel-&gt;properties-&gt;appversion.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_DOCPROPS_CORE" VERSION="1" LANGU="E" DESCRIPT="Create &apos;docProps/core.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="4 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_DOCPROPS_CORE" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_DOCPROPS_CORE.
** Constant node name
DATA: lc_xml_node_coreproperties TYPE string VALUE &apos;coreProperties&apos;,
lc_xml_node_creator TYPE string VALUE &apos;creator&apos;,
lc_xml_node_lastmodifiedby TYPE string VALUE &apos;lastModifiedBy&apos;,
lc_xml_node_created TYPE string VALUE &apos;created&apos;,
lc_xml_node_modified TYPE string VALUE &apos;modified&apos;,
&quot; Node attributes
lc_xml_attr_type TYPE string VALUE &apos;type&apos;,
lc_xml_attr_target TYPE string VALUE &apos;dcterms:W3CDTF&apos;,
&quot; Node namespace
lc_cp_ns TYPE string VALUE &apos;cp&apos;,
lc_dc_ns TYPE string VALUE &apos;dc&apos;,
lc_dcterms_ns TYPE string VALUE &apos;dcterms&apos;,
lc_dcmitype_ns TYPE string VALUE &apos;dcmitype&apos;,
lc_xsi_ns TYPE string VALUE &apos;xsi&apos;,
lc_xml_node_cp_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/metadata/core-properties&apos;,
lc_xml_node_dc_ns TYPE string VALUE &apos;http://purl.org/dc/elements/1.1/&apos;,
lc_xml_node_dcterms_ns TYPE string VALUE &apos;http://purl.org/dc/terms/&apos;,
lc_xml_node_dcmitype_ns TYPE string VALUE &apos;http://purl.org/dc/dcmitype/&apos;,
lc_xml_node_xsi_ns TYPE string VALUE &apos;http://www.w3.org/2001/XMLSchema-instance&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer.
DATA: lv_value TYPE string.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node coreProperties
lo_element_root = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_coreproperties
prefix = lc_cp_ns
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:cp&apos;
value = lc_xml_node_cp_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:dc&apos;
value = lc_xml_node_dc_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:dcterms&apos;
value = lc_xml_node_dcterms_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:dcmitype&apos;
value = lc_xml_node_dcmitype_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:xsi&apos;
value = lc_xml_node_xsi_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; Creator node
lo_element = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_creator
prefix = lc_dc_ns
parent = lo_document ).
lv_value = excel-&gt;properties-&gt;creator.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; lastModifiedBy node
lo_element = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_lastmodifiedby
prefix = lc_cp_ns
parent = lo_document ).
lv_value = excel-&gt;properties-&gt;lastmodifiedby.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Created node
lo_element = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_created
prefix = lc_dcterms_ns
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
prefix = lc_xsi_ns
value = lc_xml_attr_target ).
lv_value = excel-&gt;properties-&gt;created.
lv_value = &apos;2010-07-04T14:58:53Z&apos;.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Modified node
lo_element = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_modified
prefix = lc_dcterms_ns
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
prefix = lc_xsi_ns
value = lc_xml_attr_target ).
lv_value = excel-&gt;properties-&gt;modified.
lv_value = &apos;2010-07-04T14:58:53Z&apos;.
lo_element-&gt;set_value( value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_RELATIONSHIPS" VERSION="1" LANGU="E" DESCRIPT="Create &apos;_rels/.rels&apos;" EXPOSURE="1" STATE="1" EDITORDER="5 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_RELATIONSHIPS" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_RELATIONSHIPS.
** Constant node name
DATA: lc_xml_node_relationships TYPE string VALUE &apos;Relationships&apos;,
lc_xml_node_relationship TYPE string VALUE &apos;Relationship&apos;,
&quot; Node attributes
lc_xml_attr_id TYPE string VALUE &apos;Id&apos;,
lc_xml_attr_type TYPE string VALUE &apos;Type&apos;,
lc_xml_attr_target TYPE string VALUE &apos;Target&apos;,
&quot; Node namespace
lc_xml_node_rels_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/relationships&apos;,
&quot; Node id
lc_xml_node_rId1_id TYPE string VALUE &apos;rId1&apos;,
lc_xml_node_rId2_id TYPE string VALUE &apos;rId2&apos;,
lc_xml_node_rId3_id TYPE string VALUE &apos;rId3&apos;,
&quot; Node type
lc_xml_node_rId1_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument&apos;,
lc_xml_node_rId2_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties&apos;,
lc_xml_node_rId3_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties&apos;,
&quot; Node target
lc_xml_node_rId1_tg TYPE string VALUE &apos;xl/workbook.xml&apos;,
lc_xml_node_rId2_tg TYPE string VALUE &apos;docProps/core.xml&apos;,
lc_xml_node_rId3_tg TYPE string VALUE &apos;docProps/app.xml&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_relationships
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_rels_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; Theme node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lc_xml_node_rId3_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rId3_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lc_xml_node_rId3_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Styles node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lc_xml_node_rId2_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rId2_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lc_xml_node_rId2_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; rels node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lc_xml_node_rId1_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rId1_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lc_xml_node_rId1_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_DRAWINGS" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/drawings/drawing1.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="6 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_DRAWINGS" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_DRAWINGS" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_DRAWINGS.
** Constant node name
CONSTANTS: lc_xml_node_wsdr TYPE string VALUE &apos;xdr:wsDr&apos;,
lc_xml_node_ns_xdr TYPE string VALUE &apos;http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing&apos;,
lc_xml_node_ns_a TYPE string VALUE &apos;http://schemas.openxmlformats.org/drawingml/2006/main&apos;,
lc_xml_node_onecellanchor TYPE string VALUE &apos;xdr:oneCellAnchor&apos;,
lc_xml_node_from TYPE string VALUE &apos;xdr:from&apos;,
lc_xml_node_to TYPE string VALUE &apos;xdr:to&apos;,
lc_xml_node_pic TYPE string VALUE &apos;xdr:pic&apos;,
lc_xml_node_ext TYPE string VALUE &apos;xdr:ext&apos;,
lc_xml_node_clientdata TYPE string VALUE &apos;xdr:clientData&apos;,
lc_xml_node_col TYPE string VALUE &apos;xdr:col&apos;,
lc_xml_node_coloff TYPE string VALUE &apos;xdr:colOff&apos;,
lc_xml_node_row TYPE string VALUE &apos;xdr:row&apos;,
lc_xml_node_rowoff TYPE string VALUE &apos;xdr:rowOff&apos;,
lc_xml_node_nvpicpr TYPE string VALUE &apos;xdr:nvPicPr&apos;,
lc_xml_node_cnvpr TYPE string VALUE &apos;xdr:cNvPr&apos;,
lc_xml_node_cnvpicpr TYPE string VALUE &apos;xdr:cNvPicPr&apos;,
lc_xml_node_piclocks TYPE string VALUE &apos;a:picLocks&apos;,
lc_xml_node_sppr TYPE string VALUE &apos;xdr:spPr&apos;,
lc_xml_node_apgeom TYPE string VALUE &apos;a:prstGeom&apos;,
lc_xml_node_aavlst TYPE string VALUE &apos;a:avLst&apos;,
lc_xml_node_blipfill TYPE string VALUE &apos;xdr:blipFill&apos;,
lc_xml_node_ablip TYPE string VALUE &apos;a:blip&apos;,
lc_xml_node_astretch TYPE string VALUE &apos;a:stretch&apos;,
lc_xml_node_ns_r TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships&apos;.
CONSTANTS: lc_on TYPE string VALUE &apos;1&apos;,
lc_off TYPE string VALUE &apos;0&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_element2 TYPE REF TO if_ixml_element,
lo_element3 TYPE REF TO if_ixml_element,
lo_element_onecellanchor TYPE REF TO if_ixml_element,
lo_element_from TYPE REF TO if_ixml_element,
lo_element_ext TYPE REF TO if_ixml_element,
lo_element_pic TYPE REF TO if_ixml_element,
lo_element_clientdata TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_drawing TYPE REF TO zcl_excel_drawing,
lv_col TYPE string, &quot; zexcel_cell_column,
lv_row TYPE string, &quot; zexcel_cell_row.
lv_counter TYPE i VALUE 0,
lv_value TYPE string.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
***********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_wsdr
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:xdr&apos;
value = lc_xml_node_ns_xdr ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:a&apos;
value = lc_xml_node_ns_a ).
**********************************************************************
* STEP 4: Create drawings
lo_iterator = io_worksheet-&gt;get_drawings_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_drawing ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lo_element_onecellanchor = lo_document-&gt;create_simple_element( name = lc_xml_node_onecellanchor
parent = lo_document ).
* from cell ******************************
lo_element_from = lo_document-&gt;create_simple_element( name = lc_xml_node_from
parent = lo_document ).
lv_col = lo_drawing-&gt;get_from_col( ).
lv_row = lo_drawing-&gt;get_from_row( ).
CONDENSE lv_col NO-GAPS.
CONDENSE lv_row NO-GAPS.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_col
parent = lo_document ).
lo_element-&gt;set_value( value = lv_col ).
lo_element_from-&gt;append_child( new_child = lo_element ).
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_coloff
parent = lo_document ).
lo_element-&gt;set_value( value = `0` ).
lo_element_from-&gt;append_child( new_child = lo_element ).
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_row
parent = lo_document ).
lo_element-&gt;set_value( value = lv_row ).
lo_element_from-&gt;append_child( new_child = lo_element ).
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_rowoff
parent = lo_document ).
lo_element-&gt;set_value( value = `1` ).
lo_element_from-&gt;append_child( new_child = lo_element ).
* ext ******************************
lo_element_ext = lo_document-&gt;create_simple_element( name = lc_xml_node_ext
parent = lo_document ).
lv_value = lo_drawing-&gt;get_width_emu_str( ).
lo_element_ext-&gt;set_attribute_ns( name = &apos;cx&apos;
value = lv_value ).
lv_value = lo_drawing-&gt;get_height_emu_str( ).
lo_element_ext-&gt;set_attribute_ns( name = &apos;cy&apos;
value = lv_value ).
* pic **********************************
lo_element_pic = lo_document-&gt;create_simple_element( name = lc_xml_node_pic
parent = lo_document ).
* nvPicPr
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_nvpicpr
parent = lo_document ).
* cNvPr
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_cnvpr
parent = lo_document ).
lv_value = sy-index.
CONDENSE lv_value.
lo_element2-&gt;set_attribute_ns( name = &apos;id&apos;
value = lv_value ).
lo_element2-&gt;set_attribute_ns( name = &apos;name&apos;
value = &apos;Image 1&apos; ).
lo_element-&gt;append_child( new_child = lo_element2 ).
* cNvPicPr
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_cnvpicpr
parent = lo_document ).
* picLocks
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_piclocks
parent = lo_document ).
lo_element3-&gt;set_attribute_ns( name = &apos;noChangeAspect&apos;
value = &apos;1&apos; ).
lo_element2-&gt;append_child( new_child = lo_element3 ).
lo_element-&gt;append_child( new_child = lo_element2 ).
lo_element_pic-&gt;append_child( new_child = lo_element ).
* blipFill
ADD 1 TO lv_counter.
lv_value = lv_counter.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_blipfill
parent = lo_document ).
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_ablip
parent = lo_document ).
lo_element2-&gt;set_attribute_ns( name = &apos;xmlns:r&apos;
value = lc_xml_node_ns_r ).
lo_element2-&gt;set_attribute_ns( name = &apos;r:embed&apos;
value = lv_value ).
lo_element-&gt;append_child( new_child = lo_element2 ).
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_astretch
parent = lo_document ).
lo_element-&gt;append_child( new_child = lo_element2 ).
lo_element_pic-&gt;append_child( new_child = lo_element ).
* spPr
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sppr
parent = lo_document ).
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_apgeom
parent = lo_document ).
lo_element2-&gt;set_attribute_ns( name = &apos;prst&apos;
value = &apos;rect&apos; ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_aavlst
parent = lo_document ).
lo_element2-&gt;append_child( new_child = lo_element3 ).
lo_element-&gt;append_child( new_child = lo_element2 ).
lo_element_pic-&gt;append_child( new_child = lo_element ).
* client data ***************************
lo_element_clientdata = lo_document-&gt;create_simple_element( name = lc_xml_node_clientdata
parent = lo_document ).
lo_element_onecellanchor-&gt;append_child( new_child = lo_element_from ).
lo_element_onecellanchor-&gt;append_child( new_child = lo_element_ext ).
lo_element_onecellanchor-&gt;append_child( new_child = lo_element_pic ).
lo_element_onecellanchor-&gt;append_child( new_child = lo_element_clientdata ).
lo_element_root-&gt;append_child( new_child = lo_element_onecellanchor ).
ENDWHILE.
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_DRAWINGS_RELS" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/drawings/_rels/drawing1.xml.rels&apos;" EXPOSURE="1" STATE="1" EDITORDER="7 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_DRAWINGS_RELS" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_DRAWINGS_RELS" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_DRAWINGS_RELS.
** Constant node name
DATA: lc_xml_node_relationships TYPE string VALUE &apos;Relationships&apos;,
lc_xml_node_relationship TYPE string VALUE &apos;Relationship&apos;,
&quot; Node attributes
lc_xml_attr_id TYPE string VALUE &apos;Id&apos;,
lc_xml_attr_type TYPE string VALUE &apos;Type&apos;,
lc_xml_attr_target TYPE string VALUE &apos;Target&apos;,
&quot; Node namespace
lc_xml_node_rels_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/relationships&apos;,
lc_xml_node_rid_image_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/image&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_drawing TYPE REF TO zcl_excel_drawing.
DATA: lv_value TYPE string,
lv_counter TYPE i.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_relationships
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_rels_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; Add sheet Relationship nodes here
lv_counter = 0.
lo_iterator = io_worksheet-&gt;get_drawings_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_drawing ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
ADD 1 TO lv_counter.
lv_value = lv_counter.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_image_tp ).
lv_value = lo_drawing-&gt;get_media_name( ).
CONCATENATE &apos;../media/&apos; lv_value INTO lv_value.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDWHILE.
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_RELATIONSHIPS" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/_rels/workbook.xml.rels&apos;" EXPOSURE="1" STATE="1" EDITORDER="8 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_RELATIONSHIPS" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_RELATIONSHIPS.
** Constant node name
DATA: lc_xml_node_relationships TYPE string VALUE &apos;Relationships&apos;,
lc_xml_node_relationship TYPE string VALUE &apos;Relationship&apos;,
&quot; Node attributes
lc_xml_attr_id TYPE string VALUE &apos;Id&apos;,
lc_xml_attr_type TYPE string VALUE &apos;Type&apos;,
lc_xml_attr_target TYPE string VALUE &apos;Target&apos;,
&quot; Node namespace
lc_xml_node_rels_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/relationships&apos;,
&quot; Node id
lc_xml_node_ridx_id TYPE string VALUE &apos;rId#&apos;,
&quot; Node type
lc_xml_node_rid_sheet_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet&apos;,
lc_xml_node_rid_theme_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme&apos;,
lc_xml_node_rid_styles_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles&apos;,
lc_xml_node_rid_shared_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings&apos;,
&quot; Node target
lc_xml_node_ridx_tg TYPE string VALUE &apos;worksheets/sheet#.xml&apos;,
lc_xml_node_rid_shared_tg TYPE string VALUE &apos;sharedStrings.xml&apos;,
lc_xml_node_rid_styles_tg TYPE string VALUE &apos;styles.xml&apos;,
lc_xml_node_rid_theme_tg TYPE string VALUE &apos;theme/theme1.xml&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer.
DATA: lv_xml_node_ridx_tg TYPE string,
lv_xml_node_ridx_id TYPE string,
lv_size TYPE i,
lv_syindex(2) TYPE c.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_relationships
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_rels_ns ).
**********************************************************************
* STEP 4: Create subnodes
lv_size = excel-&gt;get_worksheets_size( ).
&quot; Relationship node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lv_size = lv_size + 2.
lv_syindex = lv_size.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
lv_xml_node_ridx_id = lc_xml_node_ridx_id.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_ridx_id WITH lv_syindex.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_xml_node_ridx_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_styles_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lc_xml_node_rid_styles_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; Relationship node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lv_size = lv_size - 1.
lv_syindex = lv_size.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
lv_xml_node_ridx_id = lc_xml_node_ridx_id.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_ridx_id WITH lv_syindex.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_xml_node_ridx_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_theme_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lc_xml_node_rid_theme_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
lv_size = excel-&gt;get_worksheets_size( ).
DO lv_size TIMES.
&quot; Relationship node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lv_xml_node_ridx_id = lc_xml_node_ridx_id.
lv_xml_node_ridx_tg = lc_xml_node_ridx_tg.
lv_syindex = sy-index.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_ridx_id WITH lv_syindex.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_ridx_tg WITH lv_syindex.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_xml_node_ridx_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_sheet_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lv_xml_node_ridx_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDDO.
&quot; Relationship node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
ADD 3 TO lv_size.
lv_syindex = lv_size.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
lv_xml_node_ridx_id = lc_xml_node_ridx_id.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_ridx_id WITH lv_syindex.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_xml_node_ridx_id ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_shared_tp ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lc_xml_node_rid_shared_tg ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHAREDSTRINGS" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/sharedStrings.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="9 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHAREDSTRINGS" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_SHAREDSTRINGS.
** Constant node name
DATA: lc_xml_node_sst TYPE string VALUE &apos;sst&apos;,
lc_xml_node_si TYPE string VALUE &apos;si&apos;,
lc_xml_node_t TYPE string VALUE &apos;t&apos;,
&quot; Node attributes
lc_xml_attr_count TYPE string VALUE &apos;count&apos;,
lc_xml_attr_uniquecount TYPE string VALUE &apos;uniqueCount&apos;,
&quot; Node namespace
lc_xml_node_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/spreadsheetml/2006/main&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_sub_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_worksheet TYPE REF TO zcl_excel_worksheet.
DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted,
ls_shared_string TYPE zexcel_s_shared_string,
lv_value TYPE string,
lv_count_str TYPE string,
lv_uniquecount_str TYPE string,
lv_sytabix TYPE sytabix,
lv_count TYPE i,
lv_uniquecount TYPE i.
FIELD-SYMBOLS: &lt;fs_sheet_content&gt; TYPE zexcel_s_cell_data,
&lt;fs_sheet_string&gt; TYPE zexcel_s_shared_string.
**********************************************************************
* STEP 1: Collect strings from each worksheet
lo_iterator = excel-&gt;get_worksheets_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_worksheet ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
APPEND LINES OF lo_worksheet-&gt;sheet_content TO lt_cell_data.
ENDWHILE.
DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. &quot; delete formula content
DESCRIBE TABLE lt_cell_data LINES lv_count.
MOVE lv_count TO lv_count_str.
SHIFT lv_count_str RIGHT DELETING TRAILING space.
SHIFT lv_count_str LEFT DELETING LEADING space.
SORT lt_cell_data BY cell_value.
DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value.
DESCRIBE TABLE lt_cell_data LINES lv_uniquecount.
MOVE lv_uniquecount TO lv_uniquecount_str.
SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space.
SHIFT lv_uniquecount_str LEFT DELETING LEADING space.
LOOP AT lt_cell_data ASSIGNING &lt;fs_sheet_content&gt;.
lv_sytabix = sy-tabix - 1.
MOVE lv_sytabix TO ls_shared_string-string_no.
MOVE &lt;fs_sheet_content&gt;-cell_value TO ls_shared_string-string_value.
APPEND ls_shared_string TO shared_strings.
ENDLOOP.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_sst
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_ns ).
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_count_str ).
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_uniquecount
value = lv_uniquecount_str ).
**********************************************************************
* STEP 4: Create subnode
LOOP AT shared_strings ASSIGNING &lt;fs_sheet_string&gt;.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_si
parent = lo_document ).
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_t
parent = lo_document ).
lo_sub_element-&gt;set_value( value = &lt;fs_sheet_string&gt;-string_value ).
lo_element-&gt;append_child( new_child = lo_sub_element ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDLOOP.
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/sheet.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="10 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET" SCONAME="IV_ACTIVE" VERSION="1" LANGU="E" DESCRIPT="General Flag" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="FLAG" PARVALUE="&apos;&apos;"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_SHEET.
TYPES: BEGIN OF cfvo,
value TYPE zexcel_conditional_value,
type TYPE zexcel_conditional_type,
END OF cfvo.
** Constant node name
DATA: lc_xml_node_worksheet TYPE string VALUE &apos;worksheet&apos;,
lc_xml_node_sheetpr TYPE string VALUE &apos;sheetPr&apos;,
lc_xml_node_outlinepr TYPE string VALUE &apos;outlinePr&apos;,
lc_xml_node_dimension TYPE string VALUE &apos;dimension&apos;,
lc_xml_node_sheetviews TYPE string VALUE &apos;sheetViews&apos;,
lc_xml_node_sheetview TYPE string VALUE &apos;sheetView&apos;,
lc_xml_node_selection TYPE string VALUE &apos;selection&apos;,
lc_xml_node_pane TYPE string VALUE &apos;pane&apos;,
lc_xml_node_sheetformatpr TYPE string VALUE &apos;sheetFormatPr&apos;,
lc_xml_node_cols TYPE string VALUE &apos;cols&apos;,
lc_xml_node_col TYPE string VALUE &apos;col&apos;,
lc_xml_node_sheetdata TYPE string VALUE &apos;sheetData&apos;,
lc_xml_node_row TYPE string VALUE &apos;row&apos;,
lc_xml_node_c TYPE string VALUE &apos;c&apos;,
lc_xml_node_v TYPE string VALUE &apos;v&apos;,
lc_xml_node_f TYPE string VALUE &apos;f&apos;,
lc_xml_node_sheetprotection TYPE string VALUE &apos;sheetProtection&apos;,
lc_xml_node_pagemargins TYPE string VALUE &apos;pageMargins&apos;,
lc_xml_node_pagesetup TYPE string VALUE &apos;pageSetup&apos;,
lc_xml_node_pagesetuppr TYPE string VALUE &apos;pageSetUpPr&apos;,
lc_xml_node_condformatting TYPE string VALUE &apos;conditionalFormatting&apos;,
lc_xml_node_cfrule TYPE string VALUE &apos;cfRule&apos;,
lc_xml_node_iconset TYPE string VALUE &apos;iconSet&apos;,
lc_xml_node_cfvo TYPE string VALUE &apos;cfvo&apos;,
lc_xml_node_formula TYPE string VALUE &apos;formula&apos;,
lc_xml_node_datavalidations TYPE string VALUE &apos;dataValidations&apos;,
lc_xml_node_datavalidation TYPE string VALUE &apos;dataValidation&apos;,
lc_xml_node_formula1 TYPE string VALUE &apos;formula1&apos;,
lc_xml_node_formula2 TYPE string VALUE &apos;formula2&apos;,
lc_xml_node_mergecell TYPE string VALUE &apos;mergeCell&apos;,
lc_xml_node_mergecells TYPE string VALUE &apos;mergeCells&apos;,
lc_xml_node_drawing TYPE string VALUE &apos;drawing&apos;,
&quot; Node attributes
lc_xml_attr_ref TYPE string VALUE &apos;ref&apos;,
lc_xml_attr_summarybelow TYPE string VALUE &apos;summaryBelow&apos;,
lc_xml_attr_summaryright TYPE string VALUE &apos;summaryRight&apos;,
lc_xml_attr_tabselected TYPE string VALUE &apos;tabSelected&apos;,
lc_xml_attr_showzeros TYPE string VALUE &apos;showZeros&apos;,
lc_xml_attr_workbookviewid TYPE string VALUE &apos;workbookViewId&apos;,
lc_xml_attr_showgridlines TYPE string VALUE &apos;showGridLines&apos;,
lc_xml_attr_gridlines TYPE string VALUE &apos;gridLines&apos;,
lc_xml_attr_showrowcolheaders TYPE string VALUE &apos;showRowColHeaders&apos;,
lc_xml_attr_activecell TYPE string VALUE &apos;activeCell&apos;,
lc_xml_attr_sqref TYPE string VALUE &apos;sqref&apos;,
lc_xml_attr_min TYPE string VALUE &apos;min&apos;,
lc_xml_attr_max TYPE string VALUE &apos;max&apos;,
lc_xml_attr_hidden TYPE string VALUE &apos;hidden&apos;,
lc_xml_attr_width TYPE string VALUE &apos;width&apos;,
lc_xml_attr_defaultwidth TYPE string VALUE &apos;9.10&apos;,
lc_xml_attr_style TYPE string VALUE &apos;style&apos;,
lc_xml_attr_true TYPE string VALUE &apos;true&apos;,
lc_xml_attr_bestfit TYPE string VALUE &apos;bestFit&apos;,
lc_xml_attr_customheight TYPE string VALUE &apos;customHeight&apos;,
lc_xml_attr_customwidth TYPE string VALUE &apos;customWidth&apos;,
lc_xml_attr_collapsed TYPE string VALUE &apos;collapsed&apos;,
lc_xml_attr_defaultrowheight TYPE string VALUE &apos;defaultRowHeight&apos;,
lc_xml_attr_defaultcolwidth TYPE string VALUE &apos;defaultColWidth&apos;,
lc_xml_attr_outlinelevelrow TYPE string VALUE &apos;x14ac:outlineLevelRow&apos;,
lc_xml_attr_outlinelevelcol TYPE string VALUE &apos;x14ac:outlineLevelCol&apos;,
lc_xml_attr_outlinelevel TYPE string VALUE &apos;outlineLevel&apos;,
lc_xml_attr_r TYPE string VALUE &apos;r&apos;,
lc_xml_attr_s TYPE string VALUE &apos;s&apos;,
lc_xml_attr_spans TYPE string VALUE &apos;spans&apos;,
lc_xml_attr_t TYPE string VALUE &apos;t&apos;,
lc_xml_attr_password TYPE string VALUE &apos;password&apos;,
lc_xml_attr_sheet TYPE string VALUE &apos;sheet&apos;,
lc_xml_attr_objects TYPE string VALUE &apos;objects&apos;,
lc_xml_attr_scenarios TYPE string VALUE &apos;scenarios&apos;,
lc_xml_attr_autofilter TYPE string VALUE &apos;autoFilter&apos;,
lc_xml_attr_deletecolumns TYPE string VALUE &apos;deleteColumns&apos;,
lc_xml_attr_deleterows TYPE string VALUE &apos;deleteRows&apos;,
lc_xml_attr_formatcells TYPE string VALUE &apos;formatCells&apos;,
lc_xml_attr_formatcolumns TYPE string VALUE &apos;formatColumns&apos;,
lc_xml_attr_formatrows TYPE string VALUE &apos;formatRows&apos;,
lc_xml_attr_insertcolumns TYPE string VALUE &apos;insertColumns&apos;,
lc_xml_attr_inserthyperlinks TYPE string VALUE &apos;insertHyperlinks&apos;,
lc_xml_attr_insertrows TYPE string VALUE &apos;insertRows&apos;,
lc_xml_attr_pivottables TYPE string VALUE &apos;pivotTables&apos;,
lc_xml_attr_selectlockedcells TYPE string VALUE &apos;selectLockedCells&apos;,
lc_xml_attr_selectunlockedcell TYPE string VALUE &apos;selectUnlockedCells&apos;,
lc_xml_attr_sort TYPE string VALUE &apos;sort&apos;,
lc_xml_attr_left TYPE string VALUE &apos;left&apos;,
lc_xml_attr_right TYPE string VALUE &apos;right&apos;,
lc_xml_attr_top TYPE string VALUE &apos;top&apos;,
lc_xml_attr_bottom TYPE string VALUE &apos;bottom&apos;,
lc_xml_attr_header TYPE string VALUE &apos;header&apos;,
lc_xml_attr_footer TYPE string VALUE &apos;footer&apos;,
lc_xml_attr_type TYPE string VALUE &apos;type&apos;,
lc_xml_attr_iconset TYPE string VALUE &apos;iconSet&apos;,
lc_xml_attr_showvalue TYPE string VALUE &apos;showValue&apos;,
lc_xml_attr_val TYPE string VALUE &apos;val&apos;,
lc_xml_attr_dxfid TYPE string VALUE &apos;dxfId&apos;,
lc_xml_attr_priority TYPE string VALUE &apos;priority&apos;,
lc_xml_attr_operator TYPE string VALUE &apos;operator&apos;,
lc_xml_attr_allowblank TYPE string VALUE &apos;allowBlank&apos;,
lc_xml_attr_showinputmessage TYPE string VALUE &apos;showInputMessage&apos;,
lc_xml_attr_showerrormessage TYPE string VALUE &apos;showErrorMessage&apos;,
lc_xml_attr_errortitle TYPE string VALUE &apos;errorTitle&apos;,
lc_xml_attr_error TYPE string VALUE &apos;error&apos;,
lc_xml_attr_prompttitle TYPE string VALUE &apos;promptTitle&apos;,
lc_xml_attr_prompt TYPE string VALUE &apos;prompt&apos;,
lc_xml_attr_count TYPE string VALUE &apos;count&apos;,
lc_xml_attr_blackandwhite TYPE string VALUE &apos;blackAndWhite&apos;,
lc_xml_attr_cellcomments TYPE string VALUE &apos;cellComments&apos;,
lc_xml_attr_copies TYPE string VALUE &apos;copies&apos;,
lc_xml_attr_draft TYPE string VALUE &apos;draft&apos;,
lc_xml_attr_errors TYPE string VALUE &apos;errors&apos;,
lc_xml_attr_firstpagenumber TYPE string VALUE &apos;firstPageNumber&apos;,
lc_xml_attr_fittopage TYPE string VALUE &apos;fitToPage&apos;,
lc_xml_attr_fittoheight TYPE string VALUE &apos;fitToHeight&apos;,
lc_xml_attr_fittowidth TYPE string VALUE &apos;fitToWidth&apos;,
lc_xml_attr_horizontaldpi TYPE string VALUE &apos;horizontalDpi&apos;,
lc_xml_attr_orientation TYPE string VALUE &apos;orientation&apos;,
lc_xml_attr_pageorder TYPE string VALUE &apos;pageOrder&apos;,
lc_xml_attr_paperheight TYPE string VALUE &apos;paperHeight&apos;,
lc_xml_attr_papersize TYPE string VALUE &apos;paperSize&apos;,
lc_xml_attr_paperwidth TYPE string VALUE &apos;paperWidth&apos;,
lc_xml_attr_scale TYPE string VALUE &apos;scale&apos;,
lc_xml_attr_usefirstpagenumber TYPE string VALUE &apos;useFirstPageNumber&apos;,
lc_xml_attr_useprinterdefaults TYPE string VALUE &apos;usePrinterDefaults&apos;,
lc_xml_attr_verticaldpi TYPE string VALUE &apos;verticalDpi&apos;,
&quot; Node namespace
lc_xml_node_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/spreadsheetml/2006/main&apos;,
lc_xml_node_r_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships&apos;,
lc_xml_node_comp_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/markup-compatibility/2006&apos;,
lc_xml_node_comp_pref TYPE string VALUE &apos;x14ac&apos;,
lc_xml_node_ig_ns TYPE string VALUE &apos;http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_element_2 TYPE REF TO if_ixml_element,
lo_element_3 TYPE REF TO if_ixml_element,
lo_element_4 TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
lo_data_validation TYPE REF TO zcl_excel_data_validation,
lo_table TYPE REF TO zcl_excel_table,
row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi,
default_col_dimension TYPE REF TO zcl_excel_worksheet_columndime,
default_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi.
DATA: lv_value TYPE string,
t_range_merge TYPE string_table,
lv_merge TYPE string,
lv_column_p TYPE zexcel_cell_column_alpha,
lv_column TYPE zexcel_cell_column,
lv_style_guid TYPE zexcel_cell_style,
lv_flag TYPE c,
ls_iconset TYPE zexcel_conditional_iconset,
ls_cellis TYPE zexcel_conditional_cellis,
ls_expression TYPE zexcel_conditional_expression,
lt_cfvo TYPE TABLE OF cfvo,
ls_cfvo TYPE cfvo,
lv_cell_row_s TYPE string,
ls_last_row TYPE zexcel_s_cell_data,
ls_style_mapping TYPE zexcel_s_styles_mapping,
lv_freeze_cell_row TYPE zexcel_cell_row,
lv_freeze_cell_column TYPE zexcel_cell_column,
lv_freeze_cell_column_alpha TYPE zexcel_cell_column_alpha,
column_dimensions TYPE zexcel_t_worksheet_columndime,
row_dimensions TYPE zexcel_t_worksheet_rowdimensio,
ls_style_cond_mapping TYPE zexcel_s_styles_cond_mapping,
lv_relation_id TYPE i VALUE 0,
outline_level_row TYPE i VALUE 0,
outline_level_col TYPE i VALUE 0,
col_count TYPE int4,
merge_count TYPE int4,
write_current_row TYPE boolean.
FIELD-SYMBOLS: &lt;ls_sheet_content&gt; TYPE zexcel_s_cell_data,
&lt;fs_range_merge&gt; LIKE LINE OF t_range_merge,
&lt;column_dimension&gt; TYPE zexcel_s_worksheet_columndime,
&lt;row_dimension&gt; TYPE zexcel_s_worksheet_rowdimensio.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
***********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_worksheet
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:r&apos;
value = lc_xml_node_r_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:mc&apos;
value = lc_xml_node_comp_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;mc:Ignorable&apos;
value = lc_xml_node_comp_pref ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:x14ac&apos;
value = lc_xml_node_ig_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; sheetPr
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sheetpr
parent = lo_document ).
&quot; TODO tabColor
&quot; outlinePr
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_outlinepr
parent = lo_document ).
&quot; TODO read attribute summaryBelow and set the attribute to 0
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_summarybelow
value = &apos;1&apos; ).
&quot; TODO read attribute summaryRight and set the attribute to 0
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_summaryright
value = &apos;1&apos; ).
lo_element-&gt;append_child( new_child = lo_element_2 ).
IF io_worksheet-&gt;sheet_setup-&gt;fit_to_page IS NOT INITIAL.
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_pagesetuppr
parent = lo_document ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_fittopage
value = `1` ).
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; pageSetupPr node
ENDIF.
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; dimension node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_dimension
parent = lo_document ).
lv_value = io_worksheet-&gt;get_dimension_range( ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_ref
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; sheetViews node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sheetviews
parent = lo_document ).
&quot; sheetView node
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_sheetview
parent = lo_document ).
IF io_worksheet-&gt;zif_excel_sheet_properties~show_zeros EQ abap_false.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showzeros
value = &apos;0&apos; ).
ENDIF.
IF iv_active EQ abap_true.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_tabselected
value = &apos;1&apos; ).
ELSE.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_tabselected
value = &apos;0&apos; ).
ENDIF.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_workbookviewid
value = &apos;0&apos; ).
&quot; showGridLines attribute
IF io_worksheet-&gt;show_gridlines = abap_true.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showgridlines
value = &apos;1&apos; ).
ELSE.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showgridlines
value = &apos;0&apos; ).
ENDIF.
&quot; showRowColHeaders attribute
IF io_worksheet-&gt;show_rowcolheaders = abap_true.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showrowcolheaders
value = &apos;1&apos; ).
ELSE.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showrowcolheaders
value = &apos;0&apos; ).
ENDIF.
&quot; freeze panes
io_worksheet-&gt;get_freeze_cell( IMPORTING ep_row = lv_freeze_cell_row
ep_column = lv_freeze_cell_column ).
IF lv_freeze_cell_row IS NOT INITIAL AND lv_freeze_cell_column IS NOT INITIAL.
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_pane
parent = lo_element_2 ).
IF lv_freeze_cell_row &gt; 1.
lv_value = lv_freeze_cell_row - 1.
CONDENSE lv_value.
lo_element_3-&gt;set_attribute_ns( name = &apos;ySplit&apos;
value = lv_value ).
ENDIF.
IF lv_freeze_cell_column &gt; 1.
lv_value = lv_freeze_cell_column - 1.
CONDENSE lv_value.
lo_element_3-&gt;set_attribute_ns( name = &apos;xSplit&apos;
value = lv_value ).
ENDIF.
lv_freeze_cell_column_alpha = zcl_excel_common=&gt;convert_column2alpha( ip_column = lv_freeze_cell_column ).
lv_value = zcl_excel_common=&gt;number_to_excel_string( ip_value = lv_freeze_cell_row ).
CONCATENATE lv_freeze_cell_column_alpha lv_value INTO lv_value.
lo_element_3-&gt;set_attribute_ns( name = &apos;topLeftCell&apos;
value = lv_value ).
lo_element_3-&gt;set_attribute_ns( name = &apos;activePane&apos;
value = &apos;bottomRight&apos; ).
lo_element_3-&gt;set_attribute_ns( name = &apos;state&apos;
value = &apos;frozen&apos; ).
lo_element_2-&gt;append_child( new_child = lo_element_3 ).
ENDIF.
&quot; selection node
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_selection
parent = lo_document ).
lv_value = io_worksheet-&gt;get_active_cell( ).
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_activecell
value = lv_value ).
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_sqref
value = lv_value ).
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; sheetView node
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; sheetView node
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; sheetViews node
column_dimensions[] = io_worksheet-&gt;get_column_dimensions( ).
&quot; Calculate col
IF NOT column_dimensions IS INITIAL.
io_worksheet-&gt;calculate_column_widths( ).
column_dimensions[] = io_worksheet-&gt;get_column_dimensions( ).
ENDIF.
row_dimensions[] = io_worksheet-&gt;get_row_dimensions( ).
&quot; sheetFormatPr node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sheetformatpr
parent = lo_document ).
&quot; defaultRowHeight
default_row_dimension = io_worksheet-&gt;get_default_row_dimension( ).
IF default_row_dimension IS BOUND.
IF default_row_dimension-&gt;get_row_height( ) &gt;= 0.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_customheight
value = lc_xml_attr_true ).
lv_value = default_row_dimension-&gt;get_row_height( ).
ELSE.
lv_value = &apos;12.75&apos;.
ENDIF.
ELSE.
lv_value = &apos;12.75&apos;.
ENDIF.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_defaultrowheight
value = lv_value ).
&quot; defaultColWidth
default_col_dimension = io_worksheet-&gt;get_default_column_dimension( ).
IF default_col_dimension IS BOUND.
IF default_col_dimension-&gt;get_width( ) &gt;= 0.
lv_value = default_col_dimension-&gt;get_width( ).
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_defaultcolwidth
value = lv_value ).
ENDIF.
ENDIF.
&quot; outlineLevelRow
LOOP AT row_dimensions ASSIGNING &lt;row_dimension&gt;.
IF &lt;row_dimension&gt;-row_dimension-&gt;get_outline_level( ) &gt; outline_level_row.
outline_level_row = &lt;row_dimension&gt;-row_dimension-&gt;get_outline_level( ).
ENDIF.
ENDLOOP.
lv_value = outline_level_row.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_outlinelevelrow
value = lv_value ).
&quot; outlineLevelCol
LOOP AT column_dimensions ASSIGNING &lt;column_dimension&gt;.
IF &lt;column_dimension&gt;-column_dimension-&gt;get_outline_level( ) &gt; outline_level_col.
outline_level_col = &lt;column_dimension&gt;-column_dimension-&gt;get_outline_level( ).
ENDIF.
ENDLOOP.
lv_value = outline_level_col.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_outlinelevelcol
value = lv_value ).
* lv_value = 0.
* SHIFT lv_value RIGHT DELETING TRAILING space.
* SHIFT lv_value LEFT DELETING LEADING space.
* lo_element-&gt;set_attribute_ns( name = lc_xml_attr_dydescent
* value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; sheetFormatPr node
IF io_worksheet-&gt;zif_excel_sheet_properties~get_style( ) IS NOT INITIAL OR NOT column_dimensions IS INITIAL.
&quot; cols node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_cols
parent = lo_document ).
&quot; This code have to be enhanced in order to manage also column style properties
&quot; Now it is an out/out
IF NOT column_dimensions IS INITIAL.
LOOP AT column_dimensions ASSIGNING &lt;column_dimension&gt;.
&quot; col node
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_col
parent = lo_document ).
lv_value = &lt;column_dimension&gt;-column_dimension-&gt;get_column_index( ).
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_min
value = lv_value ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_max
value = lv_value ).
&quot; Width
IF &lt;column_dimension&gt;-column_dimension-&gt;get_width( ) &lt; 0.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_width
value = lc_xml_attr_defaultwidth ).
ELSE.
lv_value = &lt;column_dimension&gt;-column_dimension-&gt;get_width( ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_width
value = lv_value ).
ENDIF.
&quot; Column visibility
IF &lt;column_dimension&gt;-column_dimension-&gt;get_visible( ) = abap_false.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_hidden
value = lc_xml_attr_true ).
ENDIF.
&quot; Auto size?
IF &lt;column_dimension&gt;-column_dimension-&gt;get_auto_size( ) = abap_true.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_bestfit
value = lc_xml_attr_true ).
ENDIF.
&quot; Custom width?
IF default_col_dimension IS BOUND.
IF &lt;column_dimension&gt;-column_dimension-&gt;get_width( )
&lt;&gt; default_col_dimension-&gt;get_width( ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_customwidth
value = lc_xml_attr_true ).
ENDIF.
ELSE.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_customwidth
value = lc_xml_attr_true ).
ENDIF.
&quot; Collapsed
IF &lt;column_dimension&gt;-column_dimension-&gt;get_collapsed( ) = abap_true.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_collapsed
value = lc_xml_attr_true ).
ENDIF.
&quot; outlineLevel
IF &lt;column_dimension&gt;-column_dimension-&gt;get_outline_level( ) &gt; 0.
lv_value = &lt;column_dimension&gt;-column_dimension-&gt;get_outline_level( ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_outlinelevel
value = lv_value ).
ENDIF.
&quot; Style
lv_value = &lt;column_dimension&gt;-column_dimension-&gt;get_xf_index( ).
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; col node
ENDLOOP.
ELSE.
IF io_worksheet-&gt;zif_excel_sheet_properties~get_style( ) IS NOT INITIAL.
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_col
parent = lo_document ).
lv_value = zcl_excel_common=&gt;c_excel_sheet_min_col.
CONDENSE lv_value.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_min
value = lv_value ).
lv_value = zcl_excel_common=&gt;c_excel_sheet_max_col.
CONDENSE lv_value.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_max
value = lv_value ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_width
value = lc_xml_attr_defaultwidth ).
lv_style_guid = io_worksheet-&gt;zif_excel_sheet_properties~get_style( ).
READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = lv_style_guid.
lv_value = ls_style_mapping-style.
CONDENSE lv_value.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; col node
ENDIF.
ENDIF.
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; cols node
ENDIF.
&quot; sheetData node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sheetdata
parent = lo_document ).
&quot; Get column count
col_count = io_worksheet-&gt;get_highest_column( ).
LOOP AT io_worksheet-&gt;sheet_content ASSIGNING &lt;ls_sheet_content&gt;.
CLEAR ls_style_mapping.
IF ls_last_row-cell_row NE &lt;ls_sheet_content&gt;-cell_row.
&quot; Add new row
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_row
parent = lo_document ).
&quot; r
lv_value = &lt;ls_sheet_content&gt;-cell_row.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_r
value = lv_value ).
&quot; Spans
lv_value = col_count.
CONCATENATE &apos;1:&apos; lv_value INTO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_spans
value = lv_value ).
row_dimension = io_worksheet-&gt;get_row_dimension( &lt;ls_sheet_content&gt;-cell_row ).
&quot; Do we need the row dimension attributes?
IF row_dimension-&gt;get_row_height( ) &gt;= 0 OR
row_dimension-&gt;get_visible( ) = abap_false OR
row_dimension-&gt;get_collapsed( ) = abap_true OR
row_dimension-&gt;get_outline_level( ) &gt; 0 OR
row_dimension-&gt;get_xf_index( ) &lt;&gt; 0.
&quot; Row dimensions
IF row_dimension-&gt;get_row_height( ) &gt;= 0.
lo_element_2-&gt;set_attribute_ns( name = &apos;customHeight&apos; value = &apos;1&apos;).
lv_value = row_dimension-&gt;get_row_height( ).
lo_element_2-&gt;set_attribute_ns( name = &apos;ht&apos; value = lv_value ).
ENDIF.
&quot; Row visibility
IF row_dimension-&gt;get_visible( ) = abap_false.
lo_element_2-&gt;set_attribute_ns( name = &apos;hidden&apos; value = &apos;true&apos;).
ENDIF.
&quot; Collapsed
IF row_dimension-&gt;get_collapsed( ) = abap_true.
lo_element_2-&gt;set_attribute_ns( name = &apos;collapsed&apos; value = &apos;true&apos;).
ENDIF.
&quot; Outline level
IF row_dimension-&gt;get_outline_level( ) &gt; 0.
lv_value = row_dimension-&gt;get_outline_level( ).
lo_element_2-&gt;set_attribute_ns( name = &apos;outlineLevel&apos; value = lv_value ).
ENDIF.
&quot; Style
IF row_dimension-&gt;get_xf_index( ) &lt;&gt; 0.
lv_value = row_dimension-&gt;get_xf_index( ).
lo_element_2-&gt;set_attribute_ns( name = &apos;s&apos; value = lv_value ).
lo_element_2-&gt;set_attribute_ns( name = &apos;customFormat&apos; value = &apos;1&apos;).
ENDIF.
ENDIF.
ENDIF.
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_c
parent = lo_document ).
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_r
value = &lt;ls_sheet_content&gt;-cell_coords ).
IF &lt;ls_sheet_content&gt;-cell_style IS NOT INITIAL.
READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = &lt;ls_sheet_content&gt;-cell_style.
lv_value = ls_style_mapping-style.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_s
value = lv_value ).
ENDIF.
&quot; For cells with formula ignore the value - Excel will calculate it
IF &lt;ls_sheet_content&gt;-cell_formula IS NOT INITIAL.
&quot; fomula node
lo_element_4 = lo_document-&gt;create_simple_element( name = lc_xml_node_f
parent = lo_document ).
lv_value = &lt;ls_sheet_content&gt;-cell_formula.
lo_element_4-&gt;set_value( value = lv_value ).
lo_element_3-&gt;append_child( new_child = lo_element_4 ). &quot; fomula node
ELSEIF &lt;ls_sheet_content&gt;-cell_value IS NOT INITIAL. &quot;cell can have just style or formula
IF &lt;ls_sheet_content&gt;-data_type IS NOT INITIAL.
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_t
value = &lt;ls_sheet_content&gt;-data_type ).
ENDIF.
&quot; value node
lo_element_4 = lo_document-&gt;create_simple_element( name = lc_xml_node_v
parent = lo_document ).
IF &lt;ls_sheet_content&gt;-data_type EQ &apos;s&apos;.
lv_value = me-&gt;get_shared_string_index( &lt;ls_sheet_content&gt;-cell_value ).
lo_element_4-&gt;set_value( value = lv_value ).
ELSE.
lv_value = &lt;ls_sheet_content&gt;-cell_value.
lo_element_4-&gt;set_value( value = lv_value ).
ENDIF.
lo_element_3-&gt;append_child( new_child = lo_element_4 ). &quot; value node
ENDIF.
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; column node
IF ls_last_row-cell_row NE &lt;ls_sheet_content&gt;-cell_row.
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; row node
ls_last_row = &lt;ls_sheet_content&gt;.
ENDIF.
ENDLOOP.
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; sheetData node
IF io_worksheet-&gt;zif_excel_sheet_protection~protected EQ abap_true.
&quot; sheetProtection node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sheetprotection
parent = lo_document ).
MOVE io_worksheet-&gt;zif_excel_sheet_protection~password TO lv_value.
IF lv_value IS NOT INITIAL.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_password
value = lv_value ).
ENDIF.
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~auto_filter.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_autofilter
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~delete_columns.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_deletecolumns
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~delete_rows.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_deleterows
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~format_cells.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_formatcells
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~format_columns.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_formatcolumns
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~format_rows.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_formatrows
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~insert_columns.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_insertcolumns
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~insert_hyperlinks.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_inserthyperlinks
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~insert_rows.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_insertrows
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~objects.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_objects
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~pivot_tables.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_pivottables
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~scenarios.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_scenarios
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~select_locked_cells.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_selectlockedcells
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~select_unlocked_cells.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_selectunlockedcell
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~sheet.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_sheet
value = lv_value ).
lv_value = io_worksheet-&gt;zif_excel_sheet_protection~sort.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_sort
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
&quot; Merged cells
t_range_merge = io_worksheet-&gt;get_merge( ).
IF t_range_merge IS NOT INITIAL.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_mergecells
parent = lo_document ).
DESCRIBE TABLE t_range_merge LINES merge_count.
lv_value = merge_count.
CONDENSE lv_value.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_value ).
LOOP AT t_range_merge ASSIGNING &lt;fs_range_merge&gt;.
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_mergecell
parent = lo_document ).
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_ref
value = &lt;fs_range_merge&gt; ).
lo_element-&gt;append_child( new_child = lo_element_2 ).
lo_element_root-&gt;append_child( new_child = lo_element ).
io_worksheet-&gt;delete_merge( ).
ENDLOOP.
ENDIF.
&quot; Conditional formatting node
lo_iterator = io_worksheet-&gt;get_cond_styles_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_style_conditional ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
IF lo_style_conditional-&gt;rule IS INITIAL.
CONTINUE.
ENDIF.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_condformatting
parent = lo_document ).
lv_value = lo_style_conditional-&gt;get_dimension_range( ) .
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_sqref
value = lv_value ).
&quot; cfRule node
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_cfrule
parent = lo_document ).
lv_value = lo_style_conditional-&gt;rule.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lv_value ).
lv_value = lo_style_conditional-&gt;priority.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_priority
value = lv_value ).
CASE lo_style_conditional-&gt;rule.
WHEN zcl_excel_style_conditional=&gt;c_rule_iconset.
ls_iconset = lo_style_conditional-&gt;mode_iconset.
CLEAR lt_cfvo.
&quot; iconset node
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_iconset
parent = lo_document ).
IF ls_iconset-iconset NE zcl_excel_style_conditional=&gt;c_iconset_3trafficlights.
lv_value = ls_iconset-iconset.
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_iconset
value = lv_value ).
ENDIF.
&quot; Set the showValue attribute
lv_value = ls_iconset-showvalue.
lo_element_3-&gt;set_attribute_ns( name = lc_xml_attr_showvalue
value = lv_value ).
CASE ls_iconset-iconset.
WHEN zcl_excel_style_conditional=&gt;c_iconset_3trafficlights2 OR
zcl_excel_style_conditional=&gt;c_iconset_3arrows OR
zcl_excel_style_conditional=&gt;c_iconset_3arrowsgray OR
zcl_excel_style_conditional=&gt;c_iconset_3flags OR
zcl_excel_style_conditional=&gt;c_iconset_3signs OR
zcl_excel_style_conditional=&gt;c_iconset_3symbols OR
zcl_excel_style_conditional=&gt;c_iconset_3symbols2 OR
zcl_excel_style_conditional=&gt;c_iconset_3trafficlights OR
zcl_excel_style_conditional=&gt;c_iconset_3trafficlights2.
MOVE ls_iconset-cfvo1_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo1_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo2_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo2_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo3_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo3_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
WHEN zcl_excel_style_conditional=&gt;c_iconset_4arrows OR
zcl_excel_style_conditional=&gt;c_iconset_4arrowsgray OR
zcl_excel_style_conditional=&gt;c_iconset_4rating OR
zcl_excel_style_conditional=&gt;c_iconset_4redtoblack OR
zcl_excel_style_conditional=&gt;c_iconset_4trafficlights.
MOVE ls_iconset-cfvo1_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo1_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo2_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo2_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo3_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo3_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo4_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo4_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
WHEN zcl_excel_style_conditional=&gt;c_iconset_5arrows OR
zcl_excel_style_conditional=&gt;c_iconset_5arrowsgray OR
zcl_excel_style_conditional=&gt;c_iconset_5quarters OR
zcl_excel_style_conditional=&gt;c_iconset_5rating.
MOVE ls_iconset-cfvo1_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo1_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo2_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo2_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo3_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo3_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo4_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo4_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
MOVE ls_iconset-cfvo5_value TO ls_cfvo-value.
MOVE ls_iconset-cfvo5_type TO ls_cfvo-type.
APPEND ls_cfvo TO lt_cfvo.
WHEN OTHERS.
CLEAR lt_cfvo.
ENDCASE.
LOOP AT lt_cfvo INTO ls_cfvo.
&quot; cfvo node
lo_element_4 = lo_document-&gt;create_simple_element( name = lc_xml_node_cfvo
parent = lo_document ).
lv_value = ls_cfvo-type.
lo_element_4-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lv_value ).
lv_value = ls_cfvo-value.
lo_element_4-&gt;set_attribute_ns( name = lc_xml_attr_val
value = lv_value ).
lo_element_3-&gt;append_child( new_child = lo_element_4 ). &quot; cfvo node
ENDLOOP.
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; iconset node
WHEN zcl_excel_style_conditional=&gt;c_rule_cellis.
ls_cellis = lo_style_conditional-&gt;mode_cellis.
READ TABLE me-&gt;styles_cond_mapping INTO ls_style_cond_mapping WITH KEY guid = ls_cellis-cell_style.
lv_value = ls_style_cond_mapping-dxf.
CONDENSE lv_value.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_dxfid
value = lv_value ).
lv_value = ls_cellis-operator.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_operator
value = lv_value ).
&quot; formula node
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_formula
parent = lo_document ).
lv_value = ls_cellis-formula.
lo_element_3-&gt;set_value( value = lv_value ).
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; formula node
WHEN zcl_excel_style_conditional=&gt;c_rule_expression.
ls_expression = lo_style_conditional-&gt;mode_expression.
READ TABLE me-&gt;styles_cond_mapping INTO ls_style_cond_mapping WITH KEY guid = ls_expression-cell_style.
lv_value = ls_style_cond_mapping-dxf.
CONDENSE lv_value.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_dxfid
value = lv_value ).
&quot; formula node
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_formula
parent = lo_document ).
lv_value = ls_expression-formula.
lo_element_3-&gt;set_value( value = lv_value ).
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; formula node
ENDCASE.
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; cfRule node
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; Conditional formatting node
ENDWHILE.
IF io_worksheet-&gt;get_data_validations_size( ) GT 0.
&quot; dataValidations node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_datavalidations
parent = lo_document ).
&quot; Conditional formatting node
lo_iterator = io_worksheet-&gt;get_data_validations_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_data_validation ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
&quot; dataValidation node
lo_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_datavalidation
parent = lo_document ).
lv_value = lo_data_validation-&gt;type.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lv_value ).
IF NOT lo_data_validation-&gt;operator IS INITIAL.
lv_value = lo_data_validation-&gt;operator.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_operator
value = lv_value ).
ENDIF.
IF lo_data_validation-&gt;allowblank EQ abap_true.
lv_value = &apos;1&apos;.
ELSE.
lv_value = &apos;0&apos;.
ENDIF.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_allowblank
value = lv_value ).
IF lo_data_validation-&gt;showinputmessage EQ abap_true.
lv_value = &apos;1&apos;.
ELSE.
lv_value = &apos;0&apos;.
ENDIF.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showinputmessage
value = lv_value ).
IF lo_data_validation-&gt;showerrormessage EQ abap_true.
lv_value = &apos;1&apos;.
ELSE.
lv_value = &apos;0&apos;.
ENDIF.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_showerrormessage
value = lv_value ).
IF NOT lo_data_validation-&gt;errortitle IS INITIAL.
lv_value = lo_data_validation-&gt;errortitle.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_errortitle
value = lv_value ).
ENDIF.
IF NOT lo_data_validation-&gt;error IS INITIAL.
lv_value = lo_data_validation-&gt;error.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_error
value = lv_value ).
ENDIF.
IF NOT lo_data_validation-&gt;prompttitle IS INITIAL.
lv_value = lo_data_validation-&gt;prompttitle.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_prompttitle
value = lv_value ).
ENDIF.
IF NOT lo_data_validation-&gt;prompt IS INITIAL.
lv_value = lo_data_validation-&gt;prompt.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_prompt
value = lv_value ).
ENDIF.
lv_cell_row_s = lo_data_validation-&gt;cell_row.
CONDENSE lv_cell_row_s.
CONCATENATE lo_data_validation-&gt;cell_column lv_cell_row_s INTO lv_value.
IF lo_data_validation-&gt;cell_row_to IS NOT INITIAL.
lv_cell_row_s = lo_data_validation-&gt;cell_row_to.
CONDENSE lv_cell_row_s.
CONCATENATE lv_value &apos;:&apos; lo_data_validation-&gt;cell_column_to lv_cell_row_s INTO lv_value.
ENDIF.
lo_element_2-&gt;set_attribute_ns( name = lc_xml_attr_sqref
value = lv_value ).
&quot; formula1 node
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_formula1
parent = lo_document ).
lv_value = lo_data_validation-&gt;formula1.
lo_element_3-&gt;set_value( value = lv_value ).
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; formula1 node
&quot; formula2 node
IF NOT lo_data_validation-&gt;formula2 IS INITIAL.
lo_element_3 = lo_document-&gt;create_simple_element( name = lc_xml_node_formula2
parent = lo_document ).
lv_value = lo_data_validation-&gt;formula2.
lo_element_3-&gt;set_value( value = lv_value ).
lo_element_2-&gt;append_child( new_child = lo_element_3 ). &quot; formula2 node
ENDIF.
lo_element-&gt;append_child( new_child = lo_element_2 ). &quot; dataValidation node
ENDWHILE.
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; dataValidations node
ENDIF.
&quot; Hyperlinks
DATA: lv_hyperlinks_count TYPE i,
lo_link TYPE REF TO zcl_excel_hyperlink.
lv_hyperlinks_count = io_worksheet-&gt;get_hyperlinks_size( ).
IF lv_hyperlinks_count &gt; 0.
lo_element = lo_document-&gt;create_simple_element( name = &apos;hyperlinks&apos;
parent = lo_document ).
lo_iterator = io_worksheet-&gt;get_hyperlinks_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_link ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lo_element_2 = lo_document-&gt;create_simple_element( name = &apos;hyperlink&apos;
parent = lo_element ).
lv_value = lo_link-&gt;get_ref( ).
lo_element_2-&gt;set_attribute_ns( name = &apos;ref&apos;
value = lv_value ).
IF lo_link-&gt;is_internal( ) = abap_true.
lv_value = lo_link-&gt;get_url( ).
lo_element_2-&gt;set_attribute_ns( name = &apos;location&apos;
value = lv_value ).
ELSE.
ADD 1 TO lv_relation_id.
lv_value = lv_relation_id.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element_2-&gt;set_attribute_ns( name = &apos;r:id&apos;
value = lv_value ).
ENDIF.
lo_element-&gt;append_child( new_child = lo_element_2 ).
ENDWHILE.
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
&quot; PrintOptions
IF io_worksheet-&gt;print_gridlines = abap_true OR
io_worksheet-&gt;sheet_setup-&gt;vertical_centered = abap_true OR
io_worksheet-&gt;sheet_setup-&gt;vertical_centered = abap_true.
lo_element = lo_document-&gt;create_simple_element( name = &apos;printOptions&apos;
parent = lo_document ).
IF io_worksheet-&gt;print_gridlines = abap_true.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_gridlines
value = &apos;true&apos; ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;horizontal_centered = abap_true.
lo_element-&gt;set_attribute_ns( name = &apos;horizontalCentered&apos;
value = &apos;true&apos; ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;vertical_centered = abap_true.
lo_element-&gt;set_attribute_ns( name = &apos;verticalCentered&apos;
value = &apos;true&apos; ).
ENDIF.
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
&quot; pageMargins node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_pagemargins
parent = lo_document ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;margin_left.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_left
value = lv_value ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;margin_right.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_right
value = lv_value ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;margin_top.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_top
value = lv_value ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;margin_bottom.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_bottom
value = lv_value ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;margin_header.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_header
value = lv_value ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;margin_footer.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_footer
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; pageMargins node
* pageSetup node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_pagesetup
parent = lo_document ).
IF io_worksheet-&gt;sheet_setup-&gt;black_and_white IS NOT INITIAL.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_blackandwhite
value = `1` ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;cell_comments IS NOT INITIAL.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_cellcomments
value = io_worksheet-&gt;sheet_setup-&gt;cell_comments ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;copies IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;copies.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_copies
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;draft IS NOT INITIAL.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_draft
value = `1` ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;errors IS NOT INITIAL.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_errors
value = io_worksheet-&gt;sheet_setup-&gt;errors ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;first_page_number IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;first_page_number.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_firstpagenumber
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;fit_to_page IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;fit_to_height.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_fittoheight
value = lv_value ).
lv_value = io_worksheet-&gt;sheet_setup-&gt;fit_to_width.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_fittowidth
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;horizontal_dpi IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;horizontal_dpi.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_horizontaldpi
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;orientation IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;orientation.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_orientation
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;page_order IS NOT INITIAL.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_pageorder
value = io_worksheet-&gt;sheet_setup-&gt;page_order ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;paper_height IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;paper_height.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_paperheight
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;paper_size IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;paper_size.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_papersize
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;paper_width IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;paper_width.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_paperwidth
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;scale IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;scale.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_scale
value = lv_value ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;use_first_page_num IS NOT INITIAL.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_usefirstpagenumber
value = `1` ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;use_printer_defaults IS NOT INITIAL.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_useprinterdefaults
value = `1` ).
ENDIF.
IF io_worksheet-&gt;sheet_setup-&gt;vertical_dpi IS NOT INITIAL.
lv_value = io_worksheet-&gt;sheet_setup-&gt;vertical_dpi.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_verticaldpi
value = lv_value ).
ENDIF.
lo_element_root-&gt;append_child( new_child = lo_element ). &quot; pageSetup node
* drawing
DATA: lo_drawings TYPE REF TO zcl_excel_drawings.
lo_drawings = io_worksheet-&gt;get_drawings( ).
IF lo_drawings-&gt;is_empty( ) = abap_false.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_drawing
parent = lo_document ).
ADD 1 TO lv_relation_id.
lv_value = lv_relation_id.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element-&gt;set_attribute( name = &apos;r:id&apos;
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
* tables
DATA lv_table_count TYPE i.
lv_table_count = io_worksheet-&gt;get_tables_size( ).
IF lv_table_count &gt; 0.
lo_element = lo_document-&gt;create_simple_element( name = &apos;tableParts&apos;
parent = lo_document ).
lv_value = lv_table_count.
CONDENSE lv_value.
lo_element-&gt;set_attribute_ns( name = &apos;count&apos;
value = lv_value ).
lo_iterator = io_worksheet-&gt;get_tables_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_table ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
ADD 1 TO lv_relation_id.
lv_value = lv_relation_id.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element_2 = lo_document-&gt;create_simple_element( name = &apos;tablePart&apos;
parent = lo_element ).
lo_element_2-&gt;set_attribute_ns( name = &apos;r:id&apos;
value = lv_value ).
lo_element-&gt;append_child( new_child = lo_element_2 ).
ENDWHILE.
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET_RELS" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/workbook/_rels/sheet.xml.rels&apos;" EXPOSURE="1" STATE="1" EDITORDER="11 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET_RELS" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET_RELS" SCONAME="IV_DRAWING_INDEX" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="I"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_SHEET_RELS" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_SHEET_RELS.
** Constant node name
DATA: lc_xml_node_relationships TYPE string VALUE &apos;Relationships&apos;,
lc_xml_node_relationship TYPE string VALUE &apos;Relationship&apos;,
&quot; Node attributes
lc_xml_attr_id TYPE string VALUE &apos;Id&apos;,
lc_xml_attr_type TYPE string VALUE &apos;Type&apos;,
lc_xml_attr_target TYPE string VALUE &apos;Target&apos;,
lc_xml_attr_target_mode TYPE string VALUE &apos;TargetMode&apos;,
lc_xml_val_external TYPE string VALUE &apos;External&apos;,
&quot; Node namespace
lc_xml_node_rels_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/relationships&apos;,
lc_xml_node_rid_table_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/table&apos;,
lc_xml_node_rid_drawing_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing&apos;,
lc_xml_node_rid_link_tp TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_table TYPE REF TO zcl_excel_table,
lo_link TYPE REF TO zcl_excel_hyperlink.
DATA: lv_value TYPE string,
lv_relation_id TYPE i,
lv_index_str TYPE string.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_relationships
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_rels_ns ).
**********************************************************************
* STEP 4: Create subnodes
&quot; Add sheet Relationship nodes here
lv_relation_id = 0.
lo_iterator = io_worksheet-&gt;get_hyperlinks_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_link ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
ADD 1 TO lv_relation_id.
lv_value = lv_relation_id.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_link_tp ).
lv_value = lo_link-&gt;get_url( ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target_mode
value = lc_xml_val_external ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDWHILE.
* drawing
DATA: lo_drawings TYPE REF TO zcl_excel_drawings.
lo_drawings = io_worksheet-&gt;get_drawings( ).
IF lo_drawings-&gt;is_empty( ) = abap_false.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
ADD 1 TO lv_relation_id.
lv_value = lv_relation_id.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_drawing_tp ).
lv_index_str = iv_drawing_index.
CONDENSE lv_index_str NO-GAPS.
MOVE me-&gt;c_xl_drawings TO lv_value.
REPLACE &apos;xl&apos; WITH &apos;..&apos; INTO lv_value.
REPLACE &apos;#&apos; WITH lv_index_str INTO lv_value.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
lo_iterator = io_worksheet-&gt;get_tables_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_table ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
ADD 1 TO lv_relation_id.
lv_value = lv_relation_id.
CONDENSE lv_value.
CONCATENATE &apos;rId&apos; lv_value INTO lv_value.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_relationship
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_value ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_type
value = lc_xml_node_rid_table_tp ).
lv_value = lo_table-&gt;get_name( ).
CONCATENATE &apos;../tables/&apos; lv_value &apos;.xml&apos; INTO lv_value.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_target
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDWHILE.
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/styles.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="13 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>METHOD create_xl_styles.
** Constant node name
CONSTANTS: lc_xml_node_stylesheet TYPE string VALUE &apos;styleSheet&apos;,
&quot; font
lc_xml_node_fonts TYPE string VALUE &apos;fonts&apos;,
lc_xml_node_font TYPE string VALUE &apos;font&apos;,
lc_xml_node_b TYPE string VALUE &apos;b&apos;, &quot;bold
lc_xml_node_i TYPE string VALUE &apos;i&apos;, &quot;italic
lc_xml_node_u TYPE string VALUE &apos;u&apos;, &quot;underline
lc_xml_node_strike TYPE string VALUE &apos;strike&apos;, &quot;strikethrough
lc_xml_node_sz TYPE string VALUE &apos;sz&apos;,
lc_xml_node_color TYPE string VALUE &apos;color&apos;,
lc_xml_node_name TYPE string VALUE &apos;name&apos;,
lc_xml_node_family TYPE string VALUE &apos;family&apos;,
lc_xml_node_scheme TYPE string VALUE &apos;scheme&apos;,
&quot; fill
lc_xml_node_fills TYPE string VALUE &apos;fills&apos;,
lc_xml_node_fill TYPE string VALUE &apos;fill&apos;,
lc_xml_node_patternfill TYPE string VALUE &apos;patternFill&apos;,
lc_xml_node_fgcolor TYPE string VALUE &apos;fgColor&apos;,
lc_xml_node_bgcolor TYPE string VALUE &apos;bgColor&apos;,
lc_xml_node_gradientfill TYPE string VALUE &apos;gradientFill&apos;,
lc_xml_node_stop TYPE string VALUE &apos;stop&apos;,
&quot; borders
lc_xml_node_borders TYPE string VALUE &apos;borders&apos;,
lc_xml_node_border TYPE string VALUE &apos;border&apos;,
lc_xml_node_left TYPE string VALUE &apos;left&apos;,
lc_xml_node_right TYPE string VALUE &apos;right&apos;,
lc_xml_node_top TYPE string VALUE &apos;top&apos;,
lc_xml_node_bottom TYPE string VALUE &apos;bottom&apos;,
lc_xml_node_diagonal TYPE string VALUE &apos;diagonal&apos;,
&quot; numfmt
lc_xml_node_numfmts TYPE string VALUE &apos;numFmts&apos;,
lc_xml_node_numfmt TYPE string VALUE &apos;numFmt&apos;,
&quot; Styles
lc_xml_node_cellstylexfs TYPE string VALUE &apos;cellStyleXfs&apos;,
lc_xml_node_xf TYPE string VALUE &apos;xf&apos;,
lc_xml_node_cellxfs TYPE string VALUE &apos;cellXfs&apos;,
lc_xml_node_cellstyles TYPE string VALUE &apos;cellStyles&apos;,
lc_xml_node_cellstyle TYPE string VALUE &apos;cellStyle&apos;,
lc_xml_node_dxfs TYPE string VALUE &apos;dxfs&apos;,
lc_xml_node_dxf TYPE string VALUE &apos;dxf&apos;,
lc_xml_node_tablestyles TYPE string VALUE &apos;tableStyles&apos;,
&quot; Colors
lc_xml_node_colors TYPE string VALUE &apos;colors&apos;,
lc_xml_node_mrucolors TYPE string VALUE &apos;mruColors&apos;,
&quot; Alignment
lc_xml_node_alignment TYPE string VALUE &apos;alignment&apos;,
&quot; Protection
lc_xml_node_protection TYPE string VALUE &apos;protection&apos;,
&quot; Node attributes
lc_xml_attr_count TYPE string VALUE &apos;count&apos;,
lc_xml_attr_val TYPE string VALUE &apos;val&apos;,
lc_xml_attr_theme TYPE string VALUE &apos;theme&apos;,
lc_xml_attr_rgb TYPE string VALUE &apos;rgb&apos;,
lc_xml_attr_indexed TYPE string VALUE &apos;indexed&apos;,
lc_xml_attr_tint TYPE string VALUE &apos;tint&apos;,
lc_xml_attr_style TYPE string VALUE &apos;style&apos;,
lc_xml_attr_position TYPE string VALUE &apos;position&apos;,
lc_xml_attr_degree TYPE string VALUE &apos;degree&apos;,
lc_xml_attr_patterntype TYPE string VALUE &apos;patternType&apos;,
lc_xml_attr_numfmtid TYPE string VALUE &apos;numFmtId&apos;,
lc_xml_attr_fontid TYPE string VALUE &apos;fontId&apos;,
lc_xml_attr_fillid TYPE string VALUE &apos;fillId&apos;,
lc_xml_attr_borderid TYPE string VALUE &apos;borderId&apos;,
lc_xml_attr_xfid TYPE string VALUE &apos;xfId&apos;,
lc_xml_attr_applynumberformat TYPE string VALUE &apos;applyNumberFormat&apos;,
lc_xml_attr_applyprotection TYPE string VALUE &apos;applyProtection&apos;,
lc_xml_attr_applyfont TYPE string VALUE &apos;applyFont&apos;,
lc_xml_attr_applyfill TYPE string VALUE &apos;applyFill&apos;,
lc_xml_attr_applyborder TYPE string VALUE &apos;applyBorder&apos;,
lc_xml_attr_name TYPE string VALUE &apos;name&apos;,
lc_xml_attr_builtinid TYPE string VALUE &apos;builtinId&apos;,
lc_xml_attr_defaulttablestyle TYPE string VALUE &apos;defaultTableStyle&apos;,
lc_xml_attr_defaultpivotstyle TYPE string VALUE &apos;defaultPivotStyle&apos;,
lc_xml_attr_applyalignment TYPE string VALUE &apos;applyAlignment&apos;,
lc_xml_attr_horizontal TYPE string VALUE &apos;horizontal&apos;,
lc_xml_attr_formatcode TYPE string VALUE &apos;formatCode&apos;,
lc_xml_attr_vertical TYPE string VALUE &apos;vertical&apos;,
lc_xml_attr_wraptext TYPE string VALUE &apos;wrapText&apos;,
lc_xml_attr_textrotation TYPE string VALUE &apos;textRotation&apos;,
lc_xml_attr_shrinktofit TYPE string VALUE &apos;shrinkToFit&apos;,
lc_xml_attr_indent TYPE string VALUE &apos;indent&apos;,
lc_xml_attr_locked TYPE string VALUE &apos;locked&apos;,
lc_xml_attr_hidden TYPE string VALUE &apos;hidden&apos;,
lc_xml_attr_diagonalup TYPE string VALUE &apos;diagonalUp&apos;,
lc_xml_attr_diagonaldown TYPE string VALUE &apos;diagonalDown&apos;,
&quot; Node namespace
lc_xml_node_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/spreadsheetml/2006/main&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element_fonts TYPE REF TO if_ixml_element,
lo_element_font TYPE REF TO if_ixml_element,
lo_element_fills TYPE REF TO if_ixml_element,
lo_element_fill TYPE REF TO if_ixml_element,
lo_element_borders TYPE REF TO if_ixml_element,
lo_element_border TYPE REF TO if_ixml_element,
lo_element_numfmts TYPE REF TO if_ixml_element,
lo_element_numfmt TYPE REF TO if_ixml_element,
lo_element_cellxfs TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_sub_element TYPE REF TO if_ixml_element,
lo_sub_element_2 TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_iterator2 TYPE REF TO cl_object_collection_iterator,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
lo_style TYPE REF TO zcl_excel_style.
DATA: lt_fonts TYPE zexcel_t_style_font,
ls_font TYPE zexcel_s_style_font,
lt_fills TYPE zexcel_t_style_fill,
ls_fill TYPE zexcel_s_style_fill,
lt_borders TYPE zexcel_t_style_border,
ls_border TYPE zexcel_s_style_border,
lt_numfmts TYPE zexcel_t_style_numfmt,
ls_numfmt TYPE zexcel_s_style_numfmt,
lt_protections TYPE zexcel_t_style_protection,
ls_protection TYPE zexcel_s_style_protection,
lt_alignments TYPE zexcel_t_style_alignment,
ls_alignment TYPE zexcel_s_style_alignment,
lt_cellxfs TYPE zexcel_t_cellxfs,
ls_cellxfs TYPE zexcel_s_cellxfs,
ls_styles_mapping TYPE zexcel_s_styles_mapping,
ls_style_cond_mapping TYPE zexcel_s_styles_cond_mapping,
ls_cellis TYPE zexcel_conditional_cellis,
ls_expression TYPE zexcel_conditional_expression.
DATA: lv_value TYPE string,
lv_dfx_count TYPE i,
lv_fonts_count TYPE i,
lv_fills_count TYPE i,
lv_borders_count TYPE i,
lv_cellxfs_count TYPE i,
lv_align_flag TYPE c.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
***********************************************************************
* STEP 3: Create main node relationships
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_stylesheet
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_ns ).
**********************************************************************
* STEP 4: Create subnodes
lo_element_fonts = lo_document-&gt;create_simple_element( name = lc_xml_node_fonts
parent = lo_document ).
lo_element_fills = lo_document-&gt;create_simple_element( name = lc_xml_node_fills
parent = lo_document ).
lo_element_borders = lo_document-&gt;create_simple_element( name = lc_xml_node_borders
parent = lo_document ).
lo_element_cellxfs = lo_document-&gt;create_simple_element( name = lc_xml_node_cellxfs
parent = lo_document ).
lo_element_numfmts = lo_document-&gt;create_simple_element( name = lc_xml_node_numfmts
parent = lo_document ).
* Compress styles
lo_iterator = excel-&gt;get_styles_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_style ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
ls_font = lo_style-&gt;font-&gt;get_structure( ).
ls_fill = lo_style-&gt;fill-&gt;get_structure( ).
ls_border = lo_style-&gt;borders-&gt;get_structure( ).
ls_alignment = lo_style-&gt;alignment-&gt;get_structure( ).
ls_protection = lo_style-&gt;protection-&gt;get_structure( ).
ls_numfmt = lo_style-&gt;number_format-&gt;get_structure( ).
CLEAR ls_cellxfs.
* Compress fonts
READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_cellxfs-fontid = sy-tabix.
ELSE.
APPEND ls_font TO lt_fonts.
DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid.
ENDIF.
SUBTRACT 1 FROM ls_cellxfs-fontid.
* Compress alignment
READ TABLE lt_alignments FROM ls_alignment TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_cellxfs-alignmentid = sy-tabix.
ELSE.
APPEND ls_alignment TO lt_alignments.
DESCRIBE TABLE lt_alignments LINES ls_cellxfs-alignmentid.
ENDIF.
SUBTRACT 1 FROM ls_cellxfs-alignmentid.
* Compress fills
READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_cellxfs-fillid = sy-tabix.
ELSE.
APPEND ls_fill TO lt_fills.
DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid.
ENDIF.
SUBTRACT 1 FROM ls_cellxfs-fillid.
* Compress borders
READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_cellxfs-borderid = sy-tabix.
ELSE.
APPEND ls_border TO lt_borders.
DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid.
ENDIF.
SUBTRACT 1 FROM ls_cellxfs-borderid.
* Compress protection
IF ls_protection-locked EQ c_on AND ls_protection-hidden EQ c_off.
ls_cellxfs-applyprotection = 0.
ELSE.
READ TABLE lt_protections FROM ls_protection TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_cellxfs-protectionid = sy-tabix.
ELSE.
APPEND ls_protection TO lt_protections.
DESCRIBE TABLE lt_protections LINES ls_cellxfs-protectionid.
ENDIF.
ls_cellxfs-applyprotection = 1.
ENDIF.
SUBTRACT 1 FROM ls_cellxfs-protectionid.
* Compress number formats
IF ls_numfmt IS NOT INITIAL.
READ TABLE lt_numfmts FROM ls_numfmt TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_cellxfs-numfmtid = sy-tabix.
ELSE.
APPEND ls_numfmt TO lt_numfmts.
DESCRIBE TABLE lt_numfmts LINES ls_cellxfs-numfmtid.
ENDIF.
ADD zcl_excel_common=&gt;c_excel_numfmt_offset TO ls_cellxfs-numfmtid. &quot; Add OXML offset for custom styles
ls_cellxfs-applynumberformat = 1.
ELSE.
ls_cellxfs-applynumberformat = 0.
ENDIF.
IF ls_cellxfs-fontid NE 0.
ls_cellxfs-applyfont = 1.
ELSE.
ls_cellxfs-applyfont = 0.
ENDIF.
IF ls_cellxfs-alignmentid NE 0.
ls_cellxfs-applyalignment = 1.
ELSE.
ls_cellxfs-applyalignment = 0.
ENDIF.
IF ls_cellxfs-fillid NE 0.
ls_cellxfs-applyfill = 1.
ELSE.
ls_cellxfs-applyfill = 0.
ENDIF.
IF ls_cellxfs-borderid NE 0.
ls_cellxfs-applyborder = 1.
ELSE.
ls_cellxfs-applyborder = 0.
ENDIF.
* Remap styles
READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
ls_styles_mapping-style = sy-tabix.
ELSE.
APPEND ls_cellxfs TO lt_cellxfs.
DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style.
ENDIF.
SUBTRACT 1 FROM ls_styles_mapping-style.
ls_styles_mapping-guid = lo_style-&gt;get_guid( ).
APPEND ls_styles_mapping TO me-&gt;styles_mapping.
ENDWHILE.
&quot; create numfmt elements
LOOP AT lt_numfmts INTO ls_numfmt.
lo_element_numfmt = lo_document-&gt;create_simple_element( name = lc_xml_node_numfmt
parent = lo_document ).
lv_value = sy-tabix + zcl_excel_common=&gt;c_excel_numfmt_offset.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_numfmt-&gt;set_attribute_ns( name = lc_xml_attr_numfmtid
value = lv_value ).
lv_value = ls_numfmt-numfmt.
lo_element_numfmt-&gt;set_attribute_ns( name = lc_xml_attr_formatcode
value = lv_value ).
lo_element_numfmts-&gt;append_child( new_child = lo_element_numfmt ).
ENDLOOP.
&quot; create font elements
LOOP AT lt_fonts INTO ls_font.
lo_element_font = lo_document-&gt;create_simple_element( name = lc_xml_node_font
parent = lo_document ).
IF ls_font-bold EQ abap_true.
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_b
parent = lo_document ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
ENDIF.
IF ls_font-italic EQ abap_true.
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_i
parent = lo_document ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
ENDIF.
IF ls_font-underline EQ abap_true.
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_u
parent = lo_document ).
lv_value = ls_font-underline_mode.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_val
value = lv_value ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
ENDIF.
IF ls_font-strikethrough EQ abap_true.
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_strike
parent = lo_document ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
ENDIF.
&quot;size
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sz
parent = lo_document ).
lv_value = ls_font-size.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_val
value = lv_value ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
&quot;color
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_element_font
is_color = ls_font-color ).
&quot;name
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_name
parent = lo_document ).
lv_value = ls_font-name.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_val
value = lv_value ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
&quot;family
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_family
parent = lo_document ).
lv_value = ls_font-family.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_val
value = lv_value ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
&quot;scheme
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_scheme
parent = lo_document ).
lv_value = ls_font-scheme.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_val
value = lv_value ).
lo_element_font-&gt;append_child( new_child = lo_sub_element ).
lo_element_fonts-&gt;append_child( new_child = lo_element_font ).
ENDLOOP.
&quot; create fill elements
LOOP AT lt_fills INTO ls_fill.
lo_element_fill = lo_document-&gt;create_simple_element( name = lc_xml_node_fill
parent = lo_document ).
&quot;pattern
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_patternfill
parent = lo_document ).
lv_value = ls_fill-filltype.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_patterntype
value = lv_value ).
&quot; fgcolor
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_fill-fgcolor
iv_color_elem_name = lc_xml_node_fgcolor ).
&quot; bgcolor
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_fill-bgcolor
iv_color_elem_name = lc_xml_node_bgcolor ).
lo_element_fill-&gt;append_child( new_child = lo_sub_element ).&quot;pattern
lo_element_fills-&gt;append_child( new_child = lo_element_fill ).
ENDLOOP.
&quot; create border elements
LOOP AT lt_borders INTO ls_border.
lo_element_border = lo_document-&gt;create_simple_element( name = lc_xml_node_border
parent = lo_document ).
IF ls_border-diagonalup IS NOT INITIAL.
lv_value = ls_border-diagonalup.
CONDENSE lv_value.
lo_element_border-&gt;set_attribute_ns( name = lc_xml_attr_diagonalup
value = lv_value ).
ENDIF.
IF ls_border-diagonaldown IS NOT INITIAL.
lv_value = ls_border-diagonaldown.
CONDENSE lv_value.
lo_element_border-&gt;set_attribute_ns( name = lc_xml_attr_diagonaldown
value = lv_value ).
ENDIF.
&quot;left
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_left
parent = lo_document ).
IF ls_border-left_style IS NOT INITIAL.
lv_value = ls_border-left_style.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
ENDIF.
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_border-left_color ).
lo_element_border-&gt;append_child( new_child = lo_sub_element ).
&quot;right
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_right
parent = lo_document ).
IF ls_border-right_style IS NOT INITIAL.
lv_value = ls_border-right_style.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
ENDIF.
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_border-right_color ).
lo_element_border-&gt;append_child( new_child = lo_sub_element ).
&quot;top
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_top
parent = lo_document ).
IF ls_border-top_style IS NOT INITIAL.
lv_value = ls_border-top_style.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
ENDIF.
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_border-top_color ).
lo_element_border-&gt;append_child( new_child = lo_sub_element ).
&quot;bottom
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_bottom
parent = lo_document ).
IF ls_border-bottom_style IS NOT INITIAL.
lv_value = ls_border-bottom_style.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
ENDIF.
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_border-bottom_color ).
lo_element_border-&gt;append_child( new_child = lo_sub_element ).
&quot;diagonal
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_diagonal
parent = lo_document ).
IF ls_border-diagonal_style IS NOT INITIAL.
lv_value = ls_border-diagonal_style.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_style
value = lv_value ).
ENDIF.
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element
is_color = ls_border-diagonal_color ).
lo_element_border-&gt;append_child( new_child = lo_sub_element ).
lo_element_borders-&gt;append_child( new_child = lo_element_border ).
ENDLOOP.
&quot; update attribute &quot;count&quot;
DESCRIBE TABLE lt_fonts LINES lv_fonts_count.
MOVE lv_fonts_count TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_fonts-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_value ).
DESCRIBE TABLE lt_fills LINES lv_fills_count.
MOVE lv_fills_count TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_fills-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_value ).
DESCRIBE TABLE lt_borders LINES lv_borders_count.
MOVE lv_borders_count TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_borders-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_value ).
DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count.
MOVE lv_cellxfs_count TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element_cellxfs-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_value ).
&quot; Append to root node
lo_element_root-&gt;append_child( new_child = lo_element_numfmts ).
lo_element_root-&gt;append_child( new_child = lo_element_fonts ).
lo_element_root-&gt;append_child( new_child = lo_element_fills ).
lo_element_root-&gt;append_child( new_child = lo_element_borders ).
&quot; cellstylexfs node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_cellstylexfs
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_count
value = &apos;1&apos; ).
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_xf
parent = lo_document ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_numfmtid
value = c_off ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_fontid
value = c_off ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_fillid
value = c_off ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_borderid
value = c_off ).
lo_element-&gt;append_child( new_child = lo_sub_element ).
lo_element_root-&gt;append_child( new_child = lo_element ).
LOOP AT lt_cellxfs INTO ls_cellxfs.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_xf
parent = lo_document ).
MOVE ls_cellxfs-numfmtid TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_numfmtid
value = lv_value ).
MOVE ls_cellxfs-fontid TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_fontid
value = lv_value ).
MOVE ls_cellxfs-fillid TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_fillid
value = lv_value ).
MOVE ls_cellxfs-borderid TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_borderid
value = lv_value ).
MOVE ls_cellxfs-xfid TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_xfid
value = lv_value ).
IF ls_cellxfs-applynumberformat EQ 1.
MOVE ls_cellxfs-applynumberformat TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_applynumberformat
value = lv_value ).
ENDIF.
IF ls_cellxfs-applyfont EQ 1.
MOVE ls_cellxfs-applyfont TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_applyfont
value = lv_value ).
ENDIF.
IF ls_cellxfs-applyfill EQ 1.
MOVE ls_cellxfs-applyfill TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_applyfill
value = lv_value ).
ENDIF.
IF ls_cellxfs-applyborder EQ 1.
MOVE ls_cellxfs-applyborder TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_applyborder
value = lv_value ).
ENDIF.
IF ls_cellxfs-applyalignment EQ 1. &quot; depends on each style not for all the sheet
MOVE ls_cellxfs-applyalignment TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_applyalignment
value = lv_value ).
lo_sub_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_alignment
parent = lo_document ).
ADD 1 TO ls_cellxfs-alignmentid. &quot;Table index starts from 1
READ TABLE lt_alignments INTO ls_alignment INDEX ls_cellxfs-alignmentid.
SUBTRACT 1 FROM ls_cellxfs-alignmentid.
IF ls_alignment-horizontal IS NOT INITIAL.
MOVE ls_alignment-horizontal TO lv_value.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_horizontal
value = lv_value ).
ENDIF.
IF ls_alignment-vertical IS NOT INITIAL.
MOVE ls_alignment-vertical TO lv_value.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_vertical
value = lv_value ).
ENDIF.
IF ls_alignment-wraptext EQ abap_true.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_wraptext
value = c_on ).
ENDIF.
IF ls_alignment-textrotation IS NOT INITIAL.
MOVE ls_alignment-textrotation TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_textrotation
value = lv_value ).
ENDIF.
IF ls_alignment-shrinktofit EQ abap_true.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_shrinktofit
value = c_on ).
ENDIF.
IF ls_alignment-indent IS NOT INITIAL.
MOVE ls_alignment-indent TO lv_value.
SHIFT lv_value RIGHT DELETING TRAILING space.
SHIFT lv_value LEFT DELETING LEADING space.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_indent
value = lv_value ).
ENDIF.
lo_element-&gt;append_child( new_child = lo_sub_element_2 ).
ENDIF.
IF ls_cellxfs-applyprotection EQ 1.
MOVE ls_cellxfs-applyprotection TO lv_value.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_applyprotection
value = lv_value ).
lo_sub_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_protection
parent = lo_document ).
ADD 1 TO ls_cellxfs-protectionid. &quot;Table index starts from 1
READ TABLE lt_protections INTO ls_protection INDEX ls_cellxfs-protectionid.
SUBTRACT 1 FROM ls_cellxfs-protectionid.
IF ls_protection-locked IS NOT INITIAL.
MOVE ls_protection-locked TO lv_value.
CONDENSE lv_value.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_locked
value = lv_value ).
ENDIF.
IF ls_protection-hidden IS NOT INITIAL.
MOVE ls_protection-hidden TO lv_value.
CONDENSE lv_value.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_hidden
value = lv_value ).
ENDIF.
lo_element-&gt;append_child( new_child = lo_sub_element_2 ).
ENDIF.
lo_element_cellxfs-&gt;append_child( new_child = lo_element ).
ENDLOOP.
lo_element_root-&gt;append_child( new_child = lo_element_cellxfs ).
&quot; cellStyles node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_cellstyles
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_count
value = &apos;1&apos; ).
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_cellstyle
parent = lo_document ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_name
value = &apos;Normal&apos; ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_xfid
value = c_off ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_builtinid
value = c_off ).
lo_element-&gt;append_child( new_child = lo_sub_element ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; dxfs node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_dxfs
parent = lo_document ).
lo_iterator = me-&gt;excel-&gt;get_worksheets_iterator( ).
&quot; get sheets
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_worksheet ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
&quot; Conditional formatting styles into exch sheet
lo_iterator2 = lo_worksheet-&gt;get_cond_styles_iterator( ).
WHILE lo_iterator2-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_style_conditional ?= lo_iterator2-&gt;if_object_collection_iterator~get_next( ).
CASE lo_style_conditional-&gt;rule.
WHEN zcl_excel_style_conditional=&gt;c_rule_cellis.
&quot;if style defined
ls_cellis = lo_style_conditional-&gt;mode_cellis.
IF ls_cellis-cell_style IS INITIAL.
CONTINUE.
ENDIF.
READ TABLE me-&gt;styles_mapping INTO ls_styles_mapping WITH KEY guid = ls_cellis-cell_style.
ADD 1 TO ls_styles_mapping-style. &quot; the numbering starts from 0
READ TABLE lt_cellxfs INTO ls_cellxfs INDEX ls_styles_mapping-style.
ADD 1 TO ls_cellxfs-fillid. &quot; the numbering starts from 0
&quot; Style already mapped?
READ TABLE me-&gt;styles_cond_mapping INTO ls_style_cond_mapping WITH KEY style = ls_styles_mapping-style.
IF sy-subrc EQ 0.
ls_style_cond_mapping-guid = ls_cellis-cell_style.
APPEND ls_style_cond_mapping TO me-&gt;styles_cond_mapping.
ELSE.
ls_style_cond_mapping-guid = ls_cellis-cell_style.
ls_style_cond_mapping-style = ls_styles_mapping-style.
ls_style_cond_mapping-dxf = lv_dfx_count.
APPEND ls_style_cond_mapping TO me-&gt;styles_cond_mapping.
ADD 1 TO lv_dfx_count.
&quot; dxf node
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_dxf
parent = lo_document ).
READ TABLE lt_fills INTO ls_fill INDEX ls_cellxfs-fillid.
IF ls_fill IS NOT INITIAL.
&quot; fill properties
lo_element_fill = lo_document-&gt;create_simple_element( name = lc_xml_node_fill
parent = lo_document ).
&quot;pattern
lo_sub_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_patternfill
parent = lo_document ).
lv_value = ls_fill-filltype.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_patterntype
value = lv_value ).
&quot; fgcolor
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element_2
is_color = ls_fill-fgcolor
iv_color_elem_name = lc_xml_node_fgcolor ).
&quot; bgcolor
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element_2
is_color = ls_fill-bgcolor
iv_color_elem_name = lc_xml_node_bgcolor ).
lo_element_fill-&gt;append_child( new_child = lo_sub_element_2 ). &quot;pattern
lo_sub_element-&gt;append_child( new_child = lo_element_fill ).
ENDIF.
ENDIF.
lo_element-&gt;append_child( new_child = lo_sub_element ).
WHEN zcl_excel_style_conditional=&gt;c_rule_expression.
&quot;if style defined
ls_expression = lo_style_conditional-&gt;mode_expression.
IF ls_expression-cell_style IS INITIAL.
CONTINUE.
ENDIF.
READ TABLE me-&gt;styles_mapping INTO ls_styles_mapping WITH KEY guid = ls_expression-cell_style.
ADD 1 TO ls_styles_mapping-style. &quot; the numbering starts from 0
READ TABLE lt_cellxfs INTO ls_cellxfs INDEX ls_styles_mapping-style.
ADD 1 TO ls_cellxfs-fillid. &quot; the numbering starts from 0
READ TABLE me-&gt;styles_cond_mapping INTO ls_style_cond_mapping WITH KEY style = ls_styles_mapping-style.
IF sy-subrc EQ 0.
ls_style_cond_mapping-guid = ls_expression-cell_style.
APPEND ls_style_cond_mapping TO me-&gt;styles_cond_mapping.
ELSE.
ls_style_cond_mapping-guid = ls_expression-cell_style.
ls_style_cond_mapping-style = ls_styles_mapping-style.
ls_style_cond_mapping-dxf = lv_dfx_count.
APPEND ls_style_cond_mapping TO me-&gt;styles_cond_mapping.
ADD 1 TO lv_dfx_count.
&quot; dxf node
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_dxf
parent = lo_document ).
READ TABLE lt_fills INTO ls_fill INDEX ls_cellxfs-fillid.
IF ls_fill IS NOT INITIAL.
&quot; fill properties
lo_element_fill = lo_document-&gt;create_simple_element( name = lc_xml_node_fill
parent = lo_document ).
&quot;pattern
lo_sub_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_patternfill
parent = lo_document ).
lv_value = ls_fill-filltype.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_patterntype
value = lv_value ).
&quot; fgcolor
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element_2
is_color = ls_fill-fgcolor
iv_color_elem_name = lc_xml_node_fgcolor ).
&quot; bgcolor
create_xl_styles_color_node(
io_document = lo_document
io_parent = lo_sub_element_2
is_color = ls_fill-bgcolor
iv_color_elem_name = lc_xml_node_bgcolor ).
lo_element_fill-&gt;append_child( new_child = lo_sub_element_2 ). &quot;pattern
lo_sub_element-&gt;append_child( new_child = lo_element_fill ).
ENDIF.
ENDIF.
lo_element-&gt;append_child( new_child = lo_sub_element ).
WHEN OTHERS.
CONTINUE.
ENDCASE.
ENDWHILE.
ENDWHILE.
lv_value = lv_dfx_count.
CONDENSE lv_value.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_count
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; tableStyles node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_tablestyles
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_count
value = &apos;0&apos; ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_defaulttablestyle
value = zcl_excel_table=&gt;builtinstyle_medium9 ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_defaultpivotstyle
value = zcl_excel_table=&gt;builtinstyle_pivot_light16 ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES_COLOR_NODE" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/styles.xml&apos; color node" EXPOSURE="1" STATE="1" EDITORDER="12 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES_COLOR_NODE" SCONAME="IO_DOCUMENT" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_DOCUMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES_COLOR_NODE" SCONAME="IO_PARENT" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES_COLOR_NODE" SCONAME="IV_COLOR_ELEM_NAME" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING" PARVALUE="&apos;color&apos;"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_STYLES_COLOR_NODE" SCONAME="IS_COLOR" VERSION="1" LANGU="E" DESCRIPT="Color" CMPTYPE="1" MTDTYPE="0" EDITORDER="4 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_S_STYLE_COLOR"/>
<source>method CREATE_XL_STYLES_COLOR_NODE.
DATA: lo_sub_element TYPE REF TO if_ixml_element,
lv_value TYPE string.
CONSTANTS: lc_xml_attr_theme TYPE string VALUE &apos;theme&apos;,
lc_xml_attr_rgb TYPE string VALUE &apos;rgb&apos;,
lc_xml_attr_indexed TYPE string VALUE &apos;indexed&apos;,
lc_xml_attr_tint TYPE string VALUE &apos;tint&apos;.
&quot;add node only if at least one attribute is set
CHECK is_color-rgb IS NOT INITIAL OR
is_color-indexed &lt;&gt; zcl_excel_style_color=&gt;c_indexed_not_set OR
is_color-theme &lt;&gt; zcl_excel_style_color=&gt;c_theme_not_set OR
is_color-tint IS NOT INITIAL.
lo_sub_element = io_document-&gt;create_simple_element(
name = iv_color_elem_name
parent = io_parent ).
IF is_color-rgb IS NOT INITIAL.
lv_value = is_color-rgb.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_rgb
value = lv_value ).
ENDIF.
IF is_color-indexed &lt;&gt; zcl_excel_style_color=&gt;c_indexed_not_set.
lv_value = zcl_excel_common=&gt;number_to_excel_string( is_color-indexed ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_indexed
value = lv_value ).
ENDIF.
IF is_color-theme &lt;&gt; zcl_excel_style_color=&gt;c_theme_not_set.
lv_value = zcl_excel_common=&gt;number_to_excel_string( is_color-theme ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_theme
value = lv_value ).
ENDIF.
IF is_color-tint IS NOT INITIAL.
lv_value = zcl_excel_common=&gt;number_to_excel_string( is_color-tint ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_tint
value = lv_value ).
ENDIF.
io_parent-&gt;append_child( new_child = lo_sub_element ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_TABLE" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="14 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_TABLE" SCONAME="IO_TABLE" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_TABLE"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_TABLE" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_TABLE.
DATA: lc_xml_node_table TYPE string VALUE &apos;table&apos;,
lc_xml_node_relationship TYPE string VALUE &apos;Relationship&apos;,
&quot; Node attributes
lc_xml_attr_id TYPE string VALUE &apos;id&apos;,
lc_xml_attr_name TYPE string VALUE &apos;name&apos;,
lc_xml_attr_display_name TYPE string VALUE &apos;displayName&apos;,
lc_xml_attr_ref TYPE string VALUE &apos;ref&apos;,
lc_xml_attr_totals TYPE string VALUE &apos;totalsRowShown&apos;,
&quot; Node namespace
lc_xml_node_table_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/spreadsheetml/2006/main&apos;,
&quot; Node id
lc_xml_node_ridx_id TYPE string VALUE &apos;rId#&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_element2 TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lv_table_name TYPE string,
lv_id TYPE i,
lv_syindex TYPE char3,
lv_ref TYPE string,
lv_value TYPE string,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lv_num_columns TYPE i,
ls_fieldcat TYPE zexcel_s_fieldcatalog.
**********************************************************************
* STEP 1: Create xml
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node table
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_table
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_table_ns ).
lv_id = io_table-&gt;get_id( ).
lv_value = zcl_excel_common=&gt;number_to_excel_string( ip_value = lv_id ).
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_id
value = lv_value ).
lv_table_name = io_table-&gt;get_name( ).
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_name
value = lv_table_name ).
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_display_name
value = lv_table_name ).
lv_ref = io_table-&gt;get_reference( ).
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_ref
value = lv_ref ).
IF io_table-&gt;has_totals( ) = abap_true.
lo_element_root-&gt;set_attribute_ns( name = &apos;totalsRowCount&apos;
value = &apos;1&apos; ).
ELSE.
lo_element_root-&gt;set_attribute_ns( name = lc_xml_attr_totals
value = &apos;0&apos; ).
ENDIF.
**********************************************************************
* STEP 4: Create subnodes
&quot; autoFilter
lo_element = lo_document-&gt;create_simple_element( name = &apos;autoFilter&apos;
parent = lo_document ).
lv_ref = io_table-&gt;get_reference( ip_include_totals_row = abap_false ).
lo_element-&gt;set_attribute_ns( name = &apos;ref&apos;
value = lv_ref ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot;columns
lo_element = lo_document-&gt;create_simple_element( name = &apos;tableColumns&apos;
parent = lo_document ).
* lo_columns = io_table-&gt;get_columns( ).
LOOP AT io_table-&gt;fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true.
ADD 1 TO lv_num_columns.
ENDLOOP.
lv_value = lv_num_columns.
CONDENSE lv_value.
lo_element-&gt;set_attribute_ns( name = &apos;count&apos;
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
LOOP AT io_table-&gt;fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true.
lo_element2 = lo_document-&gt;create_simple_element_ns( name = &apos;tableColumn&apos;
parent = lo_element ).
lv_value = ls_fieldcat-position.
SHIFT lv_value LEFT DELETING LEADING &apos;0&apos;.
lo_element2-&gt;set_attribute_ns( name = &apos;id&apos;
value = lv_value ).
lv_value = ls_fieldcat-scrtext_m.
lo_element2-&gt;set_attribute_ns( name = &apos;name&apos;
value = lv_value ).
IF ls_fieldcat-totals_function IS NOT INITIAL.
lo_element2-&gt;set_attribute_ns( name = &apos;totalsRowFunction&apos;
value = ls_fieldcat-totals_function ).
ENDIF.
lo_element-&gt;append_child( new_child = lo_element2 ).
ENDLOOP.
lo_element = lo_document-&gt;create_simple_element( name = &apos;tableStyleInfo&apos;
parent = lo_element_root ).
lo_element-&gt;set_attribute_ns( name = &apos;name&apos;
value = io_table-&gt;settings-table_style ).
lo_element-&gt;set_attribute_ns( name = &apos;showFirstColumn&apos;
value = &apos;0&apos; ).
lo_element-&gt;set_attribute_ns( name = &apos;showLastColumn&apos;
value = &apos;0&apos; ).
IF io_table-&gt;settings-show_row_stripes = abap_true.
lv_value = &apos;1&apos;.
ELSE.
lv_value = &apos;0&apos;.
ENDIF.
lo_element-&gt;set_attribute_ns( name = &apos;showRowStripes&apos;
value = lv_value ).
IF io_table-&gt;settings-show_column_stripes = abap_true.
lv_value = &apos;1&apos;.
ELSE.
lv_value = &apos;0&apos;.
ENDIF.
lo_element-&gt;set_attribute_ns( name = &apos;showColumnStripes&apos;
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_THEME" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/theme/theme1.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="15 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_THEME" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_THEME.
* @TODO *
DATA: lv_xl_theme TYPE string,
lv_xl_theme_01 TYPE string,
lv_xl_theme_02 TYPE string,
lv_xl_theme_03 TYPE string,
lv_xl_theme_04 TYPE string,
lv_xl_theme_05 TYPE string,
lv_xl_theme_06 TYPE string,
lv_xl_theme_07 TYPE string,
lv_xl_theme_08 TYPE string,
lv_xl_theme_09 TYPE string,
lv_xl_theme_10 TYPE string,
lv_xl_theme_11 TYPE string,
lv_xl_theme_12 TYPE string,
lv_xl_theme_13 TYPE string,
lv_xl_theme_14 TYPE string,
lv_xl_theme_15 TYPE string,
lv_xl_theme_16 TYPE string,
lv_xl_theme_17 TYPE string,
lv_xl_theme_18 TYPE string,
lv_xl_theme_19 TYPE string,
lv_xl_theme_20 TYPE string,
lv_xl_theme_21 TYPE string,
lv_xl_theme_22 TYPE string,
lv_xl_theme_23 TYPE string,
lv_xl_theme_24 TYPE string,
lv_xl_theme_25 TYPE string,
lv_xl_theme_26 TYPE string,
lv_xl_theme_27 TYPE string,
lv_xl_theme_28 TYPE string,
lv_xl_theme_29 TYPE string,
lv_xl_theme_30 TYPE string,
lv_xl_theme_31 TYPE string,
lv_xl_theme_32 TYPE string.
lv_xl_theme_01 = &apos;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;&apos;.
lv_xl_theme_02 = &apos;&lt;a:theme xmlns:a=&quot;http://schemas.openxmlformats.org/drawingml/2006/main&quot; name=&quot;Office Theme&quot;&gt;&lt;a:themeElements&gt;&lt;a:clrScheme name=&quot;Office&quot;&gt;&lt;a:dk1&gt;&lt;a:sysClr val=&quot;windowText&quot; lastClr=&quot;000000&quot;/&gt;&lt;/a:dk1&gt;&lt;a:lt1&gt;&lt;a:sysClr val=&quot;window&quot; &apos;.
lv_xl_theme_03 = &apos;lastClr=&quot;FFFFFF&quot;/&gt;&lt;/a:lt1&gt;&lt;a:dk2&gt;&lt;a:srgbClr val=&quot;1F497D&quot;/&gt;&lt;/a:dk2&gt;&lt;a:lt2&gt;&lt;a:srgbClr val=&quot;EEECE1&quot;/&gt;&lt;/a:lt2&gt;&lt;a:accent1&gt;&lt;a:srgbClr val=&quot;4F81BD&quot;/&gt;&lt;/a:accent1&gt;&lt;a:accent2&gt;&lt;a:srgbClr val=&quot;C0504D&quot;/&gt;&lt;/a:accent2&gt;&lt;a:accent3&gt;&lt;a:srgbClr &apos;.
lv_xl_theme_04 = &apos;val=&quot;9BBB59&quot;/&gt;&lt;/a:accent3&gt;&lt;a:accent4&gt;&lt;a:srgbClr val=&quot;8064A2&quot;/&gt;&lt;/a:accent4&gt;&lt;a:accent5&gt;&lt;a:srgbClr val=&quot;4BACC6&quot;/&gt;&lt;/a:accent5&gt;&lt;a:accent6&gt;&lt;a:srgbClr val=&quot;F79646&quot;/&gt;&lt;/a:accent6&gt;&lt;a:hlink&gt;&lt;a:srgbClr val=&quot;0000FF&quot;/&gt;&lt;/a:hlink&gt;&lt;a:folHlink&gt;&apos;.
lv_xl_theme_05 = &apos;&lt;a:srgbClr val=&quot;800080&quot;/&gt;&lt;/a:folHlink&gt;&lt;/a:clrScheme&gt;&lt;a:fontScheme name=&quot;Office&quot;&gt;&lt;a:majorFont&gt;&lt;a:latin typeface=&quot;Cambria&quot;/&gt;&lt;a:ea typeface=&quot;&quot;/&gt;&lt;a:cs typeface=&quot;&quot;/&gt;&apos;.
lv_xl_theme_06 = &apos;&lt;a:font script=&quot;Arab&quot; typeface=&quot;Times New Roman&quot;/&gt;&lt;a:font script=&quot;Hebr&quot; typeface=&quot;Times New Roman&quot;/&gt;&lt;a:font script=&quot;Thai&quot; &apos;.
lv_xl_theme_07 = &apos;typeface=&quot;Tahoma&quot;/&gt;&lt;a:font script=&quot;Ethi&quot; typeface=&quot;Nyala&quot;/&gt;&lt;a:font script=&quot;Beng&quot; typeface=&quot;Vrinda&quot;/&gt;&lt;a:font script=&quot;Gujr&quot; typeface=&quot;Shruti&quot;/&gt;&lt;a:font script=&quot;Khmr&quot; typeface=&quot;MoolBoran&quot;/&gt;&lt;a:font script=&quot;Knda&quot; typeface=&quot;Tunga&quot;/&gt;&lt;a:font &apos;.
lv_xl_theme_08 = &apos;script=&quot;Guru&quot; typeface=&quot;Raavi&quot;/&gt;&lt;a:font script=&quot;Cans&quot; typeface=&quot;Euphemia&quot;/&gt;&lt;a:font script=&quot;Cher&quot; typeface=&quot;Plantagenet Cherokee&quot;/&gt;&lt;a:font script=&quot;Yiii&quot; typeface=&quot;Microsoft Yi Baiti&quot;/&gt;&lt;a:font script=&quot;Tibt&quot; &apos;.
lv_xl_theme_09 = &apos;typeface=&quot;Microsoft Himalaya&quot;/&gt;&lt;a:font script=&quot;Thaa&quot; typeface=&quot;MV Boli&quot;/&gt;&lt;a:font script=&quot;Deva&quot; typeface=&quot;Mangal&quot;/&gt;&lt;a:font script=&quot;Telu&quot; typeface=&quot;Gautami&quot;/&gt;&lt;a:font script=&quot;Taml&quot; typeface=&quot;Latha&quot;/&gt;&lt;a:font script=&quot;Syrc&quot; &apos;.
lv_xl_theme_10 = &apos;typeface=&quot;Estrangelo Edessa&quot;/&gt;&lt;a:font script=&quot;Orya&quot; typeface=&quot;Kalinga&quot;/&gt;&lt;a:font script=&quot;Mlym&quot; typeface=&quot;Kartika&quot;/&gt;&lt;a:font script=&quot;Laoo&quot; typeface=&quot;DokChampa&quot;/&gt;&lt;a:font script=&quot;Sinh&quot; typeface=&quot;Iskoola Pota&quot;/&gt;&lt;a:font script=&quot;Mong&quot; &apos;.
lv_xl_theme_11 = &apos;typeface=&quot;Mongolian Baiti&quot;/&gt;&lt;a:font script=&quot;Viet&quot; typeface=&quot;Times New Roman&quot;/&gt;&lt;a:font script=&quot;Uigh&quot; typeface=&quot;Microsoft Uighur&quot;/&gt;&lt;/a:majorFont&gt;&lt;a:minorFont&gt;&lt;a:latin typeface=&quot;Calibri&quot;/&gt;&lt;a:ea typeface=&quot;&quot;/&gt;&lt;a:cs typeface=&quot;&quot;/&gt;&apos;.
lv_xl_theme_12 = &apos;&lt;a:font script=&quot;Arab&quot; typeface=&quot;Arial&quot;/&gt;&lt;a:font script=&quot;Hebr&quot; &apos;.
lv_xl_theme_13 = &apos;typeface=&quot;Arial&quot;/&gt;&lt;a:font script=&quot;Thai&quot; typeface=&quot;Tahoma&quot;/&gt;&lt;a:font script=&quot;Ethi&quot; typeface=&quot;Nyala&quot;/&gt;&lt;a:font script=&quot;Beng&quot; typeface=&quot;Vrinda&quot;/&gt;&lt;a:font script=&quot;Gujr&quot; typeface=&quot;Shruti&quot;/&gt;&lt;a:font script=&quot;Khmr&quot; typeface=&quot;DaunPenh&quot;/&gt;&lt;a:font &apos;.
lv_xl_theme_14 = &apos;script=&quot;Knda&quot; typeface=&quot;Tunga&quot;/&gt;&lt;a:font script=&quot;Guru&quot; typeface=&quot;Raavi&quot;/&gt;&lt;a:font script=&quot;Cans&quot; typeface=&quot;Euphemia&quot;/&gt;&lt;a:font script=&quot;Cher&quot; typeface=&quot;Plantagenet Cherokee&quot;/&gt;&lt;a:font script=&quot;Yiii&quot; typeface=&quot;Microsoft Yi Baiti&quot;/&gt;&lt;a:font &apos;.
lv_xl_theme_15 = &apos;script=&quot;Tibt&quot; typeface=&quot;Microsoft Himalaya&quot;/&gt;&lt;a:font script=&quot;Thaa&quot; typeface=&quot;MV Boli&quot;/&gt;&lt;a:font script=&quot;Deva&quot; typeface=&quot;Mangal&quot;/&gt;&lt;a:font script=&quot;Telu&quot; typeface=&quot;Gautami&quot;/&gt;&lt;a:font script=&quot;Taml&quot; typeface=&quot;Latha&quot;/&gt;&lt;a:font script=&quot;Syrc&quot; &apos;.
lv_xl_theme_16 = &apos;typeface=&quot;Estrangelo Edessa&quot;/&gt;&lt;a:font script=&quot;Orya&quot; typeface=&quot;Kalinga&quot;/&gt;&lt;a:font script=&quot;Mlym&quot; typeface=&quot;Kartika&quot;/&gt;&lt;a:font script=&quot;Laoo&quot; typeface=&quot;DokChampa&quot;/&gt;&lt;a:font script=&quot;Sinh&quot; typeface=&quot;Iskoola Pota&quot;/&gt;&lt;a:font script=&quot;Mong&quot; &apos;.
lv_xl_theme_17 = &apos;typeface=&quot;Mongolian Baiti&quot;/&gt;&lt;a:font script=&quot;Viet&quot; typeface=&quot;Arial&quot;/&gt;&lt;a:font script=&quot;Uigh&quot; typeface=&quot;Microsoft Uighur&quot;/&gt;&lt;/a:minorFont&gt;&lt;/a:fontScheme&gt;&lt;a:fmtScheme name=&quot;Office&quot;&gt;&lt;a:fillStyleLst&gt;&lt;a:solidFill&gt;&lt;a:schemeClr val=&quot;phClr&quot;/&gt;&apos;.
lv_xl_theme_18 = &apos;&lt;/a:solidFill&gt;&lt;a:gradFill rotWithShape=&quot;1&quot;&gt;&lt;a:gsLst&gt;&lt;a:gs pos=&quot;0&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:tint val=&quot;50000&quot;/&gt;&lt;a:satMod val=&quot;300000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs pos=&quot;35000&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:tint val=&quot;37000&quot;/&gt;&lt;a:satMod &apos;.
lv_xl_theme_19 = &apos;val=&quot;300000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs pos=&quot;100000&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:tint val=&quot;15000&quot;/&gt;&lt;a:satMod val=&quot;350000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;/a:gsLst&gt;&lt;a:lin ang=&quot;16200000&quot; scaled=&quot;1&quot;/&gt;&lt;/a:gradFill&gt;&lt;a:gradFill rotWithShape=&quot;1&quot;&gt;&apos;.
lv_xl_theme_20 = &apos;&lt;a:gsLst&gt;&lt;a:gs pos=&quot;0&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:shade val=&quot;51000&quot;/&gt;&lt;a:satMod val=&quot;130000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs pos=&quot;80000&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:shade val=&quot;93000&quot;/&gt;&lt;a:satMod val=&quot;130000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs &apos;.
lv_xl_theme_21 = &apos;pos=&quot;100000&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:shade val=&quot;94000&quot;/&gt;&lt;a:satMod val=&quot;135000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;/a:gsLst&gt;&lt;a:lin ang=&quot;16200000&quot; scaled=&quot;0&quot;/&gt;&lt;/a:gradFill&gt;&lt;/a:fillStyleLst&gt;&lt;a:lnStyleLst&gt;&lt;a:ln w=&quot;9525&quot; cap=&quot;flat&quot; cmpd=&quot;sng&quot; &apos;.
lv_xl_theme_22 = &apos;algn=&quot;ctr&quot;&gt;&lt;a:solidFill&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:shade val=&quot;95000&quot;/&gt;&lt;a:satMod val=&quot;105000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:solidFill&gt;&lt;a:prstDash val=&quot;solid&quot;/&gt;&lt;/a:ln&gt;&lt;a:ln w=&quot;25400&quot; cap=&quot;flat&quot; cmpd=&quot;sng&quot; algn=&quot;ctr&quot;&gt;&lt;a:solidFill&gt;&lt;a:schemeClr &apos;.
lv_xl_theme_23 = &apos;val=&quot;phClr&quot;/&gt;&lt;/a:solidFill&gt;&lt;a:prstDash val=&quot;solid&quot;/&gt;&lt;/a:ln&gt;&lt;a:ln w=&quot;38100&quot; cap=&quot;flat&quot; cmpd=&quot;sng&quot; algn=&quot;ctr&quot;&gt;&lt;a:solidFill&gt;&lt;a:schemeClr val=&quot;phClr&quot;/&gt;&lt;/a:solidFill&gt;&lt;a:prstDash val=&quot;solid&quot;/&gt;&lt;/a:ln&gt;&lt;/a:lnStyleLst&gt;&lt;a:effectStyleLst&gt;&apos;.
lv_xl_theme_24 = &apos;&lt;a:effectStyle&gt;&lt;a:effectLst&gt;&lt;a:outerShdw blurRad=&quot;40000&quot; dist=&quot;20000&quot; dir=&quot;5400000&quot; rotWithShape=&quot;0&quot;&gt;&lt;a:srgbClr val=&quot;000000&quot;&gt;&lt;a:alpha val=&quot;38000&quot;/&gt;&lt;/a:srgbClr&gt;&lt;/a:outerShdw&gt;&lt;/a:effectLst&gt;&lt;/a:effectStyle&gt;&lt;a:effectStyle&gt;&lt;a:effectLst&gt;&apos;.
lv_xl_theme_25 = &apos;&lt;a:outerShdw blurRad=&quot;40000&quot; dist=&quot;23000&quot; dir=&quot;5400000&quot; rotWithShape=&quot;0&quot;&gt;&lt;a:srgbClr val=&quot;000000&quot;&gt;&lt;a:alpha val=&quot;35000&quot;/&gt;&lt;/a:srgbClr&gt;&lt;/a:outerShdw&gt;&lt;/a:effectLst&gt;&lt;/a:effectStyle&gt;&lt;a:effectStyle&gt;&lt;a:effectLst&gt;&lt;a:outerShdw blurRad=&quot;40000&quot; &apos;.
lv_xl_theme_26 = &apos;dist=&quot;23000&quot; dir=&quot;5400000&quot; rotWithShape=&quot;0&quot;&gt;&lt;a:srgbClr val=&quot;000000&quot;&gt;&lt;a:alpha val=&quot;35000&quot;/&gt;&lt;/a:srgbClr&gt;&lt;/a:outerShdw&gt;&lt;/a:effectLst&gt;&lt;a:scene3d&gt;&lt;a:camera prst=&quot;orthographicFront&quot;&gt;&lt;a:rot lat=&quot;0&quot; lon=&quot;0&quot; rev=&quot;0&quot;/&gt;&lt;/a:camera&gt;&lt;a:lightRig &apos;.
lv_xl_theme_27 = &apos;rig=&quot;threePt&quot; dir=&quot;t&quot;&gt;&lt;a:rot lat=&quot;0&quot; lon=&quot;0&quot; rev=&quot;1200000&quot;/&gt;&lt;/a:lightRig&gt;&lt;/a:scene3d&gt;&lt;a:sp3d&gt;&lt;a:bevelT w=&quot;63500&quot; h=&quot;25400&quot;/&gt;&lt;/a:sp3d&gt;&lt;/a:effectStyle&gt;&lt;/a:effectStyleLst&gt;&lt;a:bgFillStyleLst&gt;&lt;a:solidFill&gt;&lt;a:schemeClr val=&quot;phClr&quot;/&gt;&apos;.
lv_xl_theme_28 = &apos;&lt;/a:solidFill&gt;&lt;a:gradFill rotWithShape=&quot;1&quot;&gt;&lt;a:gsLst&gt;&lt;a:gs pos=&quot;0&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:tint val=&quot;40000&quot;/&gt;&lt;a:satMod val=&quot;350000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs pos=&quot;40000&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:tint val=&quot;45000&quot;/&gt;&lt;a:shade &apos;.
lv_xl_theme_29 = &apos;val=&quot;99000&quot;/&gt;&lt;a:satMod val=&quot;350000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs pos=&quot;100000&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:shade val=&quot;20000&quot;/&gt;&lt;a:satMod val=&quot;255000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;/a:gsLst&gt;&lt;a:path path=&quot;circle&quot;&gt;&lt;a:fillToRect l=&quot;50000&quot; &apos;.
lv_xl_theme_30 = &apos;t=&quot;-80000&quot; r=&quot;50000&quot; b=&quot;180000&quot;/&gt;&lt;/a:path&gt;&lt;/a:gradFill&gt;&lt;a:gradFill rotWithShape=&quot;1&quot;&gt;&lt;a:gsLst&gt;&lt;a:gs pos=&quot;0&quot;&gt;&lt;a:schemeClr val=&quot;phClr&quot;&gt;&lt;a:tint val=&quot;80000&quot;/&gt;&lt;a:satMod val=&quot;300000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;a:gs pos=&quot;100000&quot;&gt;&lt;a:schemeClr &apos;.
lv_xl_theme_31 = &apos;val=&quot;phClr&quot;&gt;&lt;a:shade val=&quot;30000&quot;/&gt;&lt;a:satMod val=&quot;200000&quot;/&gt;&lt;/a:schemeClr&gt;&lt;/a:gs&gt;&lt;/a:gsLst&gt;&lt;a:path path=&quot;circle&quot;&gt;&lt;a:fillToRect l=&quot;50000&quot; t=&quot;50000&quot; r=&quot;50000&quot; b=&quot;50000&quot;/&gt;&lt;/a:path&gt;&lt;/a:gradFill&gt;&lt;/a:bgFillStyleLst&gt;&lt;/a:fmtScheme&gt;&apos;.
lv_xl_theme_32 = &apos;&lt;/a:themeElements&gt;&lt;a:objectDefaults/&gt;&lt;a:extraClrSchemeLst/&gt;&lt;/a:theme&gt;&apos;.
CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15
lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30
lv_xl_theme_31 lv_xl_theme_32
INTO lv_xl_theme SEPARATED BY space.
CALL FUNCTION &apos;SCMS_STRING_TO_XSTRING&apos;
EXPORTING
text = lv_xl_theme
IMPORTING
buffer = ep_content.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_WORKBOOK" VERSION="1" LANGU="E" DESCRIPT="Create &apos;xl/workbook.xml&apos;" EXPOSURE="1" STATE="1" EDITORDER="16 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110601" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="CREATE_XL_WORKBOOK" SCONAME="EP_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>method CREATE_XL_WORKBOOK.
** Constant node name
DATA: lc_xml_node_workbook TYPE string VALUE &apos;workbook&apos;,
lc_xml_node_fileversion TYPE string VALUE &apos;fileVersion&apos;,
lc_xml_node_workbookpr TYPE string VALUE &apos;workbookPr&apos;,
lc_xml_node_bookviews TYPE string VALUE &apos;bookViews&apos;,
lc_xml_node_workbookview TYPE string VALUE &apos;workbookView&apos;,
lc_xml_node_sheets TYPE string VALUE &apos;sheets&apos;,
lc_xml_node_sheet TYPE string VALUE &apos;sheet&apos;,
lc_xml_node_calcpr TYPE string VALUE &apos;calcPr&apos;,
lc_xml_node_workbookprotection TYPE string VALUE &apos;workbookProtection&apos;,
lc_xml_node_definednames TYPE string VALUE &apos;definedNames&apos;,
lc_xml_node_definedname TYPE string VALUE &apos;definedName&apos;,
&quot; Node attributes
lc_xml_attr_appname TYPE string VALUE &apos;appName&apos;,
lc_xml_attr_lastedited TYPE string VALUE &apos;lastEdited&apos;,
lc_xml_attr_lowestedited TYPE string VALUE &apos;lowestEdited&apos;,
lc_xml_attr_rupbuild TYPE string VALUE &apos;rupBuild&apos;,
lc_xml_attr_themeversion TYPE string VALUE &apos;defaultThemeVersion&apos;,
lc_xml_attr_xwindow TYPE string VALUE &apos;xWindow&apos;,
lc_xml_attr_ywindow TYPE string VALUE &apos;yWindow&apos;,
lc_xml_attr_windowwidth TYPE string VALUE &apos;windowWidth&apos;,
lc_xml_attr_windowheight TYPE string VALUE &apos;windowHeight&apos;,
lc_xml_attr_activetab TYPE string VALUE &apos;activeTab&apos;,
lc_xml_attr_name TYPE string VALUE &apos;name&apos;,
lc_xml_attr_sheetid TYPE string VALUE &apos;sheetId&apos;,
lc_xml_attr_state TYPE string VALUE &apos;state&apos;,
lc_xml_attr_id TYPE string VALUE &apos;id&apos;,
lc_xml_attr_calcid TYPE string VALUE &apos;calcId&apos;,
lc_xml_attr_lockrevision TYPE string VALUE &apos;lockRevision&apos;,
lc_xml_attr_lockstructure TYPE string VALUE &apos;lockStructure&apos;,
lc_xml_attr_lockwindows TYPE string VALUE &apos;lockWindows&apos;,
lc_xml_attr_revisionspassword TYPE string VALUE &apos;revisionsPassword&apos;,
lc_xml_attr_workbookpassword TYPE string VALUE &apos;workbookPassword&apos;,
&quot; Node namespace
lc_r_ns TYPE string VALUE &apos;r&apos;,
lc_xml_node_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/spreadsheetml/2006/main&apos;,
lc_xml_node_r_ns TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships&apos;,
&quot; Node id
lc_xml_node_ridx_id TYPE string VALUE &apos;rId#&apos;.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
lo_element_root TYPE REF TO if_ixml_element,
lo_element TYPE REF TO if_ixml_element,
lo_sub_element TYPE REF TO if_ixml_element,
lo_encoding TYPE REF TO if_ixml_encoding,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_ostream TYPE REF TO if_ixml_ostream,
lo_renderer TYPE REF TO if_ixml_renderer,
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_range TYPE REF TO zcl_excel_range.
DATA: lv_xml_node_ridx_id TYPE string,
lv_value TYPE string,
lv_syindex TYPE string,
lv_active_sheet TYPE zexcel_active_worksheet.
**********************************************************************
* STEP 1: Create [Content_Types].xml into the root of the ZIP
lo_ixml = cl_ixml=&gt;create( ).
**********************************************************************
* STEP 2: Set document attributes
lo_encoding = lo_ixml-&gt;create_encoding( byte_order = if_ixml_encoding=&gt;co_platform_endian
character_set = &apos;utf-8&apos; ).
lo_document = lo_ixml-&gt;create_document( ).
lo_document-&gt;set_encoding( lo_encoding ).
lo_document-&gt;set_standalone( abap_true ).
**********************************************************************
* STEP 3: Create main node
lo_element_root = lo_document-&gt;create_simple_element( name = lc_xml_node_workbook
parent = lo_document ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns&apos;
value = lc_xml_node_ns ).
lo_element_root-&gt;set_attribute_ns( name = &apos;xmlns:r&apos;
value = lc_xml_node_r_ns ).
**********************************************************************
* STEP 4: Create subnode
&quot; fileVersion node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_fileversion
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_appname
value = &apos;xl&apos; ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_lastedited
value = &apos;4&apos; ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_lowestedited
value = &apos;4&apos; ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_rupbuild
value = &apos;4506&apos; ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; fileVersion node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_workbookpr
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_themeversion
value = &apos;124226&apos; ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot; workbookProtection node
IF me-&gt;excel-&gt;zif_excel_book_protection~protected EQ abap_true.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_workbookprotection
parent = lo_document ).
MOVE me-&gt;excel-&gt;zif_excel_book_protection~workbookpassword TO lv_value.
IF lv_value IS NOT INITIAL.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_workbookpassword
value = lv_value ).
ENDIF.
MOVE me-&gt;excel-&gt;zif_excel_book_protection~revisionspassword TO lv_value.
IF lv_value IS NOT INITIAL.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_revisionspassword
value = lv_value ).
ENDIF.
MOVE me-&gt;excel-&gt;zif_excel_book_protection~lockrevision TO lv_value.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_lockrevision
value = lv_value ).
MOVE me-&gt;excel-&gt;zif_excel_book_protection~lockstructure TO lv_value.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_lockstructure
value = lv_value ).
MOVE me-&gt;excel-&gt;zif_excel_book_protection~lockwindows TO lv_value.
CONDENSE lv_value NO-GAPS.
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_lockwindows
value = lv_value ).
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
&quot; bookviews node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_bookviews
parent = lo_document ).
&quot; bookview node
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_workbookview
parent = lo_document ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_xwindow
value = &apos;120&apos; ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_ywindow
value = &apos;120&apos; ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_windowwidth
value = &apos;19035&apos; ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_windowheight
value = &apos;8445&apos; ).
&quot; Set Active Sheet
lv_active_sheet = excel-&gt;get_active_sheet_index( ).
IF lv_active_sheet &gt; 1.
lv_active_sheet = lv_active_sheet - 1.
lv_value = lv_active_sheet.
CONDENSE lv_value.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_activetab
value = lv_value ).
ENDIF.
lo_element-&gt;append_child( new_child = lo_sub_element ).&quot; bookview node
lo_element_root-&gt;append_child( new_child = lo_element ).&quot; bookviews node
&quot; sheets node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_sheets
parent = lo_document ).
lo_iterator = excel-&gt;get_worksheets_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
&quot; sheet node
lo_sub_element = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_sheet
parent = lo_document ).
lo_worksheet ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_value = lo_worksheet-&gt;get_title( ).
lv_syindex = sy-index.
SHIFT lv_syindex RIGHT DELETING TRAILING space.
SHIFT lv_syindex LEFT DELETING LEADING space.
lv_xml_node_ridx_id = lc_xml_node_ridx_id.
REPLACE ALL OCCURRENCES OF &apos;#&apos; IN lv_xml_node_ridx_id WITH lv_syindex.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_name
value = lv_value ).
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_sheetid
value = lv_syindex ).
IF lo_worksheet-&gt;zif_excel_sheet_properties~hidden EQ abap_true.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_state
value = &apos;hidden&apos; ).
ENDIF.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_id
prefix = lc_r_ns
value = lv_xml_node_ridx_id ).
lo_element-&gt;append_child( new_child = lo_sub_element ). &quot; sheet node
ENDWHILE.
lo_element_root-&gt;append_child( new_child = lo_element ).&quot; sheets node
&quot; ranges node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_definednames
parent = lo_document ).
lo_iterator = excel-&gt;get_ranges_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
&quot; range node
lo_sub_element = lo_document-&gt;create_simple_element_ns( name = lc_xml_node_definedname
parent = lo_document ).
lo_range ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
lv_value = lo_range-&gt;name.
lo_sub_element-&gt;set_attribute_ns( name = lc_xml_attr_name
value = lv_value ).
lv_value = lo_range-&gt;get_value( ).
lo_sub_element-&gt;set_value( value = lv_value ).
lo_element-&gt;append_child( new_child = lo_sub_element ). &quot; range node
ENDWHILE.
lo_element_root-&gt;append_child( new_child = lo_element ).&quot; ranges node
&quot; calcPr node
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_calcpr
parent = lo_document ).
lo_element-&gt;set_attribute_ns( name = lc_xml_attr_calcid
value = &apos;125725&apos; ).
lo_element_root-&gt;append_child( new_child = lo_element ).
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_ostream = lo_streamfactory-&gt;create_ostream_xstring( string = ep_content ).
lo_renderer = lo_ixml-&gt;create_renderer( ostream = lo_ostream document = lo_document ).
lo_renderer-&gt;render( ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="FLAG2BOOL" VERSION="1" LANGU="E" DESCRIPT="Convert a FLAG to BOOLEAN value" EXPOSURE="0" STATE="1" EDITORDER="17 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="FLAG2BOOL" SCONAME="IP_FLAG" VERSION="1" LANGU="E" DESCRIPT="General Flag" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="FLAG"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="FLAG2BOOL" SCONAME="EP_BOOLEAN" VERSION="1" LANGU="E" DESCRIPT="Boolean value" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="CHAR5"/>
<source>method FLAG2BOOL.
IF ip_flag EQ abap_true.
ep_boolean = &apos;true&apos;.
ELSE.
ep_boolean = &apos;false&apos;.
ENDIF.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="GET_SHARED_STRING_INDEX" VERSION="1" LANGU="E" DESCRIPT="Get shared string index" EXPOSURE="0" STATE="1" EDITORDER="18 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="GET_SHARED_STRING_INDEX" SCONAME="IP_CELL_VALUE" VERSION="1" LANGU="E" DESCRIPT="Cell Value" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_CELL_VALUE"/>
<parameter CLSNAME="ZCL_EXCEL_WRITER_2007" CMPNAME="GET_SHARED_STRING_INDEX" SCONAME="EP_INDEX" VERSION="1" LANGU="E" DESCRIPT="Natural Number" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="INT4"/>
<source>method GET_SHARED_STRING_INDEX.
DATA ls_shared_string TYPE zexcel_s_shared_string.
READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value BINARY SEARCH.
ep_index = ls_shared_string-string_no.
endmethod.</source>
</method>
</CLAS>