abap2xlsx/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk
Łukasz Pęgiel fb1ae88d92 THEMES +
2016-03-31 20:13:25 +02:00

3991 lines
213 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<CLAS CLSNAME="ZCL_EXCEL_READER_2007" VERSION="1" LANGU="E" DESCRIPT="Read Excel 2007 into ZCL_EXCEL" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" CLSCCINCL="X" FIXPT="X" UNICODE="X" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 ">
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_RELATIONSHIP" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="1 " TYPTYPE="4" SRCROW1="4 " SRCCOLUMN1="4 " SRCROW2="11 " SRCCOLUMN2="24 " TYPESRC_LENG="319 " TYPESRC='BEGIN OF t_relationship,
id TYPE string,
type TYPE string,
target TYPE string,
targetmode TYPE string,
worksheet TYPE REF TO zcl_excel_worksheet,
sheetid TYPE string, &quot;ins #235 - repeat rows/cols - needed to identify correct sheet
END OF t_relationship
'/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_FILEVERSION" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="2 " TYPTYPE="4" SRCROW1="13 " SRCCOLUMN1="4 " SRCROW2="19 " SRCCOLUMN2="23 " TYPESRC_LENG="209 " TYPESRC="BEGIN OF t_fileversion,
appname TYPE string,
lastedited TYPE string,
lowestedited TYPE string,
rupbuild TYPE string,
codename TYPE string,
END OF t_fileversion
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_SHEET" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="3 " TYPTYPE="4" SRCROW1="21 " SRCCOLUMN1="4 " SRCROW2="26 " SRCCOLUMN2="17 " TYPESRC_LENG="145 " TYPESRC="BEGIN OF t_sheet,
name TYPE string,
sheetid TYPE string,
id TYPE string,
state TYPE string,
END OF t_sheet
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_WORKBOOKPR" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="4 " TYPTYPE="4" SRCROW1="28 " SRCCOLUMN1="4 " SRCROW2="31 " SRCCOLUMN2="22 " TYPESRC_LENG="125 " TYPESRC="BEGIN OF t_workbookpr,
codename TYPE string,
defaultthemeversion TYPE string,
END OF t_workbookpr
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_SHEETPR" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="5 " TYPTYPE="4" SRCROW1="33 " SRCCOLUMN1="4 " SRCROW2="35 " SRCCOLUMN2="19 " TYPESRC_LENG="69 " TYPESRC="BEGIN OF t_sheetpr,
codename TYPE string,
END OF t_sheetpr
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_RANGE" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="6 " TYPTYPE="4" SRCROW1="37 " SRCCOLUMN1="4 " SRCROW2="41 " SRCCOLUMN2="17 " TYPESRC_LENG="223 " TYPESRC="BEGIN OF t_range,
name TYPE string,
hidden TYPE string, &quot;inserted with issue #235 because Autofilters didn&apos;t passthrough
localsheetid TYPE string, &quot; issue #163
END OF t_range
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_FILLS" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="7 " TYPTYPE="4" SRCROW1="43 " SRCCOLUMN1="4 " SRCROW2="43 " SRCCOLUMN2="91 " TYPESRC_LENG="89 " TYPESRC="t_fills TYPE STANDARD TABLE OF REF TO zcl_excel_style_fill WITH NON-UNIQUE DEFAULT KEY
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_BORDERS" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="8 " TYPTYPE="4" SRCROW1="45 " SRCCOLUMN1="4 " SRCROW2="45 " SRCCOLUMN2="94 " TYPESRC_LENG="92 " TYPESRC="t_borders TYPE STANDARD TABLE OF REF TO zcl_excel_style_borders WITH NON-UNIQUE DEFAULT KEY
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_FONTS" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="9 " TYPTYPE="4" SRCROW1="47 " SRCCOLUMN1="4 " SRCROW2="47 " SRCCOLUMN2="91 " TYPESRC_LENG="89 " TYPESRC="t_fonts TYPE STANDARD TABLE OF REF TO zcl_excel_style_font WITH NON-UNIQUE DEFAULT KEY
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_STYLE_REFS" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="10 " TYPTYPE="4" SRCROW1="49 " SRCCOLUMN1="4 " SRCROW2="49 " SRCCOLUMN2="89 " TYPESRC_LENG="87 " TYPESRC="t_style_refs TYPE STANDARD TABLE OF REF TO zcl_excel_style WITH NON-UNIQUE DEFAULT KEY
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_COLOR" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="11 " TYPTYPE="4" SRCROW1="51 " SRCCOLUMN1="4 " SRCROW2="56 " SRCCOLUMN2="17 " TYPESRC_LENG="145 " TYPESRC="BEGIN OF t_color,
indexed TYPE string,
rgb TYPE string,
theme TYPE string,
tint TYPE string,
END OF t_color
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_REL_DRAWING" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="12 " TYPTYPE="4" SRCROW1="58 " SRCCOLUMN1="4 " SRCROW2="63 " SRCCOLUMN2="23 " TYPESRC_LENG="191 " TYPESRC="BEGIN OF t_rel_drawing,
id TYPE string,
content TYPE xstring,
file_ext TYPE string,
content_xml TYPE REF TO if_ixml_document,
END OF t_rel_drawing
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="T_REL_DRAWINGS" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="13 " TYPTYPE="4" SRCROW1="65 " SRCCOLUMN1="4 " SRCROW2="65 " SRCCOLUMN2="82 " TYPESRC_LENG="80 " TYPESRC="t_rel_drawings TYPE STANDARD TABLE OF t_rel_drawing WITH NON-UNIQUE DEFAULT KEY
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GTS_EXTERNAL_HYPERLINK" VERSION="1" LANGU="E" DESCRIPT="External hyperlink" EXPOSURE="1" STATE="1" EDITORDER="14 " TYPTYPE="4" SRCROW1="67 " SRCCOLUMN1="4 " SRCROW2="70 " SRCCOLUMN2="32 " TYPESRC_LENG="119 " TYPESRC="BEGIN OF gts_external_hyperlink,
id TYPE string,
target TYPE string,
END OF gts_external_hyperlink
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GTT_EXTERNAL_HYPERLINKS" VERSION="1" LANGU="E" DESCRIPT="Table with external hyperlinks" EXPOSURE="1" STATE="1" EDITORDER="15 " TYPTYPE="4" SRCROW1="72 " SRCCOLUMN1="4 " SRCROW2="72 " SRCCOLUMN2="89 " TYPESRC_LENG="87 " TYPESRC="gtt_external_hyperlinks TYPE HASHED TABLE OF gts_external_hyperlink WITH UNIQUE KEY id
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="TY_REF_FORMULAE" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="16 " TYPTYPE="4" SRCROW1="74 " SRCCOLUMN1="4 " SRCROW2="81 " SRCCOLUMN2="27 " TYPESRC_LENG="222 " TYPESRC="BEGIN OF ty_ref_formulae,
sheet TYPE REF TO zcl_excel_worksheet,
row TYPE i,
column TYPE i,
si TYPE i,
ref TYPE string,
formula TYPE string,
END OF ty_ref_formulae
"/>
<types CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="TYT_REF_FORMULAE" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="17 " TYPTYPE="4" SRCROW1="83 " SRCCOLUMN1="4 " SRCROW2="83 " SRCCOLUMN2="89 " TYPESRC_LENG="87 " TYPESRC="tyt_ref_formulae TYPE HASHED TABLE OF ty_ref_formulae WITH UNIQUE KEY sheet row column
"/>
<implementing CLSNAME="ZCL_EXCEL_READER_2007" REFCLSNAME="ZIF_EXCEL_READER" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1" EDITORDER="0 "/>
<localImplementation>*&quot;* local class implementation for public class
*&quot;* use this source file for the implementation part of
*&quot;* local helper classes
TYPES: BEGIN OF t_relationship,
id TYPE string,
type TYPE string,
target TYPE string,
END OF t_relationship.
*
CLASS lcl_abap_zip_archive DEFINITION
INHERITING FROM lcl_zip_archive
CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS create
IMPORTING i_data TYPE xstring
RETURNING value(r_zip) TYPE REF TO lcl_zip_archive
RAISING zcx_excel.
METHODS read REDEFINITION.
PRIVATE SECTION.
DATA: abap_zip TYPE REF TO cl_abap_zip.
METHODS constructor IMPORTING i_data TYPE xstring
RAISING zcx_excel.
ENDCLASS. &quot;lcl_abap_zip_archive DEFINITION
*
CLASS lcl_alternate_zip_archive DEFINITION
INHERITING FROM lcl_zip_archive
CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS create
IMPORTING i_data TYPE xstring
i_alternate_zip_class TYPE seoclsname
RETURNING value(r_zip) TYPE REF TO lcl_zip_archive
RAISING zcx_excel.
METHODS read REDEFINITION.
PRIVATE SECTION.
DATA: alternate_zip TYPE REF TO object.
METHODS constructor
IMPORTING i_data TYPE xstring
i_alternate_zip_class TYPE seoclsname
RAISING zcx_excel.
ENDCLASS. &quot;lcl_alternate_zip_archive DEFINITION
*
CLASS lcl_abap_zip_archive IMPLEMENTATION.
METHOD create.
CREATE OBJECT r_zip TYPE lcl_abap_zip_archive
EXPORTING
i_data = i_data.
ENDMETHOD. &quot;create
METHOD constructor.
DATA: lv_errormessage TYPE string.
super-&gt;constructor( ).
CREATE OBJECT abap_zip.
abap_zip-&gt;load(
EXPORTING
zip = i_data
EXCEPTIONS
zip_parse_error = 1
OTHERS = 2 ).
IF sy-subrc &lt;&gt; 0.
lv_errormessage = &apos;ZIP parse error&apos;(002).
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDIF.
ENDMETHOD. &quot;constructor
METHOD read.
DATA: lv_errormessage TYPE string.
CALL METHOD abap_zip-&gt;get
EXPORTING
name = i_filename
IMPORTING
content = r_content
EXCEPTIONS
zip_index_error = 1
zip_decompression_error = 2
OTHERS = 3.
IF sy-subrc &lt;&gt; 0.
lv_errormessage = &apos;File not found in zip-archive&apos;(003).
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDIF.
ENDMETHOD. &quot;read
ENDCLASS. &quot;lcl_abap_zip_archive IMPLEMENTATION
*
CLASS lcl_alternate_zip_archive IMPLEMENTATION.
METHOD create.
CREATE OBJECT r_zip TYPE lcl_alternate_zip_archive
EXPORTING
i_alternate_zip_class = i_alternate_zip_class
i_data = i_data.
ENDMETHOD. &quot;create
METHOD constructor.
DATA: lv_errormessage TYPE string.
super-&gt;constructor( ).
CREATE OBJECT alternate_zip TYPE (i_alternate_zip_class).
TRY.
CALL METHOD alternate_zip-&gt;(&apos;LOAD&apos;)
EXPORTING
zip = i_data
EXCEPTIONS
zip_parse_error = 1
OTHERS = 2.
CATCH cx_sy_dyn_call_illegal_method.
lv_errormessage = &apos;Method LOAD missing in alternative zipclass&apos;. &quot;#EC NOTEXT This is a workaround until class CL_ABAP_ZIP is fixed
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDTRY.
IF sy-subrc &lt;&gt; 0.
lv_errormessage = &apos;ZIP parse error&apos;(002).
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDIF.
ENDMETHOD. &quot;constructor
METHOD read.
DATA: lv_errormessage TYPE string.
TRY.
CALL METHOD alternate_zip-&gt;(&apos;GET&apos;)
EXPORTING
name = i_filename
IMPORTING
content = r_content &quot; Contents
EXCEPTIONS
zip_index_error = 1
zip_decompression_error = 2
OTHERS = 3.
CATCH cx_sy_dyn_call_illegal_method.
lv_errormessage = &apos;Method GET missing in alternative zipclass&apos;. &quot;#EC NOTEXT This is a workaround until class CL_ABAP_ZIP is fixed
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDTRY.
IF sy-subrc &lt;&gt; 0.
lv_errormessage = &apos;File not found in zip-archive&apos;(003).
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDIF.
ENDMETHOD. &quot;read
ENDCLASS. &quot;lcl_alternate_zip_archive IMPLEMENTATION</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
*
class lcl_zip_archive definition abstract.
public section.
methods read abstract
importing i_filename type csequence
returning value(r_content) type xstring &quot; Remember copy-on-write!
raising zcx_excel.
endclass.</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<textPool>
<language SPRAS="E">
<textElement ID="I" KEY="001" ENTRY="A problem occured when reading the file" LENGTH="60 "/>
<textElement ID="I" KEY="002" ENTRY="ZIP parse error" LENGTH="60 "/>
<textElement ID="I" KEY="003" ENTRY="File not found in zip-archive" LENGTH="60 "/>
</language>
</textPool>
<typeUsage CLSNAME="ZCL_EXCEL_READER_2007" TYPEGROUP="IXML" VERSION="1" TPUTYPE="0" EXPLICIT="X"/>
<forwardDeclaration>IXML</forwardDeclaration>
<attribute CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="MT_DXF_STYLES" VERSION="1" LANGU="E" DESCRIPT="Styles mapping" EXPOSURE="1" STATE="1" EDITORDER="4 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_T_STYLES_COND_MAPPING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="MT_REF_FORMULAE" VERSION="1" LANGU="E" DESCRIPT="Referenced formulae before resolving" EXPOSURE="1" STATE="1" EDITORDER="3 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="TYT_REF_FORMULAE" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="SHARED_STRINGS" VERSION="1" LANGU="E" DESCRIPT="Table with Strings" EXPOSURE="1" STATE="1" EDITORDER="1 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRINGTAB" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="STYLES" VERSION="1" LANGU="E" EXPOSURE="1" STATE="1" EDITORDER="2 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="T_STYLE_REFS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="ZIP" VERSION="1" LANGU="E" DESCRIPT="Zip Utility" EXPOSURE="0" STATE="1" EDITORDER="1 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="LCL_ZIP_ARCHIVE" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<interfaceMethod CLSNAME="ZCL_EXCEL_READER_2007" CPDNAME="ZIF_EXCEL_READER~LOAD">
<source>METHOD zif_excel_reader~load.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Map Document Properties to ZCL_EXCEL
*--------------------------------------------------------------------*
CONSTANTS: lcv_core_properties TYPE string VALUE &apos;http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties&apos;,
lcv_office_document TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument&apos;.
DATA: lo_rels TYPE REF TO if_ixml_document,
lo_node TYPE REF TO if_ixml_element,
ls_relationship TYPE t_relationship.
*--------------------------------------------------------------------*
* §1 Create EXCEL-Object we want to return to caller
* §2 We need to read the the file &quot;\\_rels\.rels&quot; because it tells
* us where in this folder structure the data for the workbook
* is located in the xlsx zip-archive
*
* The xlsx Zip-archive has generally the following folder structure:
* &lt;root&gt; |
* |--&gt; _rels
* |--&gt; doc_Props
* |--&gt; xl |
* |--&gt; _rels
* |--&gt; theme
* |--&gt; worksheets
* §3 Extracting from this the path&amp;file where the workbook is located
* Following is an example how this file could be set up
* &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;true&quot;?&gt;
* &lt;Relationships xmlns=&quot;http://schemas.openxmlformats.org/package/2006/relationships&quot;&gt;
* &lt;Relationship Target=&quot;docProps/app.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties&quot; Id=&quot;rId3&quot;/&gt;
* &lt;Relationship Target=&quot;docProps/core.xml&quot; Type=&quot;http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties&quot; Id=&quot;rId2&quot;/&gt;
* &lt;Relationship Target=&quot;xl/workbook.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument&quot; Id=&quot;rId1&quot;/&gt;
* &lt;/Relationships&gt;
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* §1 Create EXCEL-Object we want to return to caller
*--------------------------------------------------------------------*
IF iv_zcl_excel_classname IS INITIAL.
CREATE OBJECT r_excel.
ELSE.
CREATE OBJECT r_excel TYPE (iv_zcl_excel_classname).
ENDIF.
zip = create_zip_archive( i_xlsx_binary = i_excel2007
i_use_alternate_zip = i_use_alternate_zip ).
*--------------------------------------------------------------------*
* §2 Get file in folderstructure
*--------------------------------------------------------------------*
lo_rels = get_ixml_from_zip_archive( &apos;_rels/.rels&apos; ).
*--------------------------------------------------------------------*
* §3 Cycle through the Relationship Tags and use the ones we need
*--------------------------------------------------------------------*
lo_node ?= lo_rels-&gt;find_from_name( &apos;Relationship&apos; ). &quot;#EC NOTEXT
WHILE lo_node IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node
CHANGING
cp_structure = ls_relationship ).
CASE ls_relationship-type.
WHEN lcv_office_document.
*--------------------------------------------------------------------*
* Parse workbook - main part here
*--------------------------------------------------------------------*
load_workbook( iv_workbook_full_filename = ls_relationship-target
io_excel = r_excel ).
WHEN lcv_core_properties.
&quot; 2do§1 Map Document Properties to ZCL_EXCEL
WHEN OTHERS.
ENDCASE.
lo_node ?= lo_node-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</interfaceMethod>
<interfaceMethod CLSNAME="ZCL_EXCEL_READER_2007" CPDNAME="ZIF_EXCEL_READER~LOAD_FILE">
<source>METHOD zif_excel_reader~load_file.
DATA: lv_excel_data TYPE xstring.
*--------------------------------------------------------------------*
* Read file into binary string
*--------------------------------------------------------------------*
IF i_from_applserver = abap_true.
lv_excel_data = read_from_applserver( i_filename ).
ELSE.
lv_excel_data = read_from_local_file( i_filename ).
ENDIF.
*--------------------------------------------------------------------*
* Parse Excel data into ZCL_EXCEL object from binary string
*--------------------------------------------------------------------*
r_excel = zif_excel_reader~load( i_excel2007 = lv_excel_data
i_use_alternate_zip = i_use_alternate_zip
iv_zcl_excel_classname = iv_zcl_excel_classname ).
ENDMETHOD.</source>
</interfaceMethod>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="CREATE_ZIP_ARCHIVE" VERSION="1" LANGU="E" DESCRIPT="Create the zip reference object" EXPOSURE="0" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="CREATE_ZIP_ARCHIVE" SCONAME="I_XLSX_BINARY" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="XSTRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="CREATE_ZIP_ARCHIVE" SCONAME="I_USE_ALTERNATE_ZIP" VERSION="1" LANGU="E" DESCRIPT="Object Type Name" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="SEOCLSNAME" PAROPTIONL="X"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="CREATE_ZIP_ARCHIVE" SCONAME="E_ZIP" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="3" TYPE="LCL_ZIP_ARCHIVE"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="CREATE_ZIP_ARCHIVE" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD create_zip_archive.
CASE i_use_alternate_zip.
WHEN space.
e_zip = lcl_abap_zip_archive=&gt;create( i_xlsx_binary ).
WHEN OTHERS.
e_zip = lcl_alternate_zip_archive=&gt;create( i_data = i_xlsx_binary
i_alternate_zip_class = i_use_alternate_zip ).
ENDCASE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="FILL_ROW_OUTLINES" VERSION="1" LANGU="E" DESCRIPT="Fill row outlines from collapsed and hierarchy information" EXPOSURE="1" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="FILL_ROW_OUTLINES" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="FILL_ROW_OUTLINES" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD fill_row_outlines.
TYPES: BEGIN OF lts_row_data,
row TYPE i,
outline_level TYPE i,
END OF lts_row_data,
ltt_row_data TYPE SORTED TABLE OF lts_row_data WITH UNIQUE KEY row.
DATA: lt_row_dimensions TYPE zexcel_t_worksheet_rowdimensio,
lt_row_data TYPE ltt_row_data,
ls_row_data LIKE LINE OF lt_row_data,
lt_collapse_rows TYPE HASHED TABLE OF i WITH UNIQUE KEY table_line,
lv_collapsed TYPE abap_bool,
lv_outline_level TYPE i,
lv_next_consecutive_row TYPE i,
lt_outline_rows TYPE zcl_excel_worksheet=&gt;mty_ts_outlines_row,
ls_outline_row LIKE LINE OF lt_outline_rows,
lv_row_offset TYPE i,
lv_row_collapse_flag TYPE i.
FIELD-SYMBOLS: &lt;ls_row_dimension&gt; LIKE LINE OF lt_row_dimensions,
&lt;ls_row_data&gt; LIKE LINE OF lt_row_data.
* First collect information about outlines ( outline leven and collapsed state )
lt_row_dimensions = io_worksheet-&gt;get_row_dimensions( ).
LOOP AT lt_row_dimensions ASSIGNING &lt;ls_row_dimension&gt;.
ls_row_data-row = &lt;ls_row_dimension&gt;-row.
ls_row_data-outline_level = &lt;ls_row_dimension&gt;-row_dimension-&gt;get_outline_level( ).
IF ls_row_data-outline_level IS NOT INITIAL.
INSERT ls_row_data INTO TABLE lt_row_data.
ENDIF.
lv_collapsed = &lt;ls_row_dimension&gt;-row_dimension-&gt;get_collapsed( ).
IF lv_collapsed = abap_true.
INSERT &lt;ls_row_dimension&gt;-row INTO TABLE lt_collapse_rows.
ENDIF.
ENDLOOP.
* Now parse this information - we need consecutive rows - any gap will create a new outline
DO 7 TIMES. &quot; max number of outlines allowed
lv_outline_level = sy-index.
CLEAR lv_next_consecutive_row.
CLEAR ls_outline_row.
LOOP AT lt_row_data ASSIGNING &lt;ls_row_data&gt; WHERE outline_level &gt;= lv_outline_level.
IF lv_next_consecutive_row &lt;&gt; &lt;ls_row_data&gt;-row &quot; A gap --&gt; close all open outlines
AND lv_next_consecutive_row IS NOT INITIAL. &quot; First time in loop.
INSERT ls_outline_row INTO TABLE lt_outline_rows.
CLEAR: ls_outline_row.
ENDIF.
IF ls_outline_row-row_from IS INITIAL.
ls_outline_row-row_from = &lt;ls_row_data&gt;-row.
ENDIF.
ls_outline_row-row_to = &lt;ls_row_data&gt;-row.
lv_next_consecutive_row = &lt;ls_row_data&gt;-row + 1.
ENDLOOP.
IF ls_outline_row-row_from IS NOT INITIAL.
INSERT ls_outline_row INTO TABLE lt_outline_rows.
ENDIF.
ENDDO.
* lt_outline_rows holds all outline information
* we now need to determine whether the outline is collapsed or not
LOOP AT lt_outline_rows INTO ls_outline_row.
IF io_worksheet-&gt;zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=&gt;c_below_off.
lv_row_collapse_flag = ls_outline_row-row_from - 1.
ELSE.
lv_row_collapse_flag = ls_outline_row-row_to + 1.
ENDIF.
READ TABLE lt_collapse_rows TRANSPORTING NO FIELDS WITH TABLE KEY table_line = lv_row_collapse_flag.
IF sy-subrc = 0.
ls_outline_row-collapsed = abap_true.
ENDIF.
io_worksheet-&gt;set_row_outline( iv_row_from = ls_outline_row-row_from
iv_row_to = ls_outline_row-row_to
iv_collapsed = ls_outline_row-collapsed ).
ENDLOOP.
* Finally purge outline information ( collapsed state, outline leve) from row_dimensions, since we want to keep these in the outline-table
LOOP AT lt_row_dimensions ASSIGNING &lt;ls_row_dimension&gt;.
&lt;ls_row_dimension&gt;-row_dimension-&gt;set_outline_level( 0 ).
&lt;ls_row_dimension&gt;-row_dimension-&gt;set_collapsed( abap_false ).
ENDLOOP.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="FILL_STRUCT_FROM_ATTRIBUTES" VERSION="1" LANGU="E" DESCRIPT="Fills structure fields based on XML node attributes" EXPOSURE="2" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="1" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="FILL_STRUCT_FROM_ATTRIBUTES" SCONAME="IP_ELEMENT" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="FILL_STRUCT_FROM_ATTRIBUTES" SCONAME="CP_STRUCTURE" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="2" PARPASSTYP="1" TYPTYPE="1" TYPE="ANY"/>
<source>method fill_struct_from_attributes.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-07
* - ...
* changes: renaming variables to naming conventions
* aligning code
* adding comments to explain what we are trying to achieve
*--------------------------------------------------------------------*
data: lv_name type string,
lo_attributes type ref to if_ixml_named_node_map,
lo_attribute type ref to if_ixml_attribute,
lo_iterator type ref to if_ixml_node_iterator.
field-symbols: &lt;component&gt; type any.
*--------------------------------------------------------------------*
* The values of named attributes of a tag are being read and moved into corresponding
* fields of given structure
* Behaves like move-corresonding tag to structure
* Example:
* &lt;Relationship Target=&quot;docProps/app.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties&quot; Id=&quot;rId3&quot;/&gt;
* Here the attributes are Target, Type and Id. Thus if the passed
* structure has fieldnames Id and Target these would be filled with
* &quot;rId3&quot; and &quot;docProps/app.xml&quot; respectively
*--------------------------------------------------------------------*
clear cp_structure.
lo_attributes = ip_element-&gt;get_attributes( ).
lo_iterator = lo_attributes-&gt;create_iterator( ).
lo_attribute ?= lo_iterator-&gt;get_next( ).
while lo_attribute is bound.
lv_name = lo_attribute-&gt;get_name( ).
translate lv_name to upper case.
assign component lv_name of structure cp_structure to &lt;component&gt;.
if sy-subrc = 0.
&lt;component&gt; = lo_attribute-&gt;get_value( ).
endif.
lo_attribute ?= lo_iterator-&gt;get_next( ).
endwhile.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_DXF_STYLE_GUID" VERSION="1" LANGU="E" DESCRIPT="Get guid of dxf style" EXPOSURE="1" STATE="1" EDITORDER="28 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_DXF_STYLE_GUID" SCONAME="IO_IXML_DXF" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_DXF_STYLE_GUID" SCONAME="IO_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_DXF_STYLE_GUID" SCONAME="RV_STYLE_GUID" VERSION="1" LANGU="E" DESCRIPT="Style identifier" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ZEXCEL_CELL_STYLE"/>
<source>METHOD get_dxf_style_guid.
DATA: lo_ixml_dxf_children TYPE REF TO if_ixml_node_list,
lo_ixml_iterator_dxf_children TYPE REF TO if_ixml_node_iterator,
lo_ixml_dxf_child TYPE REF TO if_ixml_element,
lv_dxf_child_type TYPE string,
lo_ixml_element TYPE REF TO if_ixml_element,
lo_ixml_element2 TYPE REF TO if_ixml_element,
lv_val TYPE string.
DATA: ls_cstyle TYPE zexcel_s_cstyle_complete,
ls_cstylex TYPE zexcel_s_cstylex_complete.
lo_ixml_dxf_children = io_ixml_dxf-&gt;get_children( ).
lo_ixml_iterator_dxf_children = lo_ixml_dxf_children-&gt;create_iterator( ).
lo_ixml_dxf_child ?= lo_ixml_iterator_dxf_children-&gt;get_next( ).
WHILE lo_ixml_dxf_child IS BOUND.
lv_dxf_child_type = lo_ixml_dxf_child-&gt;get_name( ).
CASE lv_dxf_child_type.
WHEN &apos;font&apos;.
*--------------------------------------------------------------------*
* italic
*--------------------------------------------------------------------*
lo_ixml_element = lo_ixml_dxf_child-&gt;find_from_name( &apos;i&apos; ).
IF lo_ixml_element IS BOUND.
CLEAR lv_val.
lv_val = lo_ixml_element-&gt;get_attribute_ns( &apos;val&apos; ).
IF lv_val &lt;&gt; &apos;0&apos;.
ls_cstyle-font-italic = &apos;X&apos;.
ls_cstylex-font-italic = &apos;X&apos;.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* bold
*--------------------------------------------------------------------*
lo_ixml_element = lo_ixml_dxf_child-&gt;find_from_name( &apos;b&apos; ).
IF lo_ixml_element IS BOUND.
CLEAR lv_val.
lv_val = lo_ixml_element-&gt;get_attribute_ns( &apos;val&apos; ).
IF lv_val &lt;&gt; &apos;0&apos;.
ls_cstyle-font-bold = &apos;X&apos;.
ls_cstylex-font-bold = &apos;X&apos;.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* strikethrough
*--------------------------------------------------------------------*
lo_ixml_element = lo_ixml_dxf_child-&gt;find_from_name( &apos;strike&apos; ).
IF lo_ixml_element IS BOUND.
CLEAR lv_val.
lv_val = lo_ixml_element-&gt;get_attribute_ns( &apos;val&apos; ).
IF lv_val &lt;&gt; &apos;0&apos;.
ls_cstyle-font-strikethrough = &apos;X&apos;.
ls_cstylex-font-strikethrough = &apos;X&apos;.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* color
*--------------------------------------------------------------------*
lo_ixml_element = lo_ixml_dxf_child-&gt;find_from_name( &apos;color&apos; ).
IF lo_ixml_element IS BOUND.
CLEAR lv_val.
lv_val = lo_ixml_element-&gt;get_attribute_ns( &apos;rgb&apos; ).
ls_cstyle-font-color-rgb = lv_val.
ls_cstylex-font-color-rgb = &apos;X&apos;.
ENDIF.
WHEN &apos;fill&apos;.
lo_ixml_element = lo_ixml_dxf_child-&gt;find_from_name( &apos;patternFill&apos; ).
IF lo_ixml_element IS BOUND.
lo_ixml_element2 = lo_ixml_element-&gt;find_from_name( &apos;bgColor&apos; ).
IF lo_ixml_element2 IS BOUND.
CLEAR lv_val.
lv_val = lo_ixml_element2-&gt;get_attribute_ns( &apos;rgb&apos; ).
IF lv_val IS NOT INITIAL.
ls_cstyle-fill-filltype = zcl_excel_style_fill=&gt;c_fill_solid.
ls_cstyle-fill-bgcolor-rgb = lv_val.
ls_cstylex-fill-filltype = &apos;X&apos;.
ls_cstylex-fill-bgcolor-rgb = &apos;X&apos;.
ENDIF.
ENDIF.
CLEAR lv_val.
lv_val = lo_ixml_element2-&gt;get_attribute_ns( &apos;theme&apos; ).
IF lv_val IS NOT INITIAL.
ls_cstyle-fill-filltype = zcl_excel_style_fill=&gt;c_fill_solid.
ls_cstyle-fill-bgcolor-theme = lv_val.
ls_cstylex-fill-filltype = &apos;X&apos;.
ls_cstylex-fill-bgcolor-theme = &apos;X&apos;.
ENDIF.
ENDIF.
* 2do - borders into dxf-styles. Here and in writerclass
* WHEN &apos;border&apos;.
* lo_ixml_element = lo_ixml_dxf_child-&gt;find_from_name( &apos;left&apos; ).
* IF lo_ixml_element IS BOUND.
* CLEAR lv_val.
* lv_val = lo_ixml_element2-&gt;get_attribute_ns( &apos;style&apos; ).
* IF lv_val IS NOT INITIAL.
* ls_cstyle-borders-left-border_style = lv_val.
* ls_cstylex-borders-left-border_style = &apos;X&apos;.
* ENDIF.
* ENDIF.
ENDCASE.
lo_ixml_dxf_child ?= lo_ixml_iterator_dxf_children-&gt;get_next( ).
ENDWHILE.
rv_style_guid = io_excel-&gt;get_static_cellstyle_guid( ip_cstyle_complete = ls_cstyle
ip_cstylex_complete = ls_cstylex ).
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_FROM_ZIP_ARCHIVE" VERSION="1" LANGU="E" DESCRIPT="Read file from ZIP Archive" EXPOSURE="1" STATE="1" EDITORDER="2 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_FROM_ZIP_ARCHIVE" SCONAME="I_FILENAME" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_FROM_ZIP_ARCHIVE" SCONAME="R_CONTENT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_FROM_ZIP_ARCHIVE" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD get_from_zip_archive.
ASSERT zip IS BOUND. &quot; zip object has to exist at this point
r_content = zip-&gt;read( i_filename ).
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_IXML_FROM_ZIP_ARCHIVE" VERSION="1" LANGU="E" DESCRIPT="Read file from ZIP Archive and convert to ixml document" EXPOSURE="1" STATE="1" EDITORDER="3 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_IXML_FROM_ZIP_ARCHIVE" SCONAME="I_FILENAME" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_IXML_FROM_ZIP_ARCHIVE" SCONAME="IS_NORMALIZING" VERSION="1" LANGU="E" DESCRIPT="Boolean Variable (X=True, -=False, Space=Unknown)" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="BOOLEAN" PARVALUE="&apos;X&apos;"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_IXML_FROM_ZIP_ARCHIVE" SCONAME="R_IXML" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_DOCUMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="GET_IXML_FROM_ZIP_ARCHIVE" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD get_ixml_from_zip_archive.
DATA: lv_content TYPE xstring,
lo_ixml TYPE REF TO if_ixml,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_istream TYPE REF TO if_ixml_istream,
lo_parser TYPE REF TO if_ixml_parser.
*--------------------------------------------------------------------*
* Load XML file from archive into an input stream,
* and parse that stream into an ixml object
*--------------------------------------------------------------------*
lv_content = me-&gt;get_from_zip_archive( i_filename ).
lo_ixml = cl_ixml=&gt;create( ).
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).
lo_istream = lo_streamfactory-&gt;create_istream_xstring( lv_content ).
r_ixml = lo_ixml-&gt;create_document( ).
lo_parser = lo_ixml-&gt;create_parser( stream_factory = lo_streamfactory
istream = lo_istream
document = r_ixml ).
lo_parser-&gt;set_normalizing( is_normalizing ).
lo_parser-&gt;set_validating( mode = if_ixml_parser=&gt;co_no_validation ).
lo_parser-&gt;parse( ).
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DRAWING_ANCHOR" VERSION="1" LANGU="E" DESCRIPT="Loads drawing anchor" EXPOSURE="1" STATE="1" EDITORDER="4 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DRAWING_ANCHOR" SCONAME="IO_ANCHOR_ELEMENT" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DRAWING_ANCHOR" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DRAWING_ANCHOR" SCONAME="IT_RELATED_DRAWINGS" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="T_REL_DRAWINGS"/>
<source>METHOD load_drawing_anchor.
TYPES: BEGIN OF t_c_nv_pr,
name TYPE string,
id TYPE string,
END OF t_c_nv_pr.
TYPES: BEGIN OF t_blip,
cstate TYPE string,
embed TYPE string,
END OF t_blip.
TYPES: BEGIN OF t_chart,
id TYPE string,
END OF t_chart.
TYPES: BEGIN OF t_ext,
cx TYPE string,
cy TYPE string,
END OF t_ext.
CONSTANTS: lc_xml_attr_true TYPE string VALUE &apos;true&apos;,
lc_xml_attr_true_int TYPE string VALUE &apos;1&apos;.
CONSTANTS: lc_rel_chart TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart&apos;,
lc_rel_image TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/image&apos;.
DATA: lo_drawing TYPE REF TO zcl_excel_drawing,
node TYPE REF TO if_ixml_element,
node2 TYPE REF TO if_ixml_element,
node3 TYPE REF TO if_ixml_element,
node4 TYPE REF TO if_ixml_element,
ls_upper TYPE zexcel_drawing_location,
ls_lower TYPE zexcel_drawing_location,
ls_size TYPE zexcel_drawing_size,
ext TYPE t_ext,
lv_content TYPE xstring,
lv_relation_id TYPE string,
lv_title TYPE string,
cnvpr TYPE t_c_nv_pr,
blip TYPE t_blip,
chart TYPE t_chart,
drawing_type TYPE zexcel_drawing_type,
rel_drawing TYPE t_rel_drawing.
node ?= io_anchor_element-&gt;find_from_name( name = &apos;from&apos; namespace = &apos;xdr&apos; ).
CHECK node IS NOT INITIAL.
node2 ?= node-&gt;find_from_name( name = &apos;col&apos; namespace = &apos;xdr&apos; ).
ls_upper-col = node2-&gt;get_value( ).
node2 ?= node-&gt;find_from_name( name = &apos;row&apos; namespace = &apos;xdr&apos; ).
ls_upper-row = node2-&gt;get_value( ).
node2 ?= node-&gt;find_from_name( name = &apos;colOff&apos; namespace = &apos;xdr&apos; ).
ls_upper-col_offset = node2-&gt;get_value( ).
node2 ?= node-&gt;find_from_name( name = &apos;rowOff&apos; namespace = &apos;xdr&apos; ).
ls_upper-row_offset = node2-&gt;get_value( ).
node ?= io_anchor_element-&gt;find_from_name( name = &apos;ext&apos; namespace = &apos;xdr&apos; ).
IF node IS INITIAL.
CLEAR ls_size.
ELSE.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = ext ).
ls_size-width = ext-cx.
ls_size-height = ext-cy.
TRY.
ls_size-width = zcl_excel_drawing=&gt;emu2pixel( ls_size-width ).
CATCH cx_root.
ENDTRY.
TRY.
ls_size-height = zcl_excel_drawing=&gt;emu2pixel( ls_size-height ).
CATCH cx_root.
ENDTRY.
ENDIF.
node ?= io_anchor_element-&gt;find_from_name( name = &apos;to&apos; namespace = &apos;xdr&apos; ).
IF node IS INITIAL.
CLEAR ls_lower.
ELSE.
node2 ?= node-&gt;find_from_name( name = &apos;col&apos; namespace = &apos;xdr&apos; ).
ls_lower-col = node2-&gt;get_value( ).
node2 ?= node-&gt;find_from_name( name = &apos;row&apos; namespace = &apos;xdr&apos; ).
ls_lower-row = node2-&gt;get_value( ).
node2 ?= node-&gt;find_from_name( name = &apos;colOff&apos; namespace = &apos;xdr&apos; ).
ls_lower-col_offset = node2-&gt;get_value( ).
node2 ?= node-&gt;find_from_name( name = &apos;rowOff&apos; namespace = &apos;xdr&apos; ).
ls_lower-row_offset = node2-&gt;get_value( ).
ENDIF.
node ?= io_anchor_element-&gt;find_from_name( name = &apos;pic&apos; namespace = &apos;xdr&apos; ).
IF node IS NOT INITIAL.
node2 ?= node-&gt;find_from_name( name = &apos;nvPicPr&apos; namespace = &apos;xdr&apos; ).
CHECK node2 IS NOT INITIAL.
node3 ?= node2-&gt;find_from_name( name = &apos;cNvPr&apos; namespace = &apos;xdr&apos; ).
CHECK node3 IS NOT INITIAL.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = cnvpr ).
lv_title = cnvpr-name.
node2 ?= node-&gt;find_from_name( name = &apos;blipFill&apos; namespace = &apos;xdr&apos; ).
CHECK node2 IS NOT INITIAL.
node3 ?= node2-&gt;find_from_name( name = &apos;blip&apos; namespace = &apos;a&apos; ).
CHECK node3 IS NOT INITIAL.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = blip ).
lv_relation_id = blip-embed.
drawing_type = zcl_excel_drawing=&gt;type_image.
ENDIF.
node ?= io_anchor_element-&gt;find_from_name( name = &apos;graphicFrame&apos; namespace = &apos;xdr&apos; ).
IF node IS NOT INITIAL.
node2 ?= node-&gt;find_from_name( name = &apos;nvGraphicFramePr&apos; namespace = &apos;xdr&apos; ).
CHECK node2 IS NOT INITIAL.
node3 ?= node2-&gt;find_from_name( name = &apos;cNvPr&apos; namespace = &apos;xdr&apos; ).
CHECK node3 IS NOT INITIAL.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = cnvpr ).
lv_title = cnvpr-name.
node2 ?= node-&gt;find_from_name( name = &apos;graphic&apos; namespace = &apos;a&apos; ).
CHECK node2 IS NOT INITIAL.
node3 ?= node2-&gt;find_from_name( name = &apos;graphicData&apos; namespace = &apos;a&apos; ).
CHECK node3 IS NOT INITIAL.
node4 ?= node2-&gt;find_from_name( name = &apos;chart&apos; namespace = &apos;c&apos; ).
CHECK node4 IS NOT INITIAL.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = node4 CHANGING cp_structure = chart ).
lv_relation_id = chart-id.
drawing_type = zcl_excel_drawing=&gt;type_chart.
ENDIF.
lo_drawing = io_worksheet-&gt;excel-&gt;add_new_drawing(
ip_type = drawing_type
ip_title = lv_title ).
io_worksheet-&gt;add_drawing( lo_drawing ).
lo_drawing-&gt;set_position2(
EXPORTING
ip_from = ls_upper
ip_to = ls_lower ).
READ TABLE it_related_drawings INTO rel_drawing
WITH KEY id = lv_relation_id.
lo_drawing-&gt;set_media(
EXPORTING
ip_media = rel_drawing-content
ip_media_type = rel_drawing-file_ext
ip_width = ls_size-width
ip_height = ls_size-height ).
IF drawing_type = zcl_excel_drawing=&gt;type_chart.
&quot;-------------Added by Alessandro Iannacci - Should load chart attributes
lo_drawing-&gt;load_chart_attributes( rel_drawing-content_xml ).
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DXF_STYLES" VERSION="1" LANGU="E" DESCRIPT="Loads dxf styles" EXPOSURE="1" STATE="1" EDITORDER="7 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DXF_STYLES" SCONAME="IV_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DXF_STYLES" SCONAME="IO_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_DXF_STYLES" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_dxf_styles.
DATA: lo_styles_xml TYPE REF TO if_ixml_document,
lo_node_dxfs TYPE REF TO if_ixml_element,
lo_nodes_dxf TYPE REF TO if_ixml_node_collection,
lo_iterator_dxf TYPE REF TO if_ixml_node_iterator,
lo_node_dxf TYPE REF TO if_ixml_element,
lv_dxf_count TYPE i.
FIELD-SYMBOLS: &lt;ls_dxf_style&gt; LIKE LINE OF mt_dxf_styles.
*--------------------------------------------------------------------*
* Look for dxfs-node
*--------------------------------------------------------------------*
lo_styles_xml = me-&gt;get_ixml_from_zip_archive( iv_path ).
lo_node_dxfs = lo_styles_xml-&gt;find_from_name( &apos;dxfs&apos; ).
CHECK lo_node_dxfs IS BOUND.
*--------------------------------------------------------------------*
* loop through all dxf-nodes and create style for each
*--------------------------------------------------------------------*
lo_nodes_dxf ?= lo_node_dxfs-&gt;get_elements_by_tag_name( &apos;dxf&apos; ).
lo_iterator_dxf = lo_nodes_dxf-&gt;create_iterator( ).
lo_node_dxf ?= lo_iterator_dxf-&gt;get_next( ).
WHILE lo_node_dxf IS BOUND.
APPEND INITIAL LINE TO mt_dxf_styles ASSIGNING &lt;ls_dxf_style&gt;.
&lt;ls_dxf_style&gt;-dxf = lv_dxf_count. &quot; We start counting at 0
ADD 1 TO lv_dxf_count. &quot; prepare next entry
&lt;ls_dxf_style&gt;-guid = get_dxf_style_guid( io_ixml_dxf = lo_node_dxf
io_excel = io_excel ).
lo_node_dxf ?= lo_iterator_dxf-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_SHARED_STRINGS" VERSION="1" LANGU="E" DESCRIPT="Loads shared strings table" EXPOSURE="1" STATE="1" EDITORDER="5 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_SHARED_STRINGS" SCONAME="IP_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_SHARED_STRINGS" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>method LOAD_SHARED_STRINGS.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Support partial formatting of strings in cells
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-11
* - ...
* changes: renaming variables to naming conventions
* renaming variables to indicate what they are used for
* aligning code
* adding comments to explain what we are trying to achieve
* rewriting code for better readibility
*--------------------------------------------------------------------*
DATA:
lo_shared_strings_xml TYPE REF TO if_ixml_document,
lo_node_si TYPE REF TO if_ixml_element,
lo_node_si_child TYPE REF TO if_ixml_element,
lo_node_r_child_t TYPE REF TO if_ixml_element,
lv_tag_name TYPE string,
lv_node_value TYPE string.
FIELD-SYMBOLS: &lt;lv_shared_string&gt; LIKE LINE OF me-&gt;shared_strings.
*--------------------------------------------------------------------*
* §1 Parse shared strings file and get into internal table
* So far I have encountered 2 ways how a string can be represented in the shared strings file
* §1.1 - &quot;simple&quot; strings
* §1.2 - rich text formatted strings
* Following is an example how this file could be set up; 2 strings in simple formatting, 3rd string rich textformatted
* &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;true&quot;?&gt;
* &lt;sst uniqueCount=&quot;6&quot; count=&quot;6&quot; xmlns=&quot;http://schemas.openxmlformats.org/spreadsheetml/2006/main&quot;&gt;
* &lt;si&gt;
* &lt;t&gt;This is a teststring 1&lt;/t&gt;
* &lt;/si&gt;
* &lt;si&gt;
* &lt;t&gt;This is a teststring 2&lt;/t&gt;
* &lt;/si&gt;
* &lt;si&gt;
* &lt;r&gt;
* &lt;t&gt;T&lt;/t&gt;
* &lt;/r&gt;
* &lt;r&gt;
* &lt;rPr&gt;
* &lt;sz val=&quot;11&quot;/&gt;
* &lt;color rgb=&quot;FFFF0000&quot;/&gt;
* &lt;rFont val=&quot;Calibri&quot;/&gt;
* &lt;family val=&quot;2&quot;/&gt;
* &lt;scheme val=&quot;minor&quot;/&gt;
* &lt;/rPr&gt;
* &lt;t xml:space=&quot;preserve&quot;&gt;his is a &lt;/t&gt;
* &lt;/r&gt;
* &lt;r&gt;
* &lt;rPr&gt;
* &lt;sz val=&quot;11&quot;/&gt;
* &lt;color theme=&quot;1&quot;/&gt;
* &lt;rFont val=&quot;Calibri&quot;/&gt;
* &lt;family val=&quot;2&quot;/&gt;
* &lt;scheme val=&quot;minor&quot;/&gt;
* &lt;/rPr&gt;
* &lt;t&gt;teststring 3&lt;/t&gt;
* &lt;/r&gt;
* &lt;/si&gt;
* &lt;/sst&gt;
*--------------------------------------------------------------------*
lo_shared_strings_xml = me-&gt;get_ixml_from_zip_archive( i_filename = ip_path
is_normalizing = space ). &quot; NO!!! normalizing - otherwise leading blanks will be omitted and that is not really desired for the stringtable
lo_node_si ?= lo_shared_strings_xml-&gt;find_from_name( &apos;si&apos; ).
WHILE lo_node_si IS BOUND.
APPEND INITIAL LINE TO me-&gt;shared_strings ASSIGNING &lt;lv_shared_string&gt;. &quot; Each &lt;si&gt;-entry in the xml-file must lead to an entry in our stringtable
lo_node_si_child ?= lo_node_si-&gt;get_first_child( ).
IF lo_node_si_child IS BOUND.
lv_tag_name = lo_node_si_child-&gt;get_name( ).
IF lv_tag_name = &apos;t&apos;.
*--------------------------------------------------------------------*
* §1.1 - &quot;simple&quot; strings
* Example: see above
*--------------------------------------------------------------------*
&lt;lv_shared_string&gt; = lo_node_si_child-&gt;get_value( ).
ELSE.
*--------------------------------------------------------------------*
* §1.2 - rich text formatted strings
* it is sufficient to strip the &lt;t&gt;...&lt;/t&gt; tag from each &lt;r&gt;-tag and concatenate these
* as long as rich text formatting is not supported (2do§1) ignore all info about formatting
* Example: see above
*--------------------------------------------------------------------*
WHILE lo_node_si_child IS BOUND. &quot; actually these children of &lt;si&gt; are &lt;r&gt;-tags
lo_node_r_child_t ?= lo_node_si_child-&gt;find_from_name( &apos;t&apos; ). &quot; extract the &lt;t&gt;...&lt;/t&gt; part of each &lt;r&gt;-tag
IF lo_node_r_child_t IS BOUND.
lv_node_value = lo_node_r_child_t-&gt;get_value( ).
CONCATENATE &lt;lv_shared_string&gt; lv_node_value INTO &lt;lv_shared_string&gt; RESPECTING BLANKS.
ENDIF.
lo_node_si_child ?= lo_node_si_child-&gt;get_next( ).
ENDWHILE.
ENDIF.
ENDIF.
lo_node_si ?= lo_node_si-&gt;get_next( ).
ENDWHILE.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLES" VERSION="1" LANGU="E" DESCRIPT="Loads styles" EXPOSURE="1" STATE="1" EDITORDER="6 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLES" SCONAME="IP_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLES" SCONAME="IP_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLES" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_styles.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (wip ) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
* adding comments to explain what we are trying to achieve
*--------------------------------------------------------------------*
TYPES: BEGIN OF lty_xf,
applyalignment TYPE string,
applyborder TYPE string,
applyfill TYPE string,
applyfont TYPE string,
applynumberformat TYPE string,
applyprotection TYPE string,
borderid TYPE string,
fillid TYPE string,
fontid TYPE string,
numfmtid TYPE string,
pivotbutton TYPE string,
quoteprefix TYPE string,
xfid TYPE string,
END OF lty_xf.
TYPES: BEGIN OF lty_alignment,
horizontal TYPE string,
indent TYPE string,
justifylastline TYPE string,
readingorder TYPE string,
relativeindent TYPE string,
shrinktofit TYPE string,
textrotation TYPE string,
vertical TYPE string,
wraptext TYPE string,
END OF lty_alignment.
TYPES: BEGIN OF lty_protection,
hidden TYPE string,
locked TYPE string,
END OF lty_protection.
DATA: lo_styles_xml TYPE REF TO if_ixml_document,
lo_style TYPE REF TO zcl_excel_style,
lt_num_formats TYPE zcl_excel_style_number_format=&gt;t_num_formats,
lt_fills TYPE t_fills,
lt_borders TYPE t_borders,
lt_fonts TYPE t_fonts,
ls_num_format TYPE zcl_excel_style_number_format=&gt;t_num_format ,
ls_fill TYPE REF TO zcl_excel_style_fill,
ls_cell_border TYPE REF TO zcl_excel_style_borders,
ls_font TYPE REF TO zcl_excel_style_font,
lo_node_cellxfs TYPE REF TO if_ixml_element,
lo_node_cellxfs_xf TYPE REF TO if_ixml_element,
lo_node_cellxfs_xf_alignment TYPE REF TO if_ixml_element,
lo_node_cellxfs_xf_protection TYPE REF TO if_ixml_element,
lo_nodes_xf TYPE REF TO if_ixml_node_collection,
lo_iterator_cellxfs TYPE REF TO if_ixml_node_iterator,
ls_xf TYPE lty_xf,
ls_alignment TYPE lty_alignment,
ls_protection TYPE lty_protection,
lv_index TYPE i.
*--------------------------------------------------------------------*
* To build a complete style that fully describes how a cell looks like
* we need the various parts
* §1 - Numberformat
* §2 - Fillstyle
* §3 - Borders
* §4 - Font
* §5 - Alignment
* §6 - Protection
* Following is an example how this part of a file could be set up
* ...
* parts with various formatinformation - see §1,§2,§3,§4
* ...
* &lt;cellXfs count=&quot;26&quot;&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;0&quot; fillId=&quot;0&quot; fontId=&quot;0&quot; xfId=&quot;0&quot;/&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;0&quot; fillId=&quot;2&quot; fontId=&quot;0&quot; xfId=&quot;0&quot; applyFill=&quot;1&quot;/&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;1&quot; fillId=&quot;3&quot; fontId=&quot;0&quot; xfId=&quot;0&quot; applyFill=&quot;1&quot; applyBorder=&quot;1&quot;/&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;2&quot; fillId=&quot;3&quot; fontId=&quot;0&quot; xfId=&quot;0&quot; applyFill=&quot;1&quot; applyBorder=&quot;1&quot;/&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;3&quot; fillId=&quot;3&quot; fontId=&quot;0&quot; xfId=&quot;0&quot; applyFill=&quot;1&quot; applyBorder=&quot;1&quot;/&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;4&quot; fillId=&quot;3&quot; fontId=&quot;0&quot; xfId=&quot;0&quot; applyFill=&quot;1&quot; applyBorder=&quot;1&quot;/&gt;
* &lt;xf numFmtId=&quot;0&quot; borderId=&quot;0&quot; fillId=&quot;3&quot; fontId=&quot;0&quot; xfId=&quot;0&quot; applyFill=&quot;1&quot; applyBorder=&quot;1&quot;/&gt;
* ...
* &lt;/cellXfs&gt;
*--------------------------------------------------------------------*
lo_styles_xml = me-&gt;get_ixml_from_zip_archive( ip_path ).
*--------------------------------------------------------------------*
* The styles are build up from
* §1 number formats
* §2 fill styles
* §3 border styles
* §4 fonts
* These need to be read before we can try to build up a complete
* style that describes the look of a cell
*--------------------------------------------------------------------*
lt_num_formats = load_style_num_formats( lo_styles_xml ). &quot; §1
lt_fills = load_style_fills( lo_styles_xml ). &quot; §2
lt_borders = load_style_borders( lo_styles_xml ). &quot; §3
lt_fonts = load_style_fonts( lo_styles_xml ). &quot; §4
*--------------------------------------------------------------------*
* Now everything is prepared to build a &quot;full&quot; style
*--------------------------------------------------------------------*
lo_node_cellxfs = lo_styles_xml-&gt;find_from_name( name = &apos;cellXfs&apos; ).
IF lo_node_cellxfs IS BOUND.
lo_nodes_xf = lo_node_cellxfs-&gt;get_elements_by_tag_name( name = &apos;xf&apos; ).
lo_iterator_cellxfs = lo_nodes_xf-&gt;create_iterator( ).
lo_node_cellxfs_xf ?= lo_iterator_cellxfs-&gt;get_next( ).
WHILE lo_node_cellxfs_xf IS BOUND.
lo_style = ip_excel-&gt;add_new_style( ).
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_cellxfs_xf
CHANGING
cp_structure = ls_xf ).
*--------------------------------------------------------------------*
* §2 fill style
*--------------------------------------------------------------------*
IF ls_xf-applyfill = &apos;1&apos; AND ls_xf-fillid IS NOT INITIAL.
lv_index = ls_xf-fillid + 1.
READ TABLE lt_fills INTO ls_fill INDEX lv_index.
IF sy-subrc = 0.
lo_style-&gt;fill = ls_fill.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* §1 number format
*--------------------------------------------------------------------*
IF ls_xf-numfmtid IS NOT INITIAL.
READ TABLE lt_num_formats INTO ls_num_format WITH TABLE KEY id = ls_xf-numfmtid.
IF sy-subrc = 0.
lo_style-&gt;number_format = ls_num_format-format.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* §3 border style
*--------------------------------------------------------------------*
IF ls_xf-applyborder = &apos;1&apos; AND ls_xf-borderid IS NOT INITIAL.
lv_index = ls_xf-borderid + 1.
READ TABLE lt_borders INTO ls_cell_border INDEX lv_index.
IF sy-subrc = 0.
lo_style-&gt;borders = ls_cell_border.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* §4 font
*--------------------------------------------------------------------*
IF ls_xf-applyfont = &apos;1&apos; AND ls_xf-fontid IS NOT INITIAL.
lv_index = ls_xf-fontid + 1.
READ TABLE lt_fonts INTO ls_font INDEX lv_index.
IF sy-subrc = 0.
lo_style-&gt;font = ls_font.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* §5 - Alignment
*--------------------------------------------------------------------*
lo_node_cellxfs_xf_alignment ?= lo_node_cellxfs_xf-&gt;find_from_name( &apos;alignment&apos; ).
IF lo_node_cellxfs_xf_alignment IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_cellxfs_xf_alignment
CHANGING
cp_structure = ls_alignment ).
IF ls_alignment-horizontal IS NOT INITIAL.
lo_style-&gt;alignment-&gt;horizontal = ls_alignment-horizontal.
ENDIF.
IF ls_alignment-vertical IS NOT INITIAL.
lo_style-&gt;alignment-&gt;vertical = ls_alignment-vertical.
ENDIF.
IF ls_alignment-textrotation IS NOT INITIAL.
lo_style-&gt;alignment-&gt;textrotation = ls_alignment-textrotation.
ENDIF.
IF ls_alignment-wraptext = &apos;1&apos; OR ls_alignment-wraptext = &apos;true&apos;.
lo_style-&gt;alignment-&gt;wraptext = abap_true.
ENDIF.
IF ls_alignment-shrinktofit = &apos;1&apos; OR ls_alignment-shrinktofit = &apos;true&apos;.
lo_style-&gt;alignment-&gt;shrinktofit = abap_true.
ENDIF.
IF ls_alignment-indent IS NOT INITIAL.
lo_style-&gt;alignment-&gt;indent = ls_alignment-indent.
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
* §6 - Protection
*--------------------------------------------------------------------*
lo_node_cellxfs_xf_protection ?= lo_node_cellxfs_xf-&gt;find_from_name( &apos;protection&apos; ).
IF lo_node_cellxfs_xf_protection IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_cellxfs_xf_protection
CHANGING
cp_structure = ls_protection ).
IF ls_protection-locked = &apos;1&apos; OR ls_protection-locked = &apos;true&apos;.
lo_style-&gt;protection-&gt;locked = zcl_excel_style_protection=&gt;c_protection_locked.
ELSE.
lo_style-&gt;protection-&gt;locked = zcl_excel_style_protection=&gt;c_protection_unlocked.
ENDIF.
IF ls_protection-hidden = &apos;1&apos; OR ls_protection-hidden = &apos;true&apos;.
lo_style-&gt;protection-&gt;hidden = zcl_excel_style_protection=&gt;c_protection_hidden.
ELSE.
lo_style-&gt;protection-&gt;hidden = zcl_excel_style_protection=&gt;c_protection_unhidden.
ENDIF.
ENDIF.
INSERT lo_style INTO TABLE me-&gt;styles.
lo_node_cellxfs_xf ?= lo_iterator_cellxfs-&gt;get_next( ).
ENDWHILE.
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_BORDERS" VERSION="1" LANGU="E" DESCRIPT="Loads &apos;borders&apos; part of styles" EXPOSURE="1" STATE="1" EDITORDER="8 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_BORDERS" SCONAME="IP_XML" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_DOCUMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_BORDERS" SCONAME="EP_BORDERS" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="T_BORDERS"/>
<source>method LOAD_STYLE_BORDERS.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
* renaming variables to indicate what they are used for
* adding comments to explain what we are trying to achieve
*--------------------------------------------------------------------*
DATA: lo_node_border TYPE REF TO if_ixml_element,
lo_node_bordertype TYPE REF TO if_ixml_element,
lo_node_bordercolor TYPE REF TO if_ixml_element,
lo_cell_border TYPE REF TO zcl_excel_style_borders,
lo_border TYPE REF TO zcl_excel_style_border,
ls_color TYPE t_color.
*--------------------------------------------------------------------*
* We need a table of used borderformats to build up our styles
* §1 A cell has 4 outer borders and 2 diagonal &quot;borders&quot;
* These borders can be formatted separately but the diagonal borders
* are always being formatted the same
* We&apos;ll parse through the &lt;border&gt;-tag for each of the bordertypes
* §2 and read the corresponding formatting information
* Following is an example how this part of a file could be set up
* &lt;border diagonalDown=&quot;1&quot;&gt;
* &lt;left style=&quot;mediumDashDotDot&quot;&gt;
* &lt;color rgb=&quot;FFFF0000&quot;/&gt;
* &lt;/left&gt;
* &lt;right/&gt;
* &lt;top style=&quot;thick&quot;&gt;
* &lt;color rgb=&quot;FFFF0000&quot;/&gt;
* &lt;/top&gt;
* &lt;bottom style=&quot;thick&quot;&gt;
* &lt;color rgb=&quot;FFFF0000&quot;/&gt;
* &lt;/bottom&gt;
* &lt;diagonal style=&quot;thick&quot;&gt;
* &lt;color rgb=&quot;FFFF0000&quot;/&gt;
* &lt;/diagonal&gt;
* &lt;/border&gt;
*--------------------------------------------------------------------*
lo_node_border ?= ip_xml-&gt;find_from_name( &apos;border&apos; ).
WHILE lo_node_border IS BOUND.
CREATE OBJECT lo_cell_border.
*--------------------------------------------------------------------*
* Diagonal borderlines are formatted the equally. Determine what kind of diagonal borders are present if any
*--------------------------------------------------------------------*
* DiagonalNone = 0
* DiagonalUp = 1
* DiagonalDown = 2
* DiagonalBoth = 3
*--------------------------------------------------------------------*
IF lo_node_border-&gt;get_attribute( &apos;diagonalDown&apos; ) IS NOT INITIAL.
add zcl_excel_style_borders=&gt;c_diagonal_down to lo_cell_border-&gt;diagonal_mode.
ENDIF.
IF lo_node_border-&gt;get_attribute( &apos;diagonalUp&apos; ) IS NOT INITIAL.
add zcl_excel_style_borders=&gt;c_diagonal_up to lo_cell_border-&gt;diagonal_mode.
ENDIF.
lo_node_bordertype ?= lo_node_border-&gt;get_first_child( ).
WHILE lo_node_bordertype IS BOUND.
*--------------------------------------------------------------------*
* §1 Determine what kind of border we are talking about
*--------------------------------------------------------------------*
* Up, down, left, right, diagonal
*--------------------------------------------------------------------*
CREATE OBJECT lo_border.
CASE lo_node_bordertype-&gt;get_name( ).
WHEN &apos;left&apos;.
lo_cell_border-&gt;left = lo_border.
WHEN &apos;right&apos;.
lo_cell_border-&gt;right = lo_border.
WHEN &apos;top&apos;.
lo_cell_border-&gt;top = lo_border.
WHEN &apos;bottom&apos;.
lo_cell_border-&gt;down = lo_border.
WHEN &apos;diagonal&apos;.
lo_cell_border-&gt;diagonal = lo_border.
ENDCASE.
*--------------------------------------------------------------------*
* §2 Read the border-formatting
*--------------------------------------------------------------------*
lo_border-&gt;border_style = lo_node_bordertype-&gt;get_attribute( &apos;style&apos; ).
lo_node_bordercolor ?= lo_node_bordertype-&gt;find_from_name( &apos;color&apos; ).
IF lo_node_bordercolor IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_bordercolor
CHANGING
cp_structure = ls_color ).
lo_border-&gt;border_color-rgb = ls_color-rgb.
IF ls_color-indexed IS NOT INITIAL.
lo_border-&gt;border_color-indexed = ls_color-indexed.
ENDIF.
IF ls_color-theme IS NOT INITIAL.
lo_border-&gt;border_color-theme = ls_color-theme.
ENDIF.
lo_border-&gt;border_color-tint = ls_color-tint.
ENDIF.
lo_node_bordertype ?= lo_node_bordertype-&gt;get_next( ).
ENDWHILE.
INSERT lo_cell_border INTO TABLE ep_borders.
lo_node_border ?= lo_node_border-&gt;get_next( ).
ENDWHILE.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_FILLS" VERSION="1" LANGU="E" DESCRIPT="Loads &apos;fills&apos; part of styles" EXPOSURE="1" STATE="1" EDITORDER="9 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_FILLS" SCONAME="IP_XML" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_DOCUMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_FILLS" SCONAME="EP_FILLS" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="T_FILLS"/>
<source>method LOAD_STYLE_FILLS.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Support gradientFill
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
* commenting on problems/future enhancements/todos we already know of or should decide upon
* adding comments to explain what we are trying to achieve
* renaming variables to indicate what they are used for
*--------------------------------------------------------------------*
DATA: lv_value TYPE string,
lo_node_fill TYPE REF TO if_ixml_element,
lo_node_fill_child TYPE REF TO if_ixml_element,
lo_node_bgcolor TYPE REF TO if_ixml_element,
lo_node_fgcolor TYPE REF TO if_ixml_element,
lo_node_stop TYPE REF TO if_ixml_element,
lo_fill TYPE REF TO zcl_excel_style_fill,
ls_color TYPE t_color.
*--------------------------------------------------------------------*
* We need a table of used fillformats to build up our styles
* Following is an example how this part of a file could be set up
* &lt;fill&gt;
* &lt;patternFill patternType=&quot;gray125&quot;/&gt;
* &lt;/fill&gt;
* &lt;fill&gt;
* &lt;patternFill patternType=&quot;solid&quot;&gt;
* &lt;fgColor rgb=&quot;FFFFFF00&quot;/&gt;
* &lt;bgColor indexed=&quot;64&quot;/&gt;
* &lt;/patternFill&gt;
* &lt;/fill&gt;
*--------------------------------------------------------------------*
lo_node_fill ?= ip_xml-&gt;find_from_name( &apos;fill&apos; ).
WHILE lo_node_fill IS BOUND.
CREATE OBJECT lo_fill.
lo_node_fill_child ?= lo_node_fill-&gt;get_first_child( ).
lv_value = lo_node_fill_child-&gt;get_name( ).
CASE lv_value.
*--------------------------------------------------------------------*
* Patternfill
*--------------------------------------------------------------------*
WHEN &apos;patternFill&apos;.
lo_fill-&gt;filltype = lo_node_fill_child-&gt;get_attribute( &apos;patternType&apos; ).
*--------------------------------------------------------------------*
* Patternfill - background color
*--------------------------------------------------------------------*
lo_node_bgcolor = lo_node_fill_child-&gt;find_from_name( &apos;bgColor&apos; ).
IF lo_node_bgcolor IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_bgcolor
CHANGING
cp_structure = ls_color ).
lo_fill-&gt;bgcolor-rgb = ls_color-rgb.
IF ls_color-indexed IS NOT INITIAL.
lo_fill-&gt;bgcolor-indexed = ls_color-indexed.
ENDIF.
IF ls_color-theme IS NOT INITIAL.
lo_fill-&gt;bgcolor-theme = ls_color-theme.
ENDIF.
lo_fill-&gt;bgcolor-tint = ls_color-tint.
ENDIF.
*--------------------------------------------------------------------*
* Patternfill - foreground color
*--------------------------------------------------------------------*
lo_node_fgcolor = lo_node_fill-&gt;find_from_name( &apos;fgColor&apos; ).
IF lo_node_fgcolor IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_fgcolor
CHANGING
cp_structure = ls_color ).
lo_fill-&gt;fgcolor-rgb = ls_color-rgb.
IF ls_color-indexed IS NOT INITIAL.
lo_fill-&gt;fgcolor-indexed = ls_color-indexed.
ENDIF.
IF ls_color-theme IS NOT INITIAL.
lo_fill-&gt;fgcolor-theme = ls_color-theme.
ENDIF.
lo_fill-&gt;fgcolor-tint = ls_color-tint.
ENDIF.
*--------------------------------------------------------------------*
* gradientFill
*--------------------------------------------------------------------*
WHEN &apos;gradientFill&apos;.
lo_fill-&gt;gradtype-type = lo_node_fill_child-&gt;get_attribute( &apos;type&apos; ).
lo_fill-&gt;gradtype-top = lo_node_fill_child-&gt;get_attribute( &apos;top&apos; ).
lo_fill-&gt;gradtype-left = lo_node_fill_child-&gt;get_attribute( &apos;left&apos; ).
lo_fill-&gt;gradtype-right = lo_node_fill_child-&gt;get_attribute( &apos;right&apos; ).
lo_fill-&gt;gradtype-bottom = lo_node_fill_child-&gt;get_attribute( &apos;bottom&apos; ).
lo_fill-&gt;gradtype-degree = lo_node_fill_child-&gt;get_attribute( &apos;degree&apos; ).
free lo_node_stop.
lo_node_stop ?= lo_node_fill_child-&gt;find_from_name( &apos;stop&apos; ).
while lo_node_stop is bound.
if lo_fill-&gt;gradtype-position1 is initial.
lo_fill-&gt;gradtype-position1 = lo_node_stop-&gt;get_attribute( &apos;position&apos; ).
lo_node_bgcolor = lo_node_stop-&gt;find_from_name( &apos;color&apos; ).
IF lo_node_bgcolor IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_bgcolor
CHANGING
cp_structure = ls_color ).
lo_fill-&gt;bgcolor-rgb = ls_color-rgb.
IF ls_color-indexed IS NOT INITIAL.
lo_fill-&gt;bgcolor-indexed = ls_color-indexed.
ENDIF.
IF ls_color-theme IS NOT INITIAL.
lo_fill-&gt;bgcolor-theme = ls_color-theme.
ENDIF.
lo_fill-&gt;bgcolor-tint = ls_color-tint.
ENDIF.
elseif lo_fill-&gt;gradtype-position2 is initial.
lo_fill-&gt;gradtype-position2 = lo_node_stop-&gt;get_attribute( &apos;position&apos; ).
lo_node_fgcolor = lo_node_stop-&gt;find_from_name( &apos;color&apos; ).
IF lo_node_fgcolor IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node_fgcolor
CHANGING
cp_structure = ls_color ).
lo_fill-&gt;fgcolor-rgb = ls_color-rgb.
IF ls_color-indexed IS NOT INITIAL.
lo_fill-&gt;fgcolor-indexed = ls_color-indexed.
ENDIF.
IF ls_color-theme IS NOT INITIAL.
lo_fill-&gt;fgcolor-theme = ls_color-theme.
ENDIF.
lo_fill-&gt;fgcolor-tint = ls_color-tint.
ENDIF.
elseif lo_fill-&gt;gradtype-position3 is initial.
lo_fill-&gt;gradtype-position3 = lo_node_stop-&gt;get_attribute( &apos;position&apos; ).
&quot;BGColor is filled already with position 1 no need to check again
endif.
lo_node_stop ?= lo_node_stop-&gt;get_next( ).
ENDWHILE.
WHEN OTHERS.
ENDCASE.
INSERT lo_fill INTO TABLE ep_fills.
lo_node_fill ?= lo_node_fill-&gt;get_next( ).
ENDWHILE.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_FONTS" VERSION="1" LANGU="E" DESCRIPT="Loads &apos;fonts&apos; part of styles" EXPOSURE="1" STATE="1" EDITORDER="10 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_FONTS" SCONAME="IP_XML" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_DOCUMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_FONTS" SCONAME="EP_FONTS" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="T_FONTS"/>
<source>METHOD load_style_fonts.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
* removing unused variables
* adding comments to explain what we are trying to achieve
*--------------------------------------------------------------------*
DATA: lo_node_font TYPE REF TO if_ixml_element,
lo_node2 TYPE REF TO if_ixml_element,
lo_font TYPE REF TO zcl_excel_style_font,
ls_color TYPE t_color.
*--------------------------------------------------------------------*
* We need a table of used fonts to build up our styles
* Following is an example how this part of a file could be set up
* &lt;font&gt;
* &lt;sz val=&quot;11&quot;/&gt;
* &lt;color theme=&quot;1&quot;/&gt;
* &lt;name val=&quot;Calibri&quot;/&gt;
* &lt;family val=&quot;2&quot;/&gt;
* &lt;scheme val=&quot;minor&quot;/&gt;
* &lt;/font&gt;
*--------------------------------------------------------------------*
lo_node_font ?= ip_xml-&gt;find_from_name( &apos;font&apos; ).
WHILE lo_node_font IS BOUND.
CREATE OBJECT lo_font.
*--------------------------------------------------------------------*
* Bold
*--------------------------------------------------------------------*
IF lo_node_font-&gt;find_from_name( &apos;b&apos; ) IS BOUND.
lo_font-&gt;bold = abap_true.
ENDIF.
*--------------------------------------------------------------------*
* Italic
*--------------------------------------------------------------------*
IF lo_node_font-&gt;find_from_name( &apos;i&apos; ) IS BOUND.
lo_font-&gt;italic = abap_true.
ENDIF.
*--------------------------------------------------------------------*
* Underline
*--------------------------------------------------------------------*
lo_node2 = lo_node_font-&gt;find_from_name( &apos;u&apos; ).
IF lo_node2 IS BOUND.
lo_font-&gt;underline = abap_true.
lo_font-&gt;underline_mode = lo_node2-&gt;get_attribute( &apos;val&apos; ).
ENDIF.
*--------------------------------------------------------------------*
* StrikeThrough
*--------------------------------------------------------------------*
IF lo_node_font-&gt;find_from_name( &apos;strike&apos; ) IS BOUND.
lo_font-&gt;strikethrough = abap_true.
ENDIF.
*--------------------------------------------------------------------*
* Fontsize
*--------------------------------------------------------------------*
lo_node2 = lo_node_font-&gt;find_from_name( &apos;sz&apos; ).
IF lo_node2 IS BOUND.
lo_font-&gt;size = lo_node2-&gt;get_attribute( &apos;val&apos; ).
ENDIF.
*--------------------------------------------------------------------*
* Fontname
*--------------------------------------------------------------------*
lo_node2 = lo_node_font-&gt;find_from_name( &apos;name&apos; ).
IF lo_node2 IS BOUND.
lo_font-&gt;name = lo_node2-&gt;get_attribute( &apos;val&apos; ).
ENDIF.
*--------------------------------------------------------------------*
* Fontfamily
*--------------------------------------------------------------------*
lo_node2 = lo_node_font-&gt;find_from_name( &apos;family&apos; ).
IF lo_node2 IS BOUND.
lo_font-&gt;family = lo_node2-&gt;get_attribute( &apos;val&apos; ).
ENDIF.
*--------------------------------------------------------------------*
* Fontscheme
*--------------------------------------------------------------------*
lo_node2 = lo_node_font-&gt;find_from_name( &apos;scheme&apos; ).
IF lo_node2 IS BOUND.
lo_font-&gt;scheme = lo_node2-&gt;get_attribute( &apos;val&apos; ).
ELSE.
CLEAR lo_font-&gt;scheme.
ENDIF.
*--------------------------------------------------------------------*
* Fontcolor
*--------------------------------------------------------------------*
lo_node2 = lo_node_font-&gt;find_from_name( &apos;color&apos; ).
IF lo_node2 IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_node2
CHANGING
cp_structure = ls_color ).
lo_font-&gt;color-rgb = ls_color-rgb.
IF ls_color-indexed IS NOT INITIAL.
lo_font-&gt;color-indexed = ls_color-indexed.
ENDIF.
IF ls_color-theme IS NOT INITIAL.
lo_font-&gt;color-theme = ls_color-theme.
ENDIF.
lo_font-&gt;color-tint = ls_color-tint.
ENDIF.
INSERT lo_font INTO TABLE ep_fonts.
lo_node_font ?= lo_node_font-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_NUM_FORMATS" VERSION="1" LANGU="E" DESCRIPT="Loads &apos;number format&apos; part of styles" EXPOSURE="1" STATE="1" EDITORDER="11 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_NUM_FORMATS" SCONAME="IP_XML" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_DOCUMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_STYLE_NUM_FORMATS" SCONAME="EP_NUM_FORMATS" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ZCL_EXCEL_STYLE_NUMBER_FORMAT=&gt;T_NUM_FORMATS"/>
<source>METHOD load_style_num_formats.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Explain gaps in predefined formats
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* adding comments to explain what we are trying to achieve
* aligning code
*--------------------------------------------------------------------*
DATA: lo_node_numfmt TYPE REF TO if_ixml_element,
ls_num_format TYPE ZCL_EXCEL_STYLE_NUMBER_FORMAT=&gt;T_NUM_FORMAT .
*--------------------------------------------------------------------*
* We need a table of used numberformats to build up our styles
* there are two kinds of numberformats
* §1 built-in numberformats
* §2 and those that have been explicitly added by the createor of the excel-file
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* §1 built-in numberformats
*--------------------------------------------------------------------*
ep_num_formats = ZCL_EXCEL_STYLE_NUMBER_FORMAT=&gt;mt_built_in_num_formats.
*--------------------------------------------------------------------*
* §2 Get non-internal numberformats that are found in the file explicitly
* Following is an example how this part of a file could be set up
* &lt;numFmts count=&quot;1&quot;&gt;
* &lt;numFmt formatCode=&quot;#,###,###,###,##0.00&quot; numFmtId=&quot;164&quot;/&gt;
* &lt;/numFmts&gt;
*--------------------------------------------------------------------*
lo_node_numfmt ?= ip_xml-&gt;find_from_name( &apos;numFmt&apos; ).
WHILE lo_node_numfmt IS BOUND.
CLEAR ls_num_format.
CREATE OBJECT ls_num_format-format.
ls_num_format-format-&gt;format_code = lo_node_numfmt-&gt;get_attribute( &apos;formatCode&apos; ).
ls_num_format-id = lo_node_numfmt-&gt;get_attribute( &apos;numFmtId&apos; ).
INSERT ls_num_format INTO TABLE ep_num_formats.
lo_node_numfmt ?= lo_node_numfmt-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_THEME" VERSION="1" LANGU="E" DESCRIPT="Loads theme" EXPOSURE="1" STATE="1" EDITORDER="29 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_THEME" SCONAME="IV_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_THEME" SCONAME="IP_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL"/>
<source>method load_theme.
data theme type ref to zcl_excel_theme.
data: lo_theme_xml type ref to if_ixml_document.
create object theme.
lo_theme_xml = me-&gt;get_ixml_from_zip_archive( iv_path ).
theme-&gt;read_theme( io_theme_xml = lo_theme_xml ).
ip_excel-&gt;set_theme( io_theme = theme ).
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKBOOK" VERSION="1" LANGU="E" DESCRIPT="Loads workbook" EXPOSURE="1" STATE="1" EDITORDER="12 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKBOOK" SCONAME="IV_WORKBOOK_FULL_FILENAME" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKBOOK" SCONAME="IO_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKBOOK" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>method LOAD_WORKBOOK.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Move macro-reading from zcl_excel_reader_xlsm to this class
* autodetect existance of macro/vba content
* Allow inputparameter to explicitly tell reader to ignore vba-content
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-10
* - ...
* changes: renaming variables to naming conventions
* aligning code
* removing unused variables
* adding me-&gt; where possible
* renaming variables to indicate what they are used for
* adding comments to explain what we are trying to achieve
* renaming i/o parameters: previous input-parameter ip_path holds a (full) filename and not a path --&gt; rename to iv_workbook_full_filename
* ip_excel renamed while being at it --&gt; rename to io_excel
*--------------------------------------------------------------------*
* issue #232 - Read worksheetstate hidden/veryHidden
* - Stefan Schmoecker, 2012-11-11
*--------------------------------------------------------------------*
* issue#235 - repeat rows/columns
* - Stefan Schmoecker, 2012-12-02
* changes: correction in named ranges to correctly attach
* sheetlocal names/ranges to the correct sheet
*--------------------------------------------------------------------*
* issue#284 - Copied formulae ignored when reading excelfile
* - Stefan Schmoecker, 2013-08-02
* changes: initialize area to hold referenced formulaedata
* after all worksheets have been read resolve formuae
*--------------------------------------------------------------------*
CONSTANTS: lcv_shared_strings TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings&apos;,
lcv_worksheet TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet&apos;,
lcv_styles TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles&apos;,
lcv_vba_project TYPE string VALUE &apos;http://schemas.microsoft.com/office/2006/relationships/vbaProject&apos;, &quot;#EC NEEDED for future incorporation of XLSM-reader
lcv_theme TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme&apos;,
*--------------------------------------------------------------------*
* #232: Read worksheetstate hidden/veryHidden - begin data declarations
*--------------------------------------------------------------------*
lcv_worksheet_state_hidden TYPE string VALUE &apos;hidden&apos;,
lcv_worksheet_state_veryhidden TYPE string VALUE &apos;veryHidden&apos;.
*--------------------------------------------------------------------*
* #232: Read worksheetstate hidden/veryHidden - end data declarations
*--------------------------------------------------------------------*
DATA:
lv_path TYPE string,
lv_filename TYPE chkfile,
lv_full_filename TYPE string,
lo_rels_workbook TYPE REF TO if_ixml_document,
lt_worksheets TYPE STANDARD TABLE OF t_relationship WITH NON-UNIQUE DEFAULT KEY,
lo_workbook TYPE REF TO if_ixml_document,
lv_workbook_index TYPE i,
lv_worksheet_path TYPE string,
ls_sheet TYPE t_sheet,
lo_node TYPE REF TO if_ixml_element,
ls_relationship TYPE t_relationship,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_range TYPE REF TO zcl_excel_range,
lv_worksheet_title TYPE zexcel_sheet_title,
lv_tabix TYPE sytabix, &quot; #235 - repeat rows/cols. Needed to link defined name to correct worksheet
ls_range TYPE t_range,
lv_range_value TYPE zexcel_range_value,
*--------------------------------------------------------------------*
* #229: Set active worksheet - begin data declarations
*--------------------------------------------------------------------*
lv_active_sheet_string TYPE string,
lv_zexcel_active_worksheet TYPE zexcel_active_worksheet,
*--------------------------------------------------------------------*
* issue#235 - repeat rows/columns - added autofilter support while changing this section
lo_autofilter TYPE REF TO zcl_excel_autofilter,
ls_area TYPE zexcel_s_autofilter_area,
lv_col_start_alpha TYPE zexcel_cell_column_alpha,
lv_col_end_alpha TYPE zexcel_cell_column_alpha,
lv_row_start TYPE zexcel_cell_row,
lv_row_end TYPE zexcel_cell_row ,
lv_regex TYPE string,
lv_range_value_1 TYPE zexcel_range_value,
lv_range_value_2 TYPE zexcel_range_value.
*--------------------------------------------------------------------*
* #229: Set active worksheet - end data declarations
*--------------------------------------------------------------------*
FIELD-SYMBOLS: &lt;worksheet&gt; TYPE t_relationship.
*--------------------------------------------------------------------*
* §1 Get the position of files related to this workbook
* Usually this will be &lt;root&gt;/xl/workbook.xml
* Thus the workbookroot will be &lt;root&gt;/xl/
* The position of all related files will be given in file
* &lt;workbookroot&gt;/_rels/&lt;workbookfilename&gt;.rels and their positions
* be be given relative to the workbookroot
* Following is an example how this file could be set up
* &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;true&quot;?&gt;
* &lt;Relationships xmlns=&quot;http://schemas.openxmlformats.org/package/2006/relationships&quot;&gt;
* &lt;Relationship Target=&quot;styles.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles&quot; Id=&quot;rId6&quot;/&gt;
* &lt;Relationship Target=&quot;theme/theme1.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme&quot; Id=&quot;rId5&quot;/&gt;
* &lt;Relationship Target=&quot;worksheets/sheet1.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet&quot; Id=&quot;rId1&quot;/&gt;
* &lt;Relationship Target=&quot;worksheets/sheet2.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet&quot; Id=&quot;rId2&quot;/&gt;
* &lt;Relationship Target=&quot;worksheets/sheet3.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet&quot; Id=&quot;rId3&quot;/&gt;
* &lt;Relationship Target=&quot;worksheets/sheet4.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet&quot; Id=&quot;rId4&quot;/&gt;
* &lt;Relationship Target=&quot;sharedStrings.xml&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings&quot; Id=&quot;rId7&quot;/&gt;
* &lt;/Relationships&gt;
*
* §2 Load data that is relevant to the complete workbook
* Currently supported is:
* §2.1 Shared strings - This holds all strings that are used in all worksheets
* §2.2 Styles - This holds all styles that are used in all worksheets
* §2.3 Worksheets - For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet
* §2.4 [Themes] - not supported
* §2.5 [VBA (Macro)] - supported in class zcl_excel_reader_xlsm but should be moved here and autodetect
* ...
*
* §3 Some information is held in the workbookfile as well
* §3.1 Names and order of of worksheets
* §3.2 Active worksheet
* §3.3 Defined names
* ...
* Following is an example how this file could be set up
* &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;true&quot;?&gt;
* &lt;workbook xmlns:r=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships&quot; xmlns=&quot;http://schemas.openxmlformats.org/spreadsheetml/2006/main&quot;&gt;
* &lt;fileVersion rupBuild=&quot;4506&quot; lowestEdited=&quot;4&quot; lastEdited=&quot;4&quot; appName=&quot;xl&quot;/&gt;
* &lt;workbookPr defaultThemeVersion=&quot;124226&quot;/&gt;
* &lt;bookViews&gt;
* &lt;workbookView activeTab=&quot;1&quot; windowHeight=&quot;8445&quot; windowWidth=&quot;19035&quot; yWindow=&quot;120&quot; xWindow=&quot;120&quot;/&gt;
* &lt;/bookViews&gt;
* &lt;sheets&gt;
* &lt;sheet r:id=&quot;rId1&quot; sheetId=&quot;1&quot; name=&quot;Sheet1&quot;/&gt;
* &lt;sheet r:id=&quot;rId2&quot; sheetId=&quot;2&quot; name=&quot;Sheet2&quot;/&gt;
* &lt;sheet r:id=&quot;rId3&quot; sheetId=&quot;3&quot; name=&quot;Sheet3&quot; state=&quot;hidden&quot;/&gt;
* &lt;sheet r:id=&quot;rId4&quot; sheetId=&quot;4&quot; name=&quot;Sheet4&quot;/&gt;
* &lt;/sheets&gt;
* &lt;definedNames/&gt;
* &lt;calcPr calcId=&quot;125725&quot;/&gt;
* &lt;/workbook&gt;
*--------------------------------------------------------------------*
CLEAR me-&gt;mt_ref_formulae. &quot; ins issue#284
*--------------------------------------------------------------------*
* §1 Get the position of files related to this workbook
* Entry into this method is with the filename of the workbook
*--------------------------------------------------------------------*
CALL FUNCTION &apos;TRINT_SPLIT_FILE_AND_PATH&apos;
EXPORTING
full_name = iv_workbook_full_filename
IMPORTING
stripped_name = lv_filename
file_path = lv_path.
CONCATENATE lv_path &apos;_rels/&apos; lv_filename &apos;.rels&apos;
INTO lv_full_filename.
lo_rels_workbook = me-&gt;get_ixml_from_zip_archive( lv_full_filename ).
lo_node ?= lo_rels_workbook-&gt;find_from_name( &apos;Relationship&apos; ). &quot;#EC NOTEXT
WHILE lo_node IS BOUND.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = lo_node CHANGING cp_structure = ls_relationship ).
CASE ls_relationship-type.
*--------------------------------------------------------------------*
* §2.1 Shared strings - This holds all strings that are used in all worksheets
*--------------------------------------------------------------------*
WHEN lcv_shared_strings.
CONCATENATE lv_path ls_relationship-target
INTO lv_full_filename.
me-&gt;load_shared_strings( lv_full_filename ).
*--------------------------------------------------------------------*
* §2.3 Worksheets
* For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet
* Shared strings and styles have to be present before we can start with creating the worksheets
* thus we only store this information for use when parsing the workbookfile for sheetinformations
*--------------------------------------------------------------------*
WHEN lcv_worksheet.
APPEND ls_relationship TO lt_worksheets.
*--------------------------------------------------------------------*
* §2.2 Styles - This holds the styles that are used in all worksheets
*--------------------------------------------------------------------*
WHEN lcv_styles.
CONCATENATE lv_path ls_relationship-target
INTO lv_full_filename.
me-&gt;load_styles( ip_path = lv_full_filename
ip_excel = io_excel ).
me-&gt;load_dxf_styles( iv_path = lv_full_filename
io_excel = io_excel ).
when lcv_theme.
CONCATENATE lv_path ls_relationship-target
INTO lv_full_filename.
me-&gt;load_theme(
exporting
iv_path = lv_full_filename
ip_excel = io_excel &quot; Excel creator
).
WHEN OTHERS.
ENDCASE.
lo_node ?= lo_node-&gt;get_next( ).
ENDWHILE.
*--------------------------------------------------------------------*
* §3 Some information held in the workbookfile
*--------------------------------------------------------------------*
lo_workbook = me-&gt;get_ixml_from_zip_archive( iv_workbook_full_filename ).
*--------------------------------------------------------------------*
* §3.1 Names and order of of worksheets
*--------------------------------------------------------------------*
lo_node ?= lo_workbook-&gt;find_from_name( &apos;sheet&apos; ).
lv_workbook_index = 1.
WHILE lo_node IS BOUND.
me-&gt;fill_struct_from_attributes( EXPORTING
ip_element = lo_node
CHANGING
cp_structure = ls_sheet ).
*--------------------------------------------------------------------*
* Create new worksheet in workbook with correct name
*--------------------------------------------------------------------*
lv_worksheet_title = ls_sheet-name.
IF lv_workbook_index = 1. &quot; First sheet has been added automatically by creating io_excel
lo_worksheet = io_excel-&gt;get_active_worksheet( ).
lo_worksheet-&gt;set_title( lv_worksheet_title ).
ELSE.
lo_worksheet = io_excel-&gt;add_new_worksheet( lv_worksheet_title ).
ENDIF.
*--------------------------------------------------------------------*
* #232 - Read worksheetstate hidden/veryHidden - begin of coding
* Set status hidden if necessary
*--------------------------------------------------------------------*
CASE ls_sheet-state.
WHEN lcv_worksheet_state_hidden.
lo_worksheet-&gt;zif_excel_sheet_properties~hidden = zif_excel_sheet_properties=&gt;c_hidden.
WHEN lcv_worksheet_state_veryhidden.
lo_worksheet-&gt;zif_excel_sheet_properties~hidden = zif_excel_sheet_properties=&gt;c_veryhidden.
ENDCASE.
*--------------------------------------------------------------------*
* #232 - Read worksheetstate hidden/veryHidden - end of coding
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* Load worksheetdata
*--------------------------------------------------------------------*
READ TABLE lt_worksheets ASSIGNING &lt;worksheet&gt; WITH KEY id = ls_sheet-id.
IF sy-subrc = 0.
&lt;worksheet&gt;-sheetid = ls_sheet-sheetid. &quot;ins #235 - repeat rows/cols - needed to identify correct sheet
CONCATENATE lv_path &lt;worksheet&gt;-target
INTO lv_worksheet_path.
me-&gt;load_worksheet( ip_path = lv_worksheet_path
io_worksheet = lo_worksheet ).
&lt;worksheet&gt;-worksheet = lo_worksheet.
ENDIF.
lo_node ?= lo_node-&gt;get_next( ).
ADD 1 TO lv_workbook_index.
ENDWHILE.
SORT lt_worksheets BY sheetid. &quot; needed for localSheetid -referencing
*--------------------------------------------------------------------*
* #284: Set active worksheet - Resolve referenced formulae to
* explicit formulae those cells
*--------------------------------------------------------------------*
me-&gt;resolve_referenced_formulae( ).
&quot; ins issue#284
*--------------------------------------------------------------------*
* #229: Set active worksheet - begin coding
* §3.2 Active worksheet
*--------------------------------------------------------------------*
lv_zexcel_active_worksheet = 1. &quot; First sheet = active sheet if nothing else specified.
lo_node ?= lo_workbook-&gt;find_from_name( &apos;workbookView&apos; ).
IF lo_node IS BOUND.
lv_active_sheet_string = lo_node-&gt;get_attribute( &apos;activeTab&apos; ).
TRY.
lv_zexcel_active_worksheet = lv_active_sheet_string + 1. &quot; EXCEL numbers the sheets from 0 onwards --&gt; index into worksheettable is increased by one
CATCH cx_sy_conversion_error. &quot;#EC NO_HANDLER - error here --&gt; just use the default 1st sheet
ENDTRY.
ENDIF.
io_excel-&gt;set_active_sheet_index( lv_zexcel_active_worksheet ).
*--------------------------------------------------------------------*
* #229: Set active worksheet - end coding
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* §3.3 Defined names
* So far I have encountered these
* - named ranges - sheetlocal
* - named ranges - workbookglobal
* - autofilters - sheetlocal ( special range )
* - repeat rows/cols - sheetlocal ( special range )
*
*--------------------------------------------------------------------*
lo_node ?= lo_workbook-&gt;find_from_name( &apos;definedName&apos; ).
WHILE lo_node IS BOUND.
CLEAR lo_range. &quot;ins issue #235 - repeat rows/cols
me-&gt;fill_struct_from_attributes( EXPORTING
ip_element = lo_node
CHANGING
cp_structure = ls_range ).
lv_range_value = lo_node-&gt;get_value( ).
IF ls_range-localsheetid IS NOT INITIAL. &quot; issue #163+
* READ TABLE lt_worksheets ASSIGNING &lt;worksheet&gt; WITH KEY id = ls_range-localsheetid. &quot;del issue #235 - repeat rows/cols &quot; issue #163+
* lo_range = &lt;worksheet&gt;-worksheet-&gt;add_new_range( ). &quot;del issue #235 - repeat rows/cols &quot; issue #163+
*--------------------------------------------------------------------*
* issue#235 - repeat rows/columns - begin
*--------------------------------------------------------------------*
lv_tabix = ls_range-localsheetid + 1.
READ TABLE lt_worksheets ASSIGNING &lt;worksheet&gt; INDEX lv_tabix.
IF sy-subrc = 0.
CASE ls_range-name.
*--------------------------------------------------------------------*
* insert autofilters
*--------------------------------------------------------------------*
WHEN zcl_excel_autofilters=&gt;c_autofilter.
lo_autofilter = io_excel-&gt;add_new_autofilter( io_sheet = &lt;worksheet&gt;-worksheet ) .
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING i_range = lv_range_value
IMPORTING e_column_start = lv_col_start_alpha
e_column_end = lv_col_end_alpha
e_row_start = ls_area-row_start
e_row_end = ls_area-row_end ).
ls_area-col_start = zcl_excel_common=&gt;convert_column2int( lv_col_start_alpha ).
ls_area-col_end = zcl_excel_common=&gt;convert_column2int( lv_col_end_alpha ).
lo_autofilter-&gt;set_filter_area( is_area = ls_area ).
*--------------------------------------------------------------------*
* repeat print rows/columns
*--------------------------------------------------------------------*
WHEN zif_excel_sheet_printsettings=&gt;gcv_print_title_name.
lo_range = &lt;worksheet&gt;-worksheet-&gt;add_new_range( ).
*--------------------------------------------------------------------*
* This might be a temporary solution. Maybe ranges get be reworked
* to support areas consisting of multiple rectangles
* But for now just split the range into row and columnpart
*--------------------------------------------------------------------*
CLEAR:lv_range_value_1,
lv_range_value_2.
IF lv_range_value IS INITIAL.
* Empty --&gt; nothing to do
ELSE.
IF lv_range_value(1) = `&apos;`. &quot; Escaped
lv_regex = `^(&apos;[^&apos;]*&apos;)+![^,]*,`.
ELSE.
lv_regex = `^[^!]*![^,]*,`.
ENDIF.
* Split into two ranges if necessary
FIND REGEX lv_regex IN lv_range_value MATCH LENGTH sy-fdpos.
IF sy-subrc = 0 AND sy-fdpos &gt; 0.
lv_range_value_2 = lv_range_value+sy-fdpos.
SUBTRACT 1 FROM sy-fdpos.
lv_range_value_1 = lv_range_value(sy-fdpos).
ELSE.
lv_range_value_1 = lv_range_value.
ENDIF.
ENDIF.
* 1st range
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING i_range = lv_range_value_1
IMPORTING e_column_start = lv_col_start_alpha
e_column_end = lv_col_end_alpha
e_row_start = lv_row_start
e_row_end = lv_row_end ).
IF lv_col_start_alpha IS NOT INITIAL.
&lt;worksheet&gt;-worksheet-&gt;zif_excel_sheet_printsettings~set_print_repeat_columns( iv_columns_from = lv_col_start_alpha
iv_columns_to = lv_col_end_alpha ).
ENDIF.
IF lv_row_start IS NOT INITIAL.
&lt;worksheet&gt;-worksheet-&gt;zif_excel_sheet_printsettings~set_print_repeat_rows( iv_rows_from = lv_row_start
iv_rows_to = lv_row_end ).
ENDIF.
* 2nd range
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING i_range = lv_range_value_2
IMPORTING e_column_start = lv_col_start_alpha
e_column_end = lv_col_end_alpha
e_row_start = lv_row_start
e_row_end = lv_row_end ).
IF lv_col_start_alpha IS NOT INITIAL.
&lt;worksheet&gt;-worksheet-&gt;zif_excel_sheet_printsettings~set_print_repeat_columns( iv_columns_from = lv_col_start_alpha
iv_columns_to = lv_col_end_alpha ).
ENDIF.
IF lv_row_start IS NOT INITIAL.
&lt;worksheet&gt;-worksheet-&gt;zif_excel_sheet_printsettings~set_print_repeat_rows( iv_rows_from = lv_row_start
iv_rows_to = lv_row_end ).
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDIF.
*--------------------------------------------------------------------*
* issue#235 - repeat rows/columns - end
*--------------------------------------------------------------------*
ELSE. &quot; issue #163+
lo_range = io_excel-&gt;add_new_range( ). &quot; issue #163+
ENDIF. &quot; issue #163+
* lo_range = ip_excel-&gt;add_new_range( ). &quot; issue #163-
IF lo_range IS BOUND. &quot;ins issue #235 - repeat rows/cols
lo_range-&gt;name = ls_range-name.
lo_range-&gt;set_range_value( lv_range_value ).
ENDIF. &quot;ins issue #235 - repeat rows/cols
lo_node ?= lo_node-&gt;get_next( ).
ENDWHILE.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Loads worksheet" EXPOSURE="1" STATE="1" EDITORDER="13 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET" SCONAME="IP_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_worksheet.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Header/footer
*
* Please don&apos;t just delete these ToDos if they are not
* needed but leave a comment that states this
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker,
* - ...
* changes: renaming variables to naming conventions
* aligning code (started)
* add a list of open ToDos here
* adding comments to explain what we are trying to achieve (started)
*--------------------------------------------------------------------*
* issue #345 - Dump on small pagemargins
* Took the chance to modularize this very long method
* by extracting the code that needed correction into
* own method ( load_worksheet_pagemargins )
*--------------------------------------------------------------------*
TYPES: BEGIN OF lty_cell,
r TYPE string,
t TYPE string,
s TYPE string,
END OF lty_cell.
TYPES: BEGIN OF lty_column,
min TYPE string,
max TYPE string,
width TYPE float,
customwidth TYPE string,
style TYPE string,
bestfit TYPE string,
collapsed TYPE string,
hidden TYPE string,
outlinelevel TYPE string,
END OF lty_column.
TYPES: BEGIN OF lty_sheetview,
showgridlines TYPE zexcel_show_gridlines,
tabselected TYPE string,
zoomscalenormal TYPE string,
workbookviewid TYPE string,
showrowcolheaders TYPE string,
END OF lty_sheetview.
TYPES: BEGIN OF lty_mergecell,
ref TYPE string,
END OF lty_mergecell.
TYPES: BEGIN OF lty_row,
r TYPE string,
customheight TYPE string,
ht TYPE float,
spans TYPE string,
thickbot TYPE string,
customformat TYPE string,
thicktop TYPE string,
collapsed TYPE string,
hidden TYPE string,
outlinelevel TYPE string,
END OF lty_row.
TYPES: BEGIN OF lty_page_setup,
id TYPE string,
orientation TYPE string,
scale TYPE string,
fittoheight TYPE string,
fittowidth TYPE string,
END OF lty_page_setup.
TYPES: BEGIN OF lty_sheetformatpr,
customheight TYPE string,
defaultrowheight TYPE string,
customwidth TYPE string,
defaultcolwidth TYPE string,
END OF lty_sheetformatpr.
TYPES: BEGIN OF lty_headerfooter,
alignwithmargins TYPE string,
differentoddeven TYPE string,
END OF lty_headerfooter.
TYPES: BEGIN OF lty_tabcolor,
rgb TYPE string,
theme TYPE string,
END OF lty_tabcolor.
TYPES: BEGIN OF lty_datavalidation,
type TYPE zexcel_data_val_type,
allowblank TYPE flag,
showinputmessage TYPE flag,
showerrormessage TYPE flag,
showdropdown TYPE flag,
operator TYPE zexcel_data_val_operator,
formula1 TYPE zexcel_validation_formula1,
formula2 TYPE zexcel_validation_formula1,
sqref TYPE string,
cell_column TYPE zexcel_cell_column_alpha,
cell_column_to TYPE zexcel_cell_column_alpha,
cell_row TYPE zexcel_cell_row,
cell_row_to TYPE zexcel_cell_row,
error TYPE string,
errortitle TYPE string,
prompt TYPE string,
prompttitle TYPE string,
errorstyle TYPE zexcel_data_val_error_style,
END OF lty_datavalidation.
CONSTANTS: lc_xml_attr_true TYPE string VALUE &apos;true&apos;,
lc_xml_attr_true_int TYPE string VALUE &apos;1&apos;,
lc_rel_drawing TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing&apos;,
lc_rel_hyperlink TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink&apos;,
lc_rel_printer TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings&apos;.
DATA: lo_ixml_worksheet TYPE REF TO if_ixml_document,
lo_ixml_cells TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml_iterator2 TYPE REF TO if_ixml_node_iterator,
lo_ixml_row_elem TYPE REF TO if_ixml_element,
lo_ixml_cell_elem TYPE REF TO if_ixml_element,
ls_cell TYPE lty_cell,
lv_index TYPE i,
lo_ixml_value_elem TYPE REF TO if_ixml_element,
lo_ixml_formula_elem TYPE REF TO if_ixml_element,
lv_cell_value TYPE zexcel_cell_value,
lv_cell_formula TYPE zexcel_cell_formula,
lv_cell_column TYPE zexcel_cell_column_alpha,
lv_cell_row TYPE zexcel_cell_row,
lo_excel_style TYPE REF TO zcl_excel_style,
lv_style_guid TYPE zexcel_cell_style,
lo_ixml_imension_elem TYPE REF TO if_ixml_element, &quot;#+234
lv_dimension_range TYPE string, &quot;#+234
lo_ixml_sheetview_elem TYPE REF TO if_ixml_element,
ls_sheetview TYPE lty_sheetview,
lo_ixml_pane_elem TYPE REF TO if_ixml_element,
ls_excel_pane TYPE zexcel_pane,
lv_pane_cell_row TYPE zexcel_cell_row,
lv_pane_cell_col_a TYPE zexcel_cell_column_alpha,
lv_pane_cell_col TYPE zexcel_cell_column,
lo_ixml_mergecells TYPE REF TO if_ixml_node_collection,
lo_ixml_mergecell_elem TYPE REF TO if_ixml_element,
ls_mergecell TYPE lty_mergecell,
lv_merge_column_start TYPE zexcel_cell_column_alpha,
lv_merge_column_end TYPE zexcel_cell_column_alpha,
lv_merge_row_start TYPE zexcel_cell_row,
lv_merge_row_end TYPE zexcel_cell_row,
lo_ixml_sheetformatpr_elem TYPE REF TO if_ixml_element,
ls_sheetformatpr TYPE lty_sheetformatpr,
lv_height TYPE float,
lo_ixml_headerfooter_elem TYPE REF TO if_ixml_element,
ls_headerfooter TYPE lty_headerfooter,
ls_odd_header TYPE zexcel_s_worksheet_head_foot,
ls_odd_footer TYPE zexcel_s_worksheet_head_foot,
ls_even_header TYPE zexcel_s_worksheet_head_foot,
ls_even_footer TYPE zexcel_s_worksheet_head_foot,
lo_ixml_hf_value_elem TYPE REF TO if_ixml_element,
lo_ixml_pagesetup_elem TYPE REF TO if_ixml_element,
lo_ixml_sheetpr TYPE REF TO if_ixml_element,
lv_fit_to_page TYPE string,
ls_pagesetup TYPE lty_page_setup,
lo_ixml_columns TYPE REF TO if_ixml_node_collection,
lo_ixml_column_elem TYPE REF TO if_ixml_element,
ls_column TYPE lty_column,
lv_column_alpha TYPE zexcel_cell_column_alpha,
lo_column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
lv_outline_level TYPE int4,
lo_ixml_tabcolor TYPE REF TO if_ixml_element,
ls_tabcolor TYPE lty_tabcolor,
ls_excel_s_tabcolor TYPE zexcel_s_tabcolor,
lo_ixml_rows TYPE REF TO if_ixml_node_collection,
ls_row TYPE lty_row,
lv_max_col TYPE i, &quot;for use with SPANS element
* lv_min_col TYPE i, &quot;for use with SPANS element &quot; not in use currently
lv_max_col_s TYPE char10, &quot;for use with SPANS element
lv_min_col_s TYPE char10, &quot;for use with SPANS element
lo_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi,
*--- End of current code aligning -------------------------------------------------------------------
lv_path TYPE string,
lo_ixml_node TYPE REF TO if_ixml_element,
ls_relationship TYPE t_relationship,
lo_ixml_rels_worksheet TYPE REF TO if_ixml_document,
lv_rels_worksheet_path TYPE string,
lv_stripped_name TYPE chkfile,
lv_dirname TYPE string,
lt_external_hyperlinks TYPE gtt_external_hyperlinks,
ls_external_hyperlink LIKE LINE OF lt_external_hyperlinks,
lo_ixml_datavalidations TYPE REF TO if_ixml_node_collection,
lo_ixml_datavalidation_elem TYPE REF TO if_ixml_element,
ls_datavalidation TYPE lty_datavalidation,
lo_data_validation TYPE REF TO zcl_excel_data_validation,
lv_datavalidation_range TYPE string,
lt_datavalidation_range TYPE TABLE OF string.
*--------------------------------------------------------------------*
* §2 We need to read the the file &quot;\\_rels\.rels&quot; because it tells
* us where in this folder structure the data for the workbook
* is located in the xlsx zip-archive
*
* The xlsx Zip-archive has generally the following folder structure:
* &lt;root&gt; |
* |--&gt; _rels
* |--&gt; doc_Props
* |--&gt; xl |
* |--&gt; _rels
* |--&gt; theme
* |--&gt; worksheets
*--------------------------------------------------------------------*
&quot; Read Workbook Relationships
CALL FUNCTION &apos;TRINT_SPLIT_FILE_AND_PATH&apos;
EXPORTING
full_name = ip_path
IMPORTING
stripped_name = lv_stripped_name
file_path = lv_dirname.
CONCATENATE lv_dirname &apos;_rels/&apos; lv_stripped_name &apos;.rels&apos;
INTO lv_rels_worksheet_path.
TRY. &quot; +#222 _rels/xxx.rels might not be present. If not found there can be no drawings --&gt; just ignore this section
lo_ixml_rels_worksheet = me-&gt;get_ixml_from_zip_archive( lv_rels_worksheet_path ).
lo_ixml_node ?= lo_ixml_rels_worksheet-&gt;find_from_name( &apos;Relationship&apos; ).
CATCH zcx_excel. &quot;#EC NO_HANDLER +#222
&quot; +#222 No errorhandling necessary - node will be unbound if error occurs
ENDTRY. &quot; +#222
WHILE lo_ixml_node IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_node
CHANGING
cp_structure = ls_relationship ).
CONCATENATE lv_dirname ls_relationship-target INTO lv_path.
lv_path = resolve_path( lv_path ).
CASE ls_relationship-type.
WHEN lc_rel_drawing.
&quot; Read Drawings
* Issue # 339 Not all drawings are in the path mentioned below.
* Some Excel elements like textfields (which we don&apos;t support ) have a drawing-part in the relationsships
* but no &quot;xl/drawings/_rels/drawing____.xml.rels&quot; part.
* Since we don&apos;t support these there is no need to read them. Catching exceptions thrown
* in the &quot;load_worksheet_drawing&quot; shouldn&apos;t lead to an abortion of the reading
TRY.
me-&gt;load_worksheet_drawing( ip_path = lv_path
io_worksheet = io_worksheet ).
CATCH zcx_excel. &quot;--&gt; then ignore it
ENDTRY.
WHEN lc_rel_printer.
&quot; Read Printer settings
WHEN lc_rel_hyperlink.
MOVE-CORRESPONDING ls_relationship TO ls_external_hyperlink.
INSERT ls_external_hyperlink INTO TABLE lt_external_hyperlinks.
WHEN OTHERS.
ENDCASE.
lo_ixml_node ?= lo_ixml_node-&gt;get_next( ).
ENDWHILE.
lo_ixml_worksheet = me-&gt;get_ixml_from_zip_archive( ip_path ).
lo_ixml_tabcolor ?= lo_ixml_worksheet-&gt;find_from_name( &apos;tabColor&apos; ).
IF lo_ixml_tabcolor IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_tabcolor
CHANGING
cp_structure = ls_tabcolor ).
* Theme not supported yet
IF ls_tabcolor-rgb IS NOT INITIAL.
ls_excel_s_tabcolor-rgb = ls_tabcolor-rgb.
io_worksheet-&gt;set_tabcolor( ls_excel_s_tabcolor ).
ENDIF.
ENDIF.
lo_ixml_rows = lo_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;row&apos; ).
lo_ixml_iterator = lo_ixml_rows-&gt;create_iterator( ).
lo_ixml_row_elem ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_row_elem IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_row_elem
CHANGING
cp_structure = ls_row ).
SPLIT ls_row-spans AT &apos;:&apos; INTO lv_min_col_s lv_max_col_s.
lv_index = lv_max_col_s.
IF lv_index &gt; lv_max_col.
lv_max_col = lv_index.
ENDIF.
lv_cell_row = ls_row-r.
IF ls_row-customheight = &apos;1&apos;
OR ls_row-collapsed = lc_xml_attr_true
OR ls_row-collapsed = lc_xml_attr_true_int
OR ls_row-hidden = lc_xml_attr_true
OR ls_row-hidden = lc_xml_attr_true_int
OR ls_row-outlinelevel &gt; &apos;0&apos;.
lo_row_dimension = io_worksheet-&gt;get_row_dimension( lv_cell_row ).
IF ls_row-customheight = &apos;1&apos;.
lo_row_dimension-&gt;set_row_height( ls_row-ht ).
ENDIF.
IF ls_row-collapsed = lc_xml_attr_true
OR ls_row-collapsed = lc_xml_attr_true_int.
lo_row_dimension-&gt;set_collapsed( abap_true ).
ENDIF.
IF ls_row-hidden = lc_xml_attr_true
OR ls_row-hidden = lc_xml_attr_true_int.
lo_row_dimension-&gt;set_visible( abap_false ).
ENDIF.
IF ls_row-outlinelevel &gt; &apos;&apos;.
* outline_level = condense( row-outlineLevel ). &quot;For basis 7.02 and higher
CONDENSE ls_row-outlinelevel.
lv_outline_level = ls_row-outlinelevel.
IF lv_outline_level &gt; 0.
lo_row_dimension-&gt;set_outline_level( lv_outline_level ).
ENDIF.
ENDIF.
ENDIF.
lo_ixml_cells = lo_ixml_row_elem-&gt;get_elements_by_tag_name( name = &apos;c&apos; ).
lo_ixml_iterator2 = lo_ixml_cells-&gt;create_iterator( ).
lo_ixml_cell_elem ?= lo_ixml_iterator2-&gt;get_next( ).
WHILE lo_ixml_cell_elem IS BOUND.
CLEAR: lv_cell_value,
lv_cell_formula,
lv_style_guid.
fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_cell_elem CHANGING cp_structure = ls_cell ).
lo_ixml_value_elem = lo_ixml_cell_elem-&gt;find_from_name( name = &apos;v&apos; ).
CASE ls_cell-t.
WHEN &apos;s&apos;. &quot; String values are stored as index in shared string table
lv_index = lo_ixml_value_elem-&gt;get_value( ) + 1.
READ TABLE shared_strings INTO lv_cell_value INDEX lv_index.
WHEN &apos;inlineStr&apos;. &quot; inlineStr values are kept in special node
lo_ixml_value_elem = lo_ixml_cell_elem-&gt;find_from_name( name = &apos;is&apos; ).
IF lo_ixml_value_elem IS BOUND.
lv_cell_value = lo_ixml_value_elem-&gt;get_value( ).
ENDIF.
WHEN OTHERS. &quot;other types are stored directly
IF lo_ixml_value_elem IS BOUND.
lv_cell_value = lo_ixml_value_elem-&gt;get_value( ).
ENDIF.
ENDCASE.
CLEAR lv_style_guid.
&quot;read style based on index
IF ls_cell-s IS NOT INITIAL.
lv_index = ls_cell-s + 1.
READ TABLE styles INTO lo_excel_style INDEX lv_index.
IF sy-subrc = 0.
lv_style_guid = lo_excel_style-&gt;get_guid( ).
ENDIF.
ENDIF.
lo_ixml_formula_elem = lo_ixml_cell_elem-&gt;find_from_name( name = &apos;f&apos; ).
IF lo_ixml_formula_elem IS BOUND.
lv_cell_formula = lo_ixml_formula_elem-&gt;get_value( ).
*--------------------------------------------------------------------*
* Begin of insertion issue#284 - Copied formulae not
*--------------------------------------------------------------------*
DATA: BEGIN OF ls_formula_attributes,
ref TYPE string,
si TYPE i,
t TYPE string,
END OF ls_formula_attributes,
ls_ref_formula TYPE ty_ref_formulae.
fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_formula_elem CHANGING cp_structure = ls_formula_attributes ).
IF ls_formula_attributes-t = &apos;shared&apos;.
zcl_excel_common=&gt;convert_columnrow2column_a_row( EXPORTING
i_columnrow = ls_cell-r
IMPORTING
e_column = lv_cell_column
e_row = lv_cell_row ).
TRY.
CLEAR ls_ref_formula.
ls_ref_formula-sheet = io_worksheet.
ls_ref_formula-row = lv_cell_row.
ls_ref_formula-column = zcl_excel_common=&gt;convert_column2int( lv_cell_column ).
ls_ref_formula-si = ls_formula_attributes-si.
ls_ref_formula-ref = ls_formula_attributes-ref.
ls_ref_formula-formula = lv_cell_formula.
INSERT ls_ref_formula INTO TABLE me-&gt;mt_ref_formulae.
CATCH cx_root.
BREAK-POINT.
ENDTRY.
ENDIF.
*--------------------------------------------------------------------*
* End of insertion issue#284 - Copied formulae not
*--------------------------------------------------------------------*
ENDIF.
IF lv_cell_value IS NOT INITIAL
OR lv_cell_formula IS NOT INITIAL
OR lv_style_guid IS NOT INITIAL.
zcl_excel_common=&gt;convert_columnrow2column_a_row( EXPORTING
i_columnrow = ls_cell-r
IMPORTING
e_column = lv_cell_column
e_row = lv_cell_row ).
io_worksheet-&gt;set_cell( ip_column = lv_cell_column &quot; cell_elem Column
ip_row = lv_cell_row &quot; cell_elem row_elem
ip_value = lv_cell_value &quot; cell_elem Value
ip_formula = lv_cell_formula
ip_data_type = ls_cell-t
ip_style = lv_style_guid ).
ENDIF.
lo_ixml_cell_elem ?= lo_ixml_iterator2-&gt;get_next( ).
ENDWHILE.
lo_ixml_row_elem ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
*--------------------------------------------------------------------*
*#234 - column width not read correctly - begin of coding
* reason - libre office doesn&apos;t use SPAN in row - definitions
*--------------------------------------------------------------------*
IF lv_max_col = 0.
lo_ixml_imension_elem = lo_ixml_worksheet-&gt;find_from_name( name = &apos;dimension&apos; ).
IF lo_ixml_imension_elem IS BOUND.
lv_dimension_range = lo_ixml_imension_elem-&gt;get_attribute( &apos;ref&apos; ).
IF lv_dimension_range CS &apos;:&apos;.
REPLACE REGEX &apos;\D+\d+:(\D+)\d+&apos; IN lv_dimension_range WITH &apos;$1&apos;. &quot; Get max column
ELSE.
REPLACE REGEX &apos;(\D+)\d+&apos; IN lv_dimension_range WITH &apos;$1&apos;. &quot; Get max column
ENDIF.
lv_max_col = zcl_excel_common=&gt;convert_column2int( lv_dimension_range ).
ENDIF.
ENDIF.
*--------------------------------------------------------------------*
*#234 - column width not read correctly - end of coding
*--------------------------------------------------------------------*
&quot;Get the customized column width
lo_ixml_columns = lo_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;col&apos; ).
lo_ixml_iterator = lo_ixml_columns-&gt;create_iterator( ).
lo_ixml_column_elem ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_column_elem IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_column_elem
CHANGING
cp_structure = ls_column ).
lo_ixml_column_elem ?= lo_ixml_iterator-&gt;get_next( ).
IF ls_column-customwidth = lc_xml_attr_true
OR ls_column-customwidth = lc_xml_attr_true_int
OR ls_column-bestfit = lc_xml_attr_true
OR ls_column-bestfit = lc_xml_attr_true_int
OR ls_column-collapsed = lc_xml_attr_true
OR ls_column-collapsed = lc_xml_attr_true_int
OR ls_column-hidden = lc_xml_attr_true
OR ls_column-hidden = lc_xml_attr_true_int
OR ls_column-outlinelevel &gt; &apos;&apos;
OR ls_column-style &gt; &apos;&apos;.
lv_index = ls_column-min.
WHILE lv_index &lt;= ls_column-max AND lv_index &lt;= lv_max_col.
lv_column_alpha = zcl_excel_common=&gt;convert_column2alpha( lv_index ).
lo_column_dimension = io_worksheet-&gt;get_column_dimension( lv_column_alpha ).
IF ls_column-customwidth = lc_xml_attr_true
OR ls_column-customwidth = lc_xml_attr_true_int
OR ls_column-width IS NOT INITIAL. &quot;+#234
lo_column_dimension-&gt;set_width( ls_column-width ).
ENDIF.
IF ls_column-bestfit = lc_xml_attr_true
OR ls_column-bestfit = lc_xml_attr_true_int.
lo_column_dimension-&gt;set_auto_size( abap_true ).
ENDIF.
IF ls_column-collapsed = lc_xml_attr_true
OR ls_column-collapsed = lc_xml_attr_true_int.
lo_column_dimension-&gt;set_collapsed( abap_true ).
ENDIF.
IF ls_column-hidden = lc_xml_attr_true
OR ls_column-hidden = lc_xml_attr_true_int.
lo_column_dimension-&gt;set_visible( abap_false ).
ENDIF.
IF ls_column-outlinelevel &gt; &apos;&apos;.
* outline_level = condense( column-outlineLevel ).
CONDENSE ls_column-outlinelevel.
lv_outline_level = ls_column-outlinelevel.
IF lv_outline_level &gt; 0.
lo_column_dimension-&gt;set_outline_level( lv_outline_level ).
ENDIF.
ENDIF.
IF ls_column-style &gt; &apos;&apos;.
sy-index = ls_column-style + 1.
READ TABLE styles INTO lo_excel_style INDEX sy-index.
DATA: dummy_zexcel_cell_style TYPE zexcel_cell_style.
dummy_zexcel_cell_style = lo_excel_style-&gt;get_guid( ).
lo_column_dimension-&gt;set_column_style_by_guid( dummy_zexcel_cell_style ).
ENDIF.
ADD 1 TO lv_index.
ENDWHILE.
ENDIF.
* issue #367 - hide columns from
IF ls_column-max = zcl_excel_common=&gt;c_excel_sheet_max_col. &quot; Max = very right column
IF ls_column-hidden = 1 &quot; all hidden
AND ls_column-min &gt; 0.
io_worksheet-&gt;zif_excel_sheet_properties~hide_columns_from = zcl_excel_common=&gt;convert_column2alpha( ls_column-min ).
ELSEIF ls_column-style &gt; &apos;&apos;.
sy-index = ls_column-style + 1.
READ TABLE styles INTO lo_excel_style INDEX sy-index.
dummy_zexcel_cell_style = lo_excel_style-&gt;get_guid( ).
* Set style for remaining columns
io_worksheet-&gt;zif_excel_sheet_properties~set_style( dummy_zexcel_cell_style ).
ENDIF.
ENDIF.
ENDWHILE.
&quot;Now we need to get information from the sheetView node
lo_ixml_sheetview_elem = lo_ixml_worksheet-&gt;find_from_name( name = &apos;sheetView&apos; ).
fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_sheetview_elem CHANGING cp_structure = ls_sheetview ).
IF ls_sheetview-showgridlines IS INITIAL OR
ls_sheetview-showgridlines = lc_xml_attr_true OR
ls_sheetview-showgridlines = lc_xml_attr_true_int.
&quot;If the attribute is not specified or set to true, we will show grid lines
ls_sheetview-showgridlines = abap_true.
ELSE.
ls_sheetview-showgridlines = abap_false.
ENDIF.
io_worksheet-&gt;set_show_gridlines( ls_sheetview-showgridlines ).
&quot;Add merge cell information
lo_ixml_mergecells = lo_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;mergeCell&apos; ).
lo_ixml_iterator = lo_ixml_mergecells-&gt;create_iterator( ).
lo_ixml_mergecell_elem ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_mergecell_elem IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_mergecell_elem
CHANGING
cp_structure = ls_mergecell ).
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING
i_range = ls_mergecell-ref
IMPORTING
e_column_start = lv_merge_column_start
e_column_end = lv_merge_column_end
e_row_start = lv_merge_row_start
e_row_end = lv_merge_row_end ).
lo_ixml_mergecell_elem ?= lo_ixml_iterator-&gt;get_next( ).
io_worksheet-&gt;set_merge( EXPORTING
ip_column_start = lv_merge_column_start
ip_column_end = lv_merge_column_end
ip_row = lv_merge_row_start
ip_row_to = lv_merge_row_end ).
ENDWHILE.
&quot; read sheet format properties
lo_ixml_sheetformatpr_elem = lo_ixml_worksheet-&gt;find_from_name( &apos;sheetFormatPr&apos; ).
IF lo_ixml_sheetformatpr_elem IS NOT INITIAL.
fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_sheetformatpr_elem CHANGING cp_structure = ls_sheetformatpr ).
IF ls_sheetformatpr-customheight = &apos;1&apos;.
lv_height = ls_sheetformatpr-defaultrowheight.
lo_row_dimension = io_worksheet-&gt;get_default_row_dimension( ).
lo_row_dimension-&gt;set_row_height( lv_height ).
ENDIF.
&quot; TODO... column
ENDIF.
&quot; Read in page margins
me-&gt;load_worksheet_pagemargins( EXPORTING
io_ixml_worksheet = lo_ixml_worksheet
io_worksheet = io_worksheet ).
* FitToPage
lo_ixml_sheetpr ?= lo_ixml_worksheet-&gt;find_from_name( &apos;pageSetUpPr&apos; ).
IF lo_ixml_sheetpr IS BOUND.
lv_fit_to_page = lo_ixml_sheetpr-&gt;get_attribute_ns( &apos;fitToPage&apos; ).
IF lv_fit_to_page IS NOT INITIAL.
io_worksheet-&gt;sheet_setup-&gt;fit_to_page = &apos;X&apos;.
ENDIF.
ENDIF.
&quot; Read in page setup
lo_ixml_pagesetup_elem = lo_ixml_worksheet-&gt;find_from_name( &apos;pageSetup&apos; ).
IF lo_ixml_pagesetup_elem IS NOT INITIAL.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_pagesetup_elem
CHANGING
cp_structure = ls_pagesetup ).
io_worksheet-&gt;sheet_setup-&gt;orientation = ls_pagesetup-orientation.
io_worksheet-&gt;sheet_setup-&gt;scale = ls_pagesetup-scale.
IF io_worksheet-&gt;sheet_setup-&gt;fit_to_page = &apos;X&apos;.
IF ls_pagesetup-fittowidth IS NOT INITIAL.
io_worksheet-&gt;sheet_setup-&gt;fit_to_width = ls_pagesetup-fittowidth.
ELSE.
io_worksheet-&gt;sheet_setup-&gt;fit_to_width = 1. &quot; Default if not given - Excel doesn&apos;t write this to xml
ENDIF.
IF ls_pagesetup-fittoheight IS NOT INITIAL.
io_worksheet-&gt;sheet_setup-&gt;fit_to_height = ls_pagesetup-fittoheight.
ELSE.
io_worksheet-&gt;sheet_setup-&gt;fit_to_height = 1. &quot; Default if not given - Excel doesn&apos;t write this to xml
ENDIF.
ENDIF.
ENDIF.
&quot; Read header footer
lo_ixml_headerfooter_elem = lo_ixml_worksheet-&gt;find_from_name( &apos;headerFooter&apos; ).
IF lo_ixml_headerfooter_elem IS NOT INITIAL.
fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_headerfooter_elem CHANGING cp_structure = ls_headerfooter ).
io_worksheet-&gt;sheet_setup-&gt;diff_oddeven_headerfooter = ls_headerfooter-differentoddeven.
lo_ixml_hf_value_elem = lo_ixml_headerfooter_elem-&gt;find_from_name( &apos;oddFooter&apos; ).
IF lo_ixml_hf_value_elem IS NOT INITIAL.
ls_odd_footer-left_value = lo_ixml_hf_value_elem-&gt;get_value( ).
ENDIF.
* 2do§1 Header/footer
&quot; TODO.. get the rest.
io_worksheet-&gt;sheet_setup-&gt;set_header_footer( ip_odd_header = ls_odd_header
ip_odd_footer = ls_odd_footer
ip_even_header = ls_even_header
ip_even_footer = ls_even_footer ).
ENDIF.
&quot; Start fix 194 Read attributes HIDDEN, OUTLINELEVEL, COLLAPSED in ZCL_EXCEL_READER_2007
&quot; Read pane
lo_ixml_pane_elem = lo_ixml_sheetview_elem-&gt;find_from_name( name = &apos;pane&apos; ).
IF lo_ixml_pane_elem IS BOUND.
fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_pane_elem CHANGING cp_structure = ls_excel_pane ).
&quot; Issue #194
&quot; Replace REGEX with method from the common class
zcl_excel_common=&gt;convert_columnrow2column_a_row( EXPORTING
i_columnrow = ls_excel_pane-topleftcell
IMPORTING
e_column = lv_pane_cell_col_a &quot; Cell Column
e_row = lv_pane_cell_row ). &quot; Natural number
lv_pane_cell_col = zcl_excel_common=&gt;convert_column2int( lv_pane_cell_col_a ).
SUBTRACT 1 FROM: lv_pane_cell_col,
lv_pane_cell_row.
IF lv_pane_cell_col &gt; 0
AND lv_pane_cell_row &gt; 0.
io_worksheet-&gt;freeze_panes( ip_num_rows = lv_pane_cell_row
ip_num_columns = lv_pane_cell_col ).
ELSEIF lv_pane_cell_row &gt; 0.
io_worksheet-&gt;freeze_panes( ip_num_rows = lv_pane_cell_row ).
ELSE.
io_worksheet-&gt;freeze_panes( ip_num_columns = lv_pane_cell_col ).
ENDIF.
ENDIF.
&quot; End fix 194 Read attributes HIDDEN, OUTLINELEVEL, COLLAPSED in ZCL_EXCEL_READER_2007
&quot; Start fix 276 Read data validations
lo_ixml_datavalidations = lo_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;dataValidation&apos; ).
lo_ixml_iterator = lo_ixml_datavalidations-&gt;create_iterator( ).
lo_ixml_datavalidation_elem ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_datavalidation_elem IS BOUND.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_datavalidation_elem
CHANGING
cp_structure = ls_datavalidation ).
CLEAR lo_ixml_formula_elem.
lo_ixml_formula_elem = lo_ixml_datavalidation_elem-&gt;find_from_name( name = &apos;formula1&apos; ).
IF lo_ixml_formula_elem IS BOUND.
ls_datavalidation-formula1 = lo_ixml_formula_elem-&gt;get_value( ).
ENDIF.
CLEAR lo_ixml_formula_elem.
lo_ixml_formula_elem = lo_ixml_datavalidation_elem-&gt;find_from_name( name = &apos;formula2&apos; ).
IF lo_ixml_formula_elem IS BOUND.
ls_datavalidation-formula2 = lo_ixml_formula_elem-&gt;get_value( ).
ENDIF.
SPLIT ls_datavalidation-sqref AT space INTO TABLE lt_datavalidation_range.
LOOP AT lt_datavalidation_range INTO lv_datavalidation_range.
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING
i_range = lv_datavalidation_range
IMPORTING
e_column_start = ls_datavalidation-cell_column
e_column_end = ls_datavalidation-cell_column_to
e_row_start = ls_datavalidation-cell_row
e_row_end = ls_datavalidation-cell_row_to ).
lo_data_validation = io_worksheet-&gt;add_new_data_validation( ).
lo_data_validation-&gt;type = ls_datavalidation-type.
lo_data_validation-&gt;allowblank = ls_datavalidation-allowblank.
IF ls_datavalidation-showinputmessage IS INITIAL.
lo_data_validation-&gt;showinputmessage = abap_false.
ELSE.
lo_data_validation-&gt;showinputmessage = abap_true.
ENDIF.
IF ls_datavalidation-showerrormessage IS INITIAL.
lo_data_validation-&gt;showerrormessage = abap_false.
ELSE.
lo_data_validation-&gt;showerrormessage = abap_true.
ENDIF.
IF ls_datavalidation-showdropdown IS INITIAL.
lo_data_validation-&gt;showdropdown = abap_false.
ELSE.
lo_data_validation-&gt;showdropdown = abap_true.
ENDIF.
lo_data_validation-&gt;operator = ls_datavalidation-operator.
lo_data_validation-&gt;formula1 = ls_datavalidation-formula1.
lo_data_validation-&gt;formula2 = ls_datavalidation-formula2.
lo_data_validation-&gt;prompttitle = ls_datavalidation-prompttitle.
lo_data_validation-&gt;prompt = ls_datavalidation-prompt.
lo_data_validation-&gt;errortitle = ls_datavalidation-errortitle.
lo_data_validation-&gt;error = ls_datavalidation-error.
lo_data_validation-&gt;errorstyle = ls_datavalidation-errorstyle.
lo_data_validation-&gt;cell_row = ls_datavalidation-cell_row.
lo_data_validation-&gt;cell_row_to = ls_datavalidation-cell_row_to.
lo_data_validation-&gt;cell_column = ls_datavalidation-cell_column.
lo_data_validation-&gt;cell_column_to = ls_datavalidation-cell_column_to.
ENDLOOP.
lo_ixml_datavalidation_elem ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
&quot; End fix 276 Read data validations
&quot; Read hyperlinks
TRY.
me-&gt;load_worksheet_hyperlinks( io_ixml_worksheet = lo_ixml_worksheet
io_worksheet = io_worksheet
it_external_hyperlinks = lt_external_hyperlinks ).
CATCH zcx_excel. &quot; Ignore Hyperlink reading errors - pass everything we were able to identify
ENDTRY.
TRY.
me-&gt;fill_row_outlines( io_worksheet = io_worksheet ).
CATCH zcx_excel. &quot; Ignore Hyperlink reading errors - pass everything we were able to identify
ENDTRY.
&quot; Issue #366 - conditional formatting
TRY.
me-&gt;load_worksheet_cond_format( io_ixml_worksheet = lo_ixml_worksheet
io_worksheet = io_worksheet ).
CATCH zcx_excel. &quot; Ignore Hyperlink reading errors - pass everything we were able to identify
ENDTRY.
&quot; Issue #377 - pagebreaks
TRY.
me-&gt;load_worksheet_pagebreaks( io_ixml_worksheet = lo_ixml_worksheet
io_worksheet = io_worksheet ).
CATCH zcx_excel. &quot; Ignore pagebreak reading errors - pass everything we were able to identify
ENDTRY.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formattings" EXPOSURE="1" STATE="1" EDITORDER="14 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT" SCONAME="IO_IXML_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="XML Document in DOM Representation" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_worksheet_cond_format.
DATA: lo_ixml_cond_formats TYPE REF TO if_ixml_node_collection,
lo_ixml_cond_format TYPE REF TO if_ixml_element,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml_rules TYPE REF TO if_ixml_node_collection,
lo_ixml_rule TYPE REF TO if_ixml_element,
lo_ixml_iterator2 TYPE REF TO if_ixml_node_iterator,
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
lo_style_conditional2 TYPE REF TO zcl_excel_style_conditional.
DATA: lv_area TYPE string,
lt_areas TYPE STANDARD TABLE OF string WITH NON-UNIQUE DEFAULT KEY,
lv_area_start_row TYPE zexcel_cell_row,
lv_area_end_row TYPE zexcel_cell_row,
lv_area_start_col TYPE zexcel_cell_column_alpha,
lv_area_end_col TYPE zexcel_cell_column_alpha,
lv_rule TYPE zexcel_condition_rule.
* FIELD-SYMBOLS: &lt;ls_external_hyperlink&gt; LIKE LINE OF it_external_hyperlinks.
lo_ixml_cond_formats = io_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;conditionalFormatting&apos; ).
lo_ixml_iterator = lo_ixml_cond_formats-&gt;create_iterator( ).
lo_ixml_cond_format ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_cond_format IS BOUND.
CLEAR: lv_area,
lo_ixml_rule,
lo_style_conditional.
*--------------------------------------------------------------------*
* Get type of rule
*--------------------------------------------------------------------*
lo_ixml_rules = io_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;cfRule&apos; ).
lo_ixml_iterator2 = lo_ixml_rules-&gt;create_iterator( ).
lo_ixml_rule ?= lo_ixml_iterator2-&gt;get_next( ).
* IF lo_ixml_rule IS BOUND.
WHILE lo_ixml_rule IS BOUND.
lv_rule = lo_ixml_rule-&gt;get_attribute_ns( &apos;type&apos; ).
CLEAR lo_style_conditional.
*--------------------------------------------------------------------*
* Depending on ruletype get additional information
*--------------------------------------------------------------------*
CASE lv_rule.
WHEN zcl_excel_style_conditional=&gt;c_rule_cellis.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_ci( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
* WHEN zcl_excel_style_conditional=&gt;c_rule_containstext.
*
WHEN zcl_excel_style_conditional=&gt;c_rule_databar.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_db( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
WHEN zcl_excel_style_conditional=&gt;c_rule_expression.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_ex( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
WHEN zcl_excel_style_conditional=&gt;c_rule_iconset.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_is( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
WHEN zcl_excel_style_conditional=&gt;c_rule_colorscale.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_cs( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
WHEN zcl_excel_style_conditional=&gt;c_rule_top10.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_t10( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
WHEN zcl_excel_style_conditional=&gt;c_rule_above_average.
lo_style_conditional = io_worksheet-&gt;add_new_conditional_style( ).
load_worksheet_cond_format_aa( io_ixml_rule = lo_ixml_rule
io_style_conditional = lo_style_conditional ).
* WHEN zcl_excel_style_conditional=&gt;c_rule_none.
*
WHEN OTHERS.
ENDCASE.
* ENDIF.
IF lo_style_conditional IS BOUND.
lo_style_conditional-&gt;rule = lv_rule.
lo_style_conditional-&gt;priority = lo_ixml_rule-&gt;get_attribute_ns( &apos;priority&apos; ).
*--------------------------------------------------------------------*
* Set area to which conditional formatting belongs
*--------------------------------------------------------------------*
lv_area = lo_ixml_cond_format-&gt;get_attribute_ns( &apos;sqref&apos; ).
SPLIT lv_area AT space INTO TABLE lt_areas.
DELETE lt_areas WHERE table_line IS INITIAL.
LOOP AT lt_areas INTO lv_area.
* IF sy-tabix = 1. &quot; Add futher style for next area
* lo_style_conditional2 = lo_style_conditional.
* ELSE.
* lo_style_conditional2 = io_worksheet-&gt;add_new_conditional_style( ).
* lo_style_conditional2-&gt;mode_cellis = lo_style_conditional-&gt;mode_cellis .
* lo_style_conditional2-&gt;mode_colorscale = lo_style_conditional-&gt;mode_colorscale .
* lo_style_conditional2-&gt;mode_databar = lo_style_conditional-&gt;mode_databar .
* lo_style_conditional2-&gt;mode_expression = lo_style_conditional-&gt;mode_expression .
* lo_style_conditional2-&gt;mode_iconset = lo_style_conditional-&gt;mode_iconset .
* lo_style_conditional2-&gt;mode_top10 = lo_style_conditional-&gt;mode_top10 .
* lo_style_conditional2-&gt;mode_above_average = lo_style_conditional-&gt;mode_above_average.
* lo_style_conditional2-&gt;priority = lo_style_conditional-&gt;priority .
* lo_style_conditional2-&gt;rule = lo_style_conditional-&gt;rule .
* ENDIF.
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING
i_range = lv_area
IMPORTING
e_column_start = lv_area_start_col
e_column_end = lv_area_end_col
e_row_start = lv_area_start_row
e_row_end = lv_area_end_row ).
* lo_style_conditional2-&gt;set_range( ip_start_column = lv_area_start_col
* ip_stop_column = lv_area_end_col
* ip_start_row = lv_area_start_row
* ip_stop_row = lv_area_end_row ).
lo_style_conditional-&gt;add_range( ip_start_column = lv_area_start_col
ip_stop_column = lv_area_end_col
ip_start_row = lv_area_start_row
ip_stop_row = lv_area_end_row ).
ENDLOOP.
ENDIF.
lo_ixml_rule ?= lo_ixml_iterator2-&gt;get_next( ).
ENDWHILE.
lo_ixml_cond_format ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_AA" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type above average" EXPOSURE="1" STATE="1" EDITORDER="15 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_AA" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_AA" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_aa.
DATA: lv_dxf_style_index TYPE i,
val TYPE string.
FIELD-SYMBOLS: &lt;ls_dxf_style&gt; LIKE LINE OF me-&gt;mt_dxf_styles.
*--------------------------------------------------------------------*
* above or below average
*--------------------------------------------------------------------*
val = io_ixml_rule-&gt;get_attribute_ns( &apos;aboveAverage&apos; ).
IF val = &apos;0&apos;. &quot; 0 = below average
io_style_conditional-&gt;mode_above_average-above_average = space.
ELSE.
io_style_conditional-&gt;mode_above_average-above_average = &apos;X&apos;. &quot; Not present or &lt;&gt; 0 --&gt; we use above average
ENDIF.
*--------------------------------------------------------------------*
* Equal average also?
*--------------------------------------------------------------------*
CLEAR val.
val = io_ixml_rule-&gt;get_attribute_ns( &apos;equalAverage&apos; ).
IF val = &apos;1&apos;. &quot; 0 = below average
io_style_conditional-&gt;mode_above_average-equal_average = &apos;X&apos;.
ELSE.
io_style_conditional-&gt;mode_above_average-equal_average = &apos; &apos;. &quot; Not present or &lt;&gt; 1 --&gt; we use not equal average
ENDIF.
*--------------------------------------------------------------------*
* Standard deviation instead of value ( 2nd stddev, 3rd stdev )
*--------------------------------------------------------------------*
CLEAR val.
val = io_ixml_rule-&gt;get_attribute_ns( &apos;stdDev&apos; ).
CASE val.
WHEN 1
OR 2
OR 3. &quot; These seem to be supported by excel - don&apos;t try anything more
io_style_conditional-&gt;mode_above_average-standard_deviation = val.
ENDCASE.
*--------------------------------------------------------------------*
* Cell formatting for top10
*--------------------------------------------------------------------*
lv_dxf_style_index = io_ixml_rule-&gt;get_attribute_ns( &apos;dxfId&apos; ).
READ TABLE me-&gt;mt_dxf_styles ASSIGNING &lt;ls_dxf_style&gt; WITH KEY dxf = lv_dxf_style_index.
IF sy-subrc = 0.
io_style_conditional-&gt;mode_above_average-cell_style = &lt;ls_dxf_style&gt;-guid.
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_CI" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type cellIs" EXPOSURE="1" STATE="1" EDITORDER="16 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_CI" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_CI" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_ci.
DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml TYPE REF TO if_ixml_element,
lv_dxf_style_index TYPE i,
lo_excel_style LIKE LINE OF me-&gt;styles.
FIELD-SYMBOLS: &lt;ls_dxf_style&gt; LIKE LINE OF me-&gt;mt_dxf_styles.
io_style_conditional-&gt;mode_cellis-operator = io_ixml_rule-&gt;get_attribute_ns( &apos;operator&apos; ).
lv_dxf_style_index = io_ixml_rule-&gt;get_attribute_ns( &apos;dxfId&apos; ).
READ TABLE me-&gt;mt_dxf_styles ASSIGNING &lt;ls_dxf_style&gt; WITH KEY dxf = lv_dxf_style_index.
IF sy-subrc = 0.
io_style_conditional-&gt;mode_cellis-cell_style = &lt;ls_dxf_style&gt;-guid.
ENDIF.
lo_ixml_nodes ?= io_ixml_rule-&gt;get_elements_by_tag_name( &apos;formula&apos; ).
lo_ixml_iterator = lo_ixml_nodes-&gt;create_iterator( ).
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml IS BOUND.
CASE sy-index.
WHEN 1.
io_style_conditional-&gt;mode_cellis-formula = lo_ixml-&gt;get_value( ).
WHEN 2.
io_style_conditional-&gt;mode_cellis-formula2 = lo_ixml-&gt;get_value( ).
WHEN OTHERS.
EXIT.
ENDCASE.
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_CS" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type colorscale" EXPOSURE="1" STATE="1" EDITORDER="17 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_CS" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_CS" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_cs.
DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml TYPE REF TO if_ixml_element.
lo_ixml_nodes ?= io_ixml_rule-&gt;get_elements_by_tag_name( &apos;cfvo&apos; ).
lo_ixml_iterator = lo_ixml_nodes-&gt;create_iterator( ).
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml IS BOUND.
CASE sy-index.
WHEN 1.
io_style_conditional-&gt;mode_colorscale-cfvo1_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_colorscale-cfvo1_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 2.
io_style_conditional-&gt;mode_colorscale-cfvo2_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_colorscale-cfvo2_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 3.
io_style_conditional-&gt;mode_colorscale-cfvo3_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_colorscale-cfvo2_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN OTHERS.
EXIT.
ENDCASE.
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
lo_ixml_nodes ?= io_ixml_rule-&gt;get_elements_by_tag_name( &apos;color&apos; ).
lo_ixml_iterator = lo_ixml_nodes-&gt;create_iterator( ).
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml IS BOUND.
CASE sy-index.
WHEN 1.
io_style_conditional-&gt;mode_colorscale-colorrgb1 = lo_ixml-&gt;get_attribute_ns( &apos;rgb&apos; ).
WHEN 2.
io_style_conditional-&gt;mode_colorscale-colorrgb2 = lo_ixml-&gt;get_attribute_ns( &apos;rgb&apos; ).
WHEN 3.
io_style_conditional-&gt;mode_colorscale-colorrgb3 = lo_ixml-&gt;get_attribute_ns( &apos;rgb&apos; ).
WHEN OTHERS.
EXIT.
ENDCASE.
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_DB" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type databar" EXPOSURE="1" STATE="1" EDITORDER="20 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_DB" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_DB" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_db.
DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml TYPE REF TO if_ixml_element.
lo_ixml ?= io_ixml_rule-&gt;find_from_name( &apos;color&apos; ).
IF lo_ixml IS BOUND.
io_style_conditional-&gt;mode_databar-colorrgb = lo_ixml-&gt;get_attribute_ns( &apos;rgb&apos; ).
ENDIF.
lo_ixml_nodes ?= io_ixml_rule-&gt;get_elements_by_tag_name( &apos;cfvo&apos; ).
lo_ixml_iterator = lo_ixml_nodes-&gt;create_iterator( ).
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml IS BOUND.
CASE sy-index.
WHEN 1.
io_style_conditional-&gt;mode_databar-cfvo1_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_databar-cfvo1_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 2.
io_style_conditional-&gt;mode_databar-cfvo2_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_databar-cfvo2_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN OTHERS.
EXIT.
ENDCASE.
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_EX" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type expression" EXPOSURE="1" STATE="1" EDITORDER="18 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_EX" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_EX" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_ex.
DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml TYPE REF TO if_ixml_element,
lv_dxf_style_index TYPE i,
lo_excel_style LIKE LINE OF me-&gt;styles.
FIELD-SYMBOLS: &lt;ls_dxf_style&gt; LIKE LINE OF me-&gt;mt_dxf_styles.
lv_dxf_style_index = io_ixml_rule-&gt;get_attribute_ns( &apos;dxfId&apos; ).
READ TABLE me-&gt;mt_dxf_styles ASSIGNING &lt;ls_dxf_style&gt; WITH KEY dxf = lv_dxf_style_index.
IF sy-subrc = 0.
io_style_conditional-&gt;mode_expression-cell_style = &lt;ls_dxf_style&gt;-guid.
ENDIF.
lo_ixml_nodes ?= io_ixml_rule-&gt;get_elements_by_tag_name( &apos;formula&apos; ).
lo_ixml_iterator = lo_ixml_nodes-&gt;create_iterator( ).
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml IS BOUND.
CASE sy-index.
WHEN 1.
io_style_conditional-&gt;mode_expression-formula = lo_ixml-&gt;get_value( ).
WHEN OTHERS.
EXIT.
ENDCASE.
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_IS" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type iconset" EXPOSURE="1" STATE="1" EDITORDER="19 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_IS" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_IS" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_is.
DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml TYPE REF TO if_ixml_element,
lo_ixml_rule_iconset TYPE REF TO if_ixml_element.
lo_ixml_rule_iconset ?= io_ixml_rule-&gt;get_first_child( ).
io_style_conditional-&gt;mode_iconset-iconset = lo_ixml_rule_iconset-&gt;get_attribute_ns( &apos;iconSet&apos; ).
io_style_conditional-&gt;mode_iconset-showvalue = lo_ixml_rule_iconset-&gt;get_attribute_ns( &apos;showValue&apos; ).
lo_ixml_nodes ?= lo_ixml_rule_iconset-&gt;get_elements_by_tag_name( &apos;cfvo&apos; ).
lo_ixml_iterator = lo_ixml_nodes-&gt;create_iterator( ).
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml IS BOUND.
CASE sy-index.
WHEN 1.
io_style_conditional-&gt;mode_iconset-cfvo1_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_iconset-cfvo1_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 2.
io_style_conditional-&gt;mode_iconset-cfvo2_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_iconset-cfvo2_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 3.
io_style_conditional-&gt;mode_iconset-cfvo3_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_iconset-cfvo3_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 4.
io_style_conditional-&gt;mode_iconset-cfvo4_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_iconset-cfvo4_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN 5.
io_style_conditional-&gt;mode_iconset-cfvo5_type = lo_ixml-&gt;get_attribute_ns( &apos;type&apos; ).
io_style_conditional-&gt;mode_iconset-cfvo5_value = lo_ixml-&gt;get_attribute_ns( &apos;val&apos; ).
WHEN OTHERS.
EXIT.
ENDCASE.
lo_ixml ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_T10" VERSION="1" LANGU="E" DESCRIPT="Load worksheet&apos;s conditional formatting - type top10" EXPOSURE="1" STATE="1" EDITORDER="21 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_T10" SCONAME="IO_IXML_RULE" VERSION="1" LANGU="E" DESCRIPT="Element of an XML Document" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_COND_FORMAT_T10" SCONAME="IO_STYLE_CONDITIONAL" VERSION="1" LANGU="E" DESCRIPT="Font Style" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLE_CONDITIONAL"/>
<source>METHOD load_worksheet_cond_format_t10.
DATA: lv_dxf_style_index TYPE i.
FIELD-SYMBOLS: &lt;ls_dxf_style&gt; LIKE LINE OF me-&gt;mt_dxf_styles.
io_style_conditional-&gt;mode_top10-topxx_count = io_ixml_rule-&gt;get_attribute_ns( &apos;rank&apos; ). &quot; Top10, Top20, Top 50...
io_style_conditional-&gt;mode_top10-percent = io_ixml_rule-&gt;get_attribute_ns( &apos;percent&apos; ). &quot; Top10 percent instead of Top10 values
if io_style_conditional-&gt;mode_top10-percent = &apos;1&apos;.
io_style_conditional-&gt;mode_top10-percent = &apos;X&apos;.
else.
io_style_conditional-&gt;mode_top10-percent = &apos; &apos;.
endif.
io_style_conditional-&gt;mode_top10-bottom = io_ixml_rule-&gt;get_attribute_ns( &apos;bottom&apos; ). &quot; Bottom10 instead of Top10
if io_style_conditional-&gt;mode_top10-bottom = &apos;1&apos;.
io_style_conditional-&gt;mode_top10-bottom = &apos;X&apos;.
else.
io_style_conditional-&gt;mode_top10-bottom = &apos; &apos;.
endif.
*--------------------------------------------------------------------*
* Cell formatting for top10
*--------------------------------------------------------------------*
lv_dxf_style_index = io_ixml_rule-&gt;get_attribute_ns( &apos;dxfId&apos; ).
READ TABLE me-&gt;mt_dxf_styles ASSIGNING &lt;ls_dxf_style&gt; WITH KEY dxf = lv_dxf_style_index.
IF sy-subrc = 0.
io_style_conditional-&gt;mode_top10-cell_style = &lt;ls_dxf_style&gt;-guid.
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_DRAWING" VERSION="1" LANGU="E" DESCRIPT="Loads worksheet drawings" EXPOSURE="1" STATE="1" EDITORDER="22 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_DRAWING" SCONAME="IP_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_DRAWING" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_DRAWING" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>method LOAD_WORKSHEET_DRAWING.
TYPES: BEGIN OF t_c_nv_pr,
name TYPE string,
id TYPE string,
END OF t_c_nv_pr.
TYPES: BEGIN OF t_blip,
cstate TYPE string,
embed TYPE string,
END OF t_blip.
TYPES: BEGIN OF t_chart,
id TYPE string,
END OF t_chart.
CONSTANTS: lc_xml_attr_true TYPE string VALUE &apos;true&apos;,
lc_xml_attr_true_int TYPE string VALUE &apos;1&apos;.
CONSTANTS: lc_rel_chart TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart&apos;,
lc_rel_image TYPE string VALUE &apos;http://schemas.openxmlformats.org/officeDocument/2006/relationships/image&apos;.
DATA: drawing TYPE REF TO if_ixml_document,
anchors TYPE REF TO if_ixml_node_collection,
node TYPE REF TO if_ixml_element,
coll_length TYPE i,
iterator TYPE REF TO if_ixml_node_iterator,
anchor_elem TYPE REF TO if_ixml_element,
relationship TYPE t_relationship,
rel_drawings TYPE t_rel_drawings,
rel_drawing TYPE t_rel_drawing,
rels_drawing TYPE REF TO if_ixml_document,
rels_drawing_path TYPE string,
stripped_name TYPE chkfile,
dirname TYPE string,
path TYPE string,
path2 TYPE text255,
file_ext2 TYPE char10.
&quot; Read Workbook Relationships
CALL FUNCTION &apos;TRINT_SPLIT_FILE_AND_PATH&apos;
EXPORTING
full_name = ip_path
IMPORTING
stripped_name = stripped_name
file_path = dirname.
CONCATENATE dirname &apos;_rels/&apos; stripped_name &apos;.rels&apos;
INTO rels_drawing_path.
rels_drawing_path = resolve_path( rels_drawing_path ).
rels_drawing = me-&gt;get_ixml_from_zip_archive( rels_drawing_path ).
node ?= rels_drawing-&gt;find_from_name( &apos;Relationship&apos; ).
WHILE node IS BOUND.
fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = relationship ).
rel_drawing-id = relationship-id.
CONCATENATE dirname relationship-target INTO path.
path = resolve_path( path ).
rel_drawing-content = me-&gt;get_from_zip_archive( path ). &quot;------------&gt; This is for template usage
path2 = path.
zcl_excel_common=&gt;split_file( EXPORTING ip_file = path2
IMPORTING ep_extension = file_ext2 ).
rel_drawing-file_ext = file_ext2.
&quot;-------------Added by Alessandro Iannacci - Should load graph xml
CASE relationship-type.
WHEN lc_rel_chart.
&quot;Read chart xml
rel_drawing-content_xml = me-&gt;get_ixml_from_zip_archive( path ).
WHEN OTHERS.
ENDCASE.
&quot;----------------------------
APPEND rel_drawing TO rel_drawings.
node ?= node-&gt;get_next( ).
ENDWHILE.
drawing = me-&gt;get_ixml_from_zip_archive( ip_path ).
* one-cell anchor **************
anchors = drawing-&gt;get_elements_by_tag_name( name = &apos;oneCellAnchor&apos; namespace = &apos;xdr&apos; ).
coll_length = anchors-&gt;get_length( ).
iterator = anchors-&gt;create_iterator( ).
DO coll_length TIMES.
anchor_elem ?= iterator-&gt;get_next( ).
CALL METHOD me-&gt;load_drawing_anchor
EXPORTING
io_anchor_element = anchor_elem
io_worksheet = io_worksheet
it_related_drawings = rel_drawings.
ENDDO.
* two-cell anchor ******************
anchors = drawing-&gt;get_elements_by_tag_name( name = &apos;twoCellAnchor&apos; namespace = &apos;xdr&apos; ).
coll_length = anchors-&gt;get_length( ).
iterator = anchors-&gt;create_iterator( ).
DO coll_length TIMES.
anchor_elem ?= iterator-&gt;get_next( ).
CALL METHOD me-&gt;load_drawing_anchor
EXPORTING
io_anchor_element = anchor_elem
io_worksheet = io_worksheet
it_related_drawings = rel_drawings.
ENDDO.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_HYPERLINKS" VERSION="1" LANGU="E" DESCRIPT="Loads hyperlinks of worksheet" EXPOSURE="1" STATE="1" EDITORDER="23 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_HYPERLINKS" SCONAME="IO_IXML_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="XML Document in DOM Representation" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_HYPERLINKS" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_HYPERLINKS" SCONAME="IT_EXTERNAL_HYPERLINKS" VERSION="1" LANGU="E" DESCRIPT="Table with external hyperlinks" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="GTT_EXTERNAL_HYPERLINKS"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_HYPERLINKS" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_worksheet_hyperlinks.
DATA: lo_ixml_hyperlinks TYPE REF TO if_ixml_node_collection,
lo_ixml_hyperlink TYPE REF TO if_ixml_element,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lv_row TYPE zexcel_cell_row,
lv_column TYPE zexcel_cell_column_alpha,
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
lv_value TYPE zexcel_cell_value.
DATA: BEGIN OF ls_hyperlink,
ref TYPE string,
display TYPE string,
location TYPE string,
tooltip TYPE string,
r_id TYPE string,
END OF ls_hyperlink.
FIELD-SYMBOLS: &lt;ls_external_hyperlink&gt; LIKE LINE OF it_external_hyperlinks.
lo_ixml_hyperlinks = io_ixml_worksheet-&gt;get_elements_by_tag_name( name = &apos;hyperlink&apos; ).
lo_ixml_iterator = lo_ixml_hyperlinks-&gt;create_iterator( ).
lo_ixml_hyperlink ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_hyperlink IS BOUND.
CLEAR ls_hyperlink.
CLEAR lo_hyperlink.
ls_hyperlink-ref = lo_ixml_hyperlink-&gt;get_attribute_ns( &apos;ref&apos; ).
ls_hyperlink-display = lo_ixml_hyperlink-&gt;get_attribute_ns( &apos;display&apos; ).
ls_hyperlink-location = lo_ixml_hyperlink-&gt;get_attribute_ns( &apos;location&apos; ).
ls_hyperlink-tooltip = lo_ixml_hyperlink-&gt;get_attribute_ns( &apos;tooltip&apos; ).
ls_hyperlink-r_id = lo_ixml_hyperlink-&gt;get_attribute( name = &apos;id&apos;
namespace = &apos;r&apos; ).
IF ls_hyperlink-r_id IS INITIAL. &quot; Internal link
lo_hyperlink = zcl_excel_hyperlink=&gt;create_internal_link( iv_location = ls_hyperlink-location ).
ELSE. &quot; External link
READ TABLE it_external_hyperlinks ASSIGNING &lt;ls_external_hyperlink&gt; WITH TABLE KEY id = ls_hyperlink-r_id.
IF sy-subrc = 0.
lo_hyperlink = zcl_excel_hyperlink=&gt;create_external_link( iv_url = &lt;ls_external_hyperlink&gt;-target ).
ENDIF.
ENDIF.
IF lo_hyperlink IS BOUND. &quot; because of unsupported external links
zcl_excel_common=&gt;convert_columnrow2column_a_row( EXPORTING
i_columnrow = ls_hyperlink-ref
IMPORTING
e_row = lv_row
e_column = lv_column ).
* Currently it is not allowed to pass a hyperlink w/o text, but text has already been read.
* So just reread it and be done with it
io_worksheet-&gt;get_cell( EXPORTING
ip_column = lv_column
ip_row = lv_row
IMPORTING
ep_value = lv_value ).
io_worksheet-&gt;set_cell( ip_column = lv_column
ip_row = lv_row
ip_value = lv_value
ip_hyperlink = lo_hyperlink ).
ENDIF.
lo_ixml_hyperlink ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEBREAKS" VERSION="1" LANGU="E" DESCRIPT="Load pagebreaks of worksheet" EXPOSURE="1" STATE="1" EDITORDER="24 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEBREAKS" SCONAME="IO_IXML_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="XML Document in DOM Representation" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEBREAKS" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEBREAKS" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_worksheet_pagebreaks.
DATA: lo_node TYPE REF TO if_ixml_element,
lo_ixml_rowbreaks TYPE REF TO if_ixml_node_collection,
lo_ixml_colbreaks TYPE REF TO if_ixml_node_collection,
lo_ixml_iterator TYPE REF TO if_ixml_node_iterator,
lo_ixml_rowbreak TYPE REF TO if_ixml_element,
lo_ixml_colbreak TYPE REF TO if_ixml_element,
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
lv_count TYPE i.
DATA: lt_pagebreaks TYPE STANDARD TABLE OF zcl_excel_worksheet_pagebreaks=&gt;ts_pagebreak_at,
lo_pagebreaks TYPE REF TO zcl_excel_worksheet_pagebreaks.
FIELD-SYMBOLS: &lt;ls_pagebreak_row&gt; LIKE LINE OF lt_pagebreaks.
FIELD-SYMBOLS: &lt;ls_pagebreak_col&gt; LIKE LINE OF lt_pagebreaks.
*--------------------------------------------------------------------*
* Get minimal number of cells where to add pagebreaks
* Since rows and columns are handled in separate nodes
* Build table to identify these cells
*--------------------------------------------------------------------*
lo_node ?= io_ixml_worksheet-&gt;find_from_name( &apos;rowBreaks&apos; ).
check lo_node is bound.
lo_ixml_rowbreaks = lo_node-&gt;get_elements_by_tag_name( name = &apos;brk&apos; ).
lo_ixml_iterator = lo_ixml_rowbreaks-&gt;create_iterator( ).
lo_ixml_rowbreak ?= lo_ixml_iterator-&gt;get_next( ).
WHILE lo_ixml_rowbreak IS BOUND.
APPEND INITIAL LINE TO lt_pagebreaks ASSIGNING &lt;ls_pagebreak_row&gt;.
&lt;ls_pagebreak_row&gt;-cell_row = lo_ixml_rowbreak-&gt;get_attribute_ns( &apos;id&apos; ).
lo_ixml_rowbreak ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
CHECK &lt;ls_pagebreak_row&gt; IS ASSIGNED.
lo_node ?= io_ixml_worksheet-&gt;find_from_name( &apos;colBreaks&apos; ).
check lo_node is bound.
lo_ixml_colbreaks = lo_node-&gt;get_elements_by_tag_name( name = &apos;brk&apos; ).
lo_ixml_iterator = lo_ixml_colbreaks-&gt;create_iterator( ).
lo_ixml_colbreak ?= lo_ixml_iterator-&gt;get_next( ).
CLEAR lv_count.
WHILE lo_ixml_colbreak IS BOUND.
ADD 1 TO lv_count.
READ TABLE lt_pagebreaks INDEX lv_count ASSIGNING &lt;ls_pagebreak_col&gt;.
IF sy-subrc &lt;&gt; 0.
APPEND INITIAL LINE TO lt_pagebreaks ASSIGNING &lt;ls_pagebreak_col&gt;.
&lt;ls_pagebreak_col&gt;-cell_row = &lt;ls_pagebreak_row&gt;-cell_row.
ENDIF.
&lt;ls_pagebreak_col&gt;-cell_column = lo_ixml_colbreak-&gt;get_attribute_ns( &apos;id&apos; ).
lo_ixml_colbreak ?= lo_ixml_iterator-&gt;get_next( ).
ENDWHILE.
*--------------------------------------------------------------------*
* Finally add each pagebreak
*--------------------------------------------------------------------*
lo_pagebreaks = io_worksheet-&gt;get_pagebreaks( ).
LOOP AT lt_pagebreaks ASSIGNING &lt;ls_pagebreak_row&gt;.
lo_pagebreaks-&gt;add_pagebreak( ip_column = &lt;ls_pagebreak_row&gt;-cell_column
ip_row = &lt;ls_pagebreak_row&gt;-cell_row ).
ENDLOOP.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEMARGINS" VERSION="1" LANGU="E" DESCRIPT="Loads pagemargings of worksheet" EXPOSURE="1" STATE="1" EDITORDER="25 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEMARGINS" SCONAME="IO_IXML_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="XML Document in DOM Representation" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_DOCUMENT"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEMARGINS" SCONAME="IO_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEET"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET_PAGEMARGINS" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD load_worksheet_pagemargins.
TYPES: BEGIN OF lty_page_margins,
footer TYPE string,
header TYPE string,
bottom TYPE string,
top TYPE string,
right TYPE string,
left TYPE string,
END OF lty_page_margins.
DATA:lo_ixml_pagemargins_elem TYPE REF TO if_ixml_element,
ls_pagemargins TYPE lty_page_margins.
lo_ixml_pagemargins_elem = io_ixml_worksheet-&gt;find_from_name( &apos;pageMargins&apos; ).
IF lo_ixml_pagemargins_elem IS NOT INITIAL.
fill_struct_from_attributes( EXPORTING
ip_element = lo_ixml_pagemargins_elem
CHANGING
cp_structure = ls_pagemargins ).
io_worksheet-&gt;sheet_setup-&gt;margin_bottom = zcl_excel_common=&gt;excel_string_to_number( ls_pagemargins-bottom ).
io_worksheet-&gt;sheet_setup-&gt;margin_footer = zcl_excel_common=&gt;excel_string_to_number( ls_pagemargins-footer ).
io_worksheet-&gt;sheet_setup-&gt;margin_header = zcl_excel_common=&gt;excel_string_to_number( ls_pagemargins-header ).
io_worksheet-&gt;sheet_setup-&gt;margin_left = zcl_excel_common=&gt;excel_string_to_number( ls_pagemargins-left ).
io_worksheet-&gt;sheet_setup-&gt;margin_right = zcl_excel_common=&gt;excel_string_to_number( ls_pagemargins-right ).
io_worksheet-&gt;sheet_setup-&gt;margin_top = zcl_excel_common=&gt;excel_string_to_number( ls_pagemargins-top ).
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_APPLSERVER" VERSION="1" LANGU="E" DESCRIPT="Load excel data from appserver" EXPOSURE="0" STATE="1" EDITORDER="2 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_APPLSERVER" SCONAME="I_FILENAME" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="CSEQUENCE"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_APPLSERVER" SCONAME="R_EXCEL_DATA" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<source>METHOD read_from_applserver.
DATA: lv_filelength TYPE i,
lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY,
ls_binary_data LIKE LINE OF lt_binary_data,
lv_filename TYPE string,
lv_max_length_line TYPE i,
lv_actual_length_line TYPE i,
lv_errormessage TYPE string.
MOVE i_filename TO lv_filename.
DESCRIBE FIELD ls_binary_data LENGTH lv_max_length_line IN BYTE MODE.
OPEN DATASET lv_filename FOR INPUT IN BINARY MODE.
IF sy-subrc &lt;&gt; 0.
lv_errormessage = &apos;A problem occured when reading the file&apos;(001).
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDIF.
WHILE sy-subrc = 0.
READ DATASET lv_filename INTO ls_binary_data MAXIMUM LENGTH lv_max_length_line ACTUAL LENGTH lv_actual_length_line.
APPEND ls_binary_data TO lt_binary_data.
lv_filelength = lv_filelength + lv_actual_length_line.
ENDWHILE.
CLOSE DATASET lv_filename.
*--------------------------------------------------------------------*
* Binary data needs to be provided as XSTRING for further processing
*--------------------------------------------------------------------*
CALL FUNCTION &apos;SCMS_BINARY_TO_XSTRING&apos;
EXPORTING
input_length = lv_filelength
IMPORTING
buffer = r_excel_data
TABLES
binary_tab = lt_binary_data.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_LOCAL_FILE" VERSION="1" LANGU="E" DESCRIPT="Load excel data from local file" EXPOSURE="0" STATE="1" EDITORDER="3 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_LOCAL_FILE" SCONAME="I_FILENAME" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="CSEQUENCE"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_LOCAL_FILE" SCONAME="R_EXCEL_DATA" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="XSTRING"/>
<exception CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="READ_FROM_LOCAL_FILE" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
<source>METHOD read_from_local_file.
DATA: lv_filelength TYPE i,
lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY,
ls_binary_data LIKE LINE OF lt_binary_data,
lv_filename TYPE string,
lv_errormessage TYPE string.
MOVE i_filename TO lv_filename.
cl_gui_frontend_services=&gt;gui_upload( EXPORTING
filename = lv_filename
filetype = &apos;BIN&apos; &quot; We are basically working with zipped directories --&gt; force binary read
IMPORTING
filelength = lv_filelength
CHANGING
data_tab = lt_binary_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19 ).
IF sy-subrc &lt;&gt; 0.
lv_errormessage = &apos;A problem occured when reading the file&apos;(001).
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_errormessage.
ENDIF.
*--------------------------------------------------------------------*
* Binary data needs to be provided as XSTRING for further processing
*--------------------------------------------------------------------*
CALL FUNCTION &apos;SCMS_BINARY_TO_XSTRING&apos;
EXPORTING
input_length = lv_filelength
IMPORTING
buffer = r_excel_data
TABLES
binary_tab = lt_binary_data.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="RESOLVE_PATH" VERSION="1" LANGU="E" DESCRIPT="Return path after ../ values are removed" EXPOSURE="1" STATE="1" EDITORDER="26 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="1" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="RESOLVE_PATH" SCONAME="IP_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="RESOLVE_PATH" SCONAME="RP_RESULT" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="STRING"/>
<source>method RESOLVE_PATH.
*--------------------------------------------------------------------*
* ToDos:
* 2do§1 Determine whether the replacement should be done
* iterative to allow /../../.. or something alike
* 2do§2 Determine whether /./ has to be supported as well
* 2do§3 Create unit-test for this method
*
* Please don&apos;t just delete these ToDos if they are not
* needed but leave a comment that states this
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
* - Stefan Schmoecker, (done) 2012-11-11
* - ...
* changes: replaced previous coding by regular expression
* adding comments to explain what we are trying to achieve
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* §1 This routine will receive a path, that may have a relative pathname (/../) included somewhere
* The output should be a resolved path without relative references
* Example: Input xl/worksheets/../drawings/drawing1.xml
* Output xl/drawings/drawing1.xml
*--------------------------------------------------------------------*
rp_result = ip_path.
*--------------------------------------------------------------------*
* §1 Remove relative pathnames
*--------------------------------------------------------------------*
* Regular expression [^/]*/\.\./
* [^/]* --&gt; any number of characters other than /
* followed by /\.\./ --&gt; the sequence /../
* ==&gt; worksheets/../ will be found in the example
*--------------------------------------------------------------------*
REPLACE REGEX &apos;[^/]*/\.\./&apos; IN rp_result WITH ``.
endmethod.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="RESOLVE_REFERENCED_FORMULAE" VERSION="1" LANGU="E" DESCRIPT="Resolve referenced formulae" EXPOSURE="1" STATE="1" EDITORDER="27 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>method RESOLVE_REFERENCED_FORMULAE.
TYPES: BEGIN OF ty_referenced_cells,
sheet TYPE REF TO zcl_excel_worksheet,
si TYPE i,
row_from TYPE i,
row_to TYPE i,
col_from TYPE i,
col_to TYPE i,
formula TYPE string,
ref_cell TYPE char10,
END OF ty_referenced_cells.
DATA: ls_ref_formula LIKE LINE OF me-&gt;mt_ref_formulae,
lts_referenced_cells TYPE SORTED TABLE OF ty_referenced_cells WITH NON-UNIQUE KEY sheet si row_from row_to col_from col_to,
ls_referenced_cell LIKE LINE OF lts_referenced_cells,
lv_col_from TYPE zexcel_cell_column_alpha,
lv_col_to TYPE zexcel_cell_column_alpha,
lv_resulting_formula TYPE string,
lv_current_cell TYPE char10.
me-&gt;mt_ref_formulae = me-&gt;mt_ref_formulae.
*--------------------------------------------------------------------*
* Get referenced Cells, Build ranges for easy lookup
*--------------------------------------------------------------------*
LOOP AT me-&gt;mt_ref_formulae INTO ls_ref_formula WHERE ref &lt;&gt; space.
CLEAR ls_referenced_cell.
ls_referenced_cell-sheet = ls_ref_formula-sheet.
ls_referenced_cell-si = ls_ref_formula-si.
ls_referenced_cell-formula = ls_ref_formula-formula.
TRY.
zcl_excel_common=&gt;convert_range2column_a_row( EXPORTING i_range = ls_ref_formula-ref
IMPORTING e_column_start = lv_col_from
e_column_end = lv_col_to
e_row_start = ls_referenced_cell-row_from
e_row_end = ls_referenced_cell-row_to ).
ls_referenced_cell-col_from = zcl_excel_common=&gt;convert_column2int( lv_col_from ).
ls_referenced_cell-col_to = zcl_excel_common=&gt;convert_column2int( lv_col_to ).
CLEAR ls_referenced_cell-ref_cell.
TRY.
ls_referenced_cell-ref_cell(3) = zcl_excel_common=&gt;convert_column2alpha( ls_ref_formula-column ).
ls_referenced_cell-ref_cell+3 = ls_ref_formula-row.
CONDENSE ls_referenced_cell-ref_cell NO-GAPS.
CATCH zcx_excel.
ENDTRY.
INSERT ls_referenced_cell INTO TABLE lts_referenced_cells.
CATCH zcx_excel.
ENDTRY.
ENDLOOP.
* break x0009004.
*--------------------------------------------------------------------*
* For each referencing cell determine the referenced cell
* and resolve the formula
*--------------------------------------------------------------------*
LOOP AT me-&gt;mt_ref_formulae INTO ls_ref_formula WHERE ref = space.
CLEAR lv_current_cell.
TRY.
lv_current_cell(3) = zcl_excel_common=&gt;convert_column2alpha( ls_ref_formula-column ).
lv_current_cell+3 = ls_ref_formula-row.
CONDENSE lv_current_cell NO-GAPS.
CATCH zcx_excel.
ENDTRY.
LOOP AT lts_referenced_cells INTO ls_referenced_cell WHERE sheet = ls_ref_formula-sheet
AND si = ls_ref_formula-si
AND row_from &lt;= ls_ref_formula-row
AND row_to &gt;= ls_ref_formula-row
AND col_from &lt;= ls_ref_formula-column
AND col_to &gt;= ls_ref_formula-column.
TRY.
lv_resulting_formula = zcl_excel_common=&gt;determine_resulting_formula( iv_reference_cell = ls_referenced_cell-ref_cell
iv_reference_formula = ls_referenced_cell-formula
iv_current_cell = lv_current_cell ).
ls_referenced_cell-sheet-&gt;set_cell_formula( ip_column = ls_ref_formula-column
ip_row = ls_ref_formula-row
ip_formula = lv_resulting_formula ).
CATCH zcx_excel.
ENDTRY.
EXIT.
ENDLOOP.
ENDLOOP.
endmethod.</source>
</method>
</CLAS>