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

162 lines
7.7 KiB
XML

<?xml version="1.0" encoding="utf-16"?>
<CLAS CLSNAME="ZCL_EXCEL_READER_XLSM" VERSION="1" LANGU="E" DESCRIPT="Excel with macro reader" UUID="0202322174CD1EE0A390E386CB9ED10B" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="FEMIA" CREATEDON="20110601" CHANGEDON="20110602" CHGDANYON="00000000" CLSFINAL="X" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="702" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 " REFCLSNAME="ZCL_EXCEL_READER_2007" CHANGEDBY="FEMIA">
<publicSection>class ZCL_EXCEL_READER_XLSM definition
public
inheriting from ZCL_EXCEL_READER_2007
final
create public .
public section.
*&quot;* public components of class ZCL_EXCEL_READER_XLSM
*&quot;* do not include other source files here!!!</publicSection>
<protectedSection>protected section.
*&quot;* protected components of class ZCL_EXCEL_READER_XLSM
*&quot;* do not include other source files here!!!
methods LOAD_WORKBOOK
redefinition .
methods LOAD_WORKSHEET
redefinition .</protectedSection>
<privateSection>private section.
*&quot;* private components of class ZCL_EXCEL_READER_XLSM
*&quot;* do not include other source files here!!!
methods LOAD_VBAPROJECT
importing
!IP_PATH type STRING
!IP_EXCEL type ref to ZCL_EXCEL .</privateSection>
<localImplementation>*&quot;* use this source file for the definition and implementation of
*&quot;* local helper classes, interface definitions and type
*&quot;* declarations</localImplementation>
<localTypes>*&quot;* use this source file for any type of declarations (class
*&quot;* definitions, interfaces or type declarations) you need for
*&quot;* components in the private section</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<inheritance CLSNAME="ZCL_EXCEL_READER_XLSM" REFCLSNAME="ZCL_EXCEL_READER_2007" VERSION="1" STATE="1" AUTHOR="FEMIA" CREATEDON="20110601" CHANGEDBY="FEMIA" CHANGEDON="20110602">
<redefinition CLSNAME="ZCL_EXCEL_READER_XLSM" REFCLSNAME="ZCL_EXCEL_READER_2007" VERSION="1" MTDNAME="LOAD_WORKBOOK" EXPOSURE="1"/>
<redefinition CLSNAME="ZCL_EXCEL_READER_XLSM" REFCLSNAME="ZCL_EXCEL_READER_2007" VERSION="1" MTDNAME="LOAD_WORKSHEET" EXPOSURE="1"/>
</inheritance>
<method CLSNAME="ZCL_EXCEL_READER_XLSM" CMPNAME="LOAD_VBAPROJECT" VERSION="1" LANGU="E" DESCRIPT="Load VBA binary" EXPOSURE="0" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110601" CHANGEDBY="FEMIA" CHANGEDON="20110602" MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_READER_XLSM" CMPNAME="LOAD_VBAPROJECT" SCONAME="IP_PATH" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110601" CHANGEDBY="FEMIA" CHANGEDON="20110602" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING"/>
<parameter CLSNAME="ZCL_EXCEL_READER_XLSM" CMPNAME="LOAD_VBAPROJECT" SCONAME="IP_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Excel creator" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="FEMIA" CREATEDON="20110601" CHANGEDBY="FEMIA" CHANGEDON="20110602" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="ZCL_EXCEL"/>
<source>METHOD load_vbaproject.
DATA lv_content TYPE xstring.
lv_content = me-&gt;get_from_zip_archive( ip_path ).
ip_excel-&gt;zif_excel_book_vba_project~set_vbaproject( lv_content ).
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKBOOK" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>METHOD load_workbook.
super-&gt;load_workbook( EXPORTING ip_path = ip_path
ip_excel = ip_excel ).
CONSTANTS: lc_vba_project TYPE string VALUE &apos;http://schemas.microsoft.com/office/2006/relationships/vbaProject&apos;.
DATA: rels_workbook_path TYPE string,
rels_workbook TYPE REF TO if_ixml_document,
path TYPE string,
node TYPE REF TO if_ixml_element,
workbook TYPE REF TO if_ixml_document,
stripped_name TYPE chkfile,
dirname TYPE string,
relationship TYPE t_relationship,
fileversion TYPE t_fileversion,
workbookPr TYPE t_workbookPr.
FIELD-SYMBOLS: &lt;worksheet&gt; TYPE t_relationship.
CALL FUNCTION &apos;TRINT_SPLIT_FILE_AND_PATH&apos;
EXPORTING
full_name = ip_path
IMPORTING
stripped_name = stripped_name
file_path = dirname.
&quot; Read Workbook Relationships
CONCATENATE dirname &apos;_rels/&apos; stripped_name &apos;.rels&apos;
INTO rels_workbook_path.
rels_workbook = me-&gt;get_ixml_from_zip_archive( rels_workbook_path ).
node ?= rels_workbook-&gt;find_from_name( &apos;Relationship&apos; ).
WHILE node IS BOUND.
me-&gt;fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = relationship ).
CASE relationship-type.
WHEN lc_vba_project.
&quot; Read VBA binary
CONCATENATE dirname relationship-target INTO path.
me-&gt;load_vbaproject( ip_path = path
ip_excel = ip_excel ).
WHEN OTHERS.
ENDCASE.
node ?= node-&gt;get_next( ).
ENDWHILE.
&quot; Read Workbook codeName
workbook = me-&gt;get_ixml_from_zip_archive( ip_path ).
node ?= workbook-&gt;find_from_name( &apos;fileVersion&apos; ).
IF node IS BOUND.
fill_struct_from_attributes( EXPORTING ip_element = node
CHANGING cp_structure = fileversion ).
ip_excel-&gt;zif_excel_book_vba_project~set_codename( fileversion-codename ).
ENDIF.
&quot; Read Workbook codeName
workbook = me-&gt;get_ixml_from_zip_archive( ip_path ).
node ?= workbook-&gt;find_from_name( &apos;workbookPr&apos; ).
IF node IS BOUND.
fill_struct_from_attributes( EXPORTING ip_element = node
CHANGING cp_structure = workbookPr ).
ip_excel-&gt;zif_excel_book_vba_project~set_codename_pr( workbookPr-codename ).
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_READER_2007" CMPNAME="LOAD_WORKSHEET" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>METHOD load_worksheet.
super-&gt;load_worksheet( EXPORTING ip_path = ip_path
io_worksheet = io_worksheet ).
DATA: path TYPE string,
node TYPE REF TO if_ixml_element,
worksheet TYPE REF TO if_ixml_document,
sheetPr TYPE t_sheetPr.
* &quot; Read Workbook codeName
* workbook = me-&gt;get_ixml_from_zip_archive( ip_path ).
* node ?= workbook-&gt;find_from_name( &apos;fileVersion&apos; ).
* IF node IS BOUND.
*
* fill_struct_from_attributes( EXPORTING ip_element = node
* CHANGING cp_structure = fileversion ).
*
* IO_WORKSHEET-&gt;zif_excel_book_vba_project~set_codename( fileversion-codename ).
* ENDIF.
&quot; Read Workbook codeName
worksheet = me-&gt;get_ixml_from_zip_archive( ip_path ).
node ?= worksheet-&gt;find_from_name( &apos;sheetPr&apos; ).
IF node IS BOUND.
fill_struct_from_attributes( EXPORTING ip_element = node
CHANGING cp_structure = sheetpr ).
io_worksheet-&gt;zif_excel_sheet_vba_project~set_codename_pr( sheetpr-codename ).
ENDIF.
ENDMETHOD.</source>
</method>
</CLAS>