From cd1f087bd871f56b87b8381ad42dbd85c4dcda56 Mon Sep 17 00:00:00 2001 From: Rene Turnheim Date: Wed, 29 Aug 2012 01:09:48 +0000 Subject: [PATCH] Fixed #206 issue; Minor issues resolved because of method calls direct on return values. This is not supported in 7.00. git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@333 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL.slnk | 161 ++++++++++++++------------- ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk | 150 ++++++++++++++----------- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 149 +++++++++++++------------ 3 files changed, 245 insertions(+), 215 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL.slnk b/ZA2X/CLAS/ZCL_EXCEL.slnk index 6cf48e2..1d36207 100644 --- a/ZA2X/CLAS/ZCL_EXCEL.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL.slnk @@ -1,8 +1,8 @@ - + - - - + + + class ZCL_EXCEL definition public final @@ -249,17 +249,17 @@ CLASS zcl_tc_excel IMPLEMENTATION. ENDCLASS. "zcl_Tc_Excel - + - - - - - - - - - + + + + + + + + + method ZIF_EXCEL_BOOK_PROPERTIES~INITIALIZE. DATA: lv_timestamp TYPE timestampl. @@ -299,18 +299,18 @@ endmethod. me->zif_excel_book_vba_project~vbaproject = ip_vbaproject. endmethod. - - - + + + method ADD_NEW_AUTOFILTER. * Check for autofilter reference: new or overwrite; only one per sheet ro_autofilter = autofilters->add( io_sheet = io_sheet ) . endmethod. - + - - + + method ADD_NEW_DRAWING. DATA: lv_guid TYPE guid_16. * Create default blank worksheet @@ -327,17 +327,17 @@ endmethod. ENDCASE. endmethod. - - + + method ADD_NEW_RANGE. * Create default blank range CREATE OBJECT eo_range. ranges->add( eo_range ). endmethod. - - - + + + method ADD_NEW_STYLE. * Start of deletion # issue 139 - Dateretention of cellstyles * CREATE OBJECT eo_style. @@ -359,10 +359,10 @@ endmethod. endmethod. - - - - + + + + method ADD_NEW_WORKSHEET. DATA: lv_guid TYPE guid_16. * Create default blank worksheet @@ -374,7 +374,7 @@ endmethod. worksheets->active_worksheet = worksheets->size( ). endmethod. - + method ADD_STATIC_STYLES. " # issue 139 * sp#ƒÂ¤ter hier noch die Worksheets abklappern, welche Styles #ƒÂ#berhaupt noch ben#ƒÂ#tigt werden @@ -399,7 +399,7 @@ endmethod. ENDLOOP. endmethod. - + method CONSTRUCTOR. DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_style TYPE REF TO zcl_excel_style. @@ -428,37 +428,37 @@ endmethod. endmethod. - - + + method GET_ACTIVE_SHEET_INDEX. r_active_worksheet = me->worksheets->active_worksheet. endmethod. - - + + method GET_ACTIVE_WORKSHEET. eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). endmethod. - - + + method GET_AUTOFILTERS_REFERENCE. ro_autofilters = autofilters. endmethod. - - + + method GET_DEFAULT_STYLE. ep_style = me->default_style. endmethod. - + - + method GET_DRAWINGS_ITERATOR. CASE ip_type. @@ -471,8 +471,8 @@ endmethod. endmethod. - - + + method GET_NEXT_TABLE_ID. DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_iterator TYPE REF TO cl_object_collection_iterator, @@ -491,18 +491,18 @@ endmethod. endmethod. - - + + method GET_RANGES_ITERATOR. eo_iterator = me->ranges->get_iterator( ). endmethod. - - - - + + + + method GET_STATIC_CELLSTYLE_GUID. " # issue 139 DATA: style LIKE LINE OF me->t_stylemapping1. @@ -525,18 +525,18 @@ endmethod. ep_guid = style-guid. endmethod. - - + + method GET_STYLES_ITERATOR. eo_iterator = me->styles->get_iterator( ). endmethod. - - - - + + + + method GET_STYLE_INDEX_IN_STYLES. DATA: index TYPE syindex. DATA: lo_iterator TYPE REF TO cl_object_collection_iterator, @@ -564,10 +564,10 @@ endmethod. ENDIF. endmethod. - - - - + + + + method GET_STYLE_TO_GUID. " # issue 139 @@ -587,24 +587,24 @@ endmethod. endmethod. - - + + method GET_WORKSHEETS_ITERATOR. eo_iterator = me->worksheets->get_iterator( ). endmethod. - - + + method GET_WORKSHEETS_NAME. ep_name = me->worksheets->name. endmethod. - - + + method GET_WORKSHEETS_SIZE. ep_size = me->worksheets->size( ). @@ -614,11 +614,14 @@ endmethod. - method GET_WORKSHEET_BY_NAME. + METHOD get_worksheet_by_name. - DATA: lv_index TYPE zexcel_active_worksheet. + DATA: lv_index TYPE zexcel_active_worksheet, + l_size TYPE i. - DO get_worksheets_size( ) TIMES. + l_size = get_worksheets_size( ). + + DO l_size TIMES. lv_index = sy-index. eo_worksheet = me->worksheets->get( lv_index ). IF eo_worksheet->get_title( ) = ip_sheet_name. @@ -628,16 +631,16 @@ endmethod. CLEAR eo_worksheet. -endmethod. +ENDMETHOD. - - + + method SET_ACTIVE_SHEET_INDEX. me->worksheets->active_worksheet = i_active_worksheet. endmethod. - - + + method SET_ACTIVE_SHEET_INDEX_BY_NAME. DATA: ws_it TYPE REF TO cl_object_collection_iterator, @@ -659,16 +662,16 @@ endmethod. endmethod. - - - + + + method SET_DEFAULT_STYLE. me->default_style = ip_style. endmethod. - - - + + + method STYLEMAPPING_DYNAMIC_STYLE. " # issue 139 eo_style2-dynamic_style_guid = ip_style->get_guid( ). diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk index ea23195..3a38168 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk @@ -1,12 +1,12 @@ - + - - - - - - - - - - - - - - - - + class ZCL_EXCEL_READER_2007 definition public create public . @@ -75,9 +75,9 @@ public section. type-pools IXML . interfaces ZIF_EXCEL_READER . - protected section. -*"* protected components of class ZCL_EXCEL_READER_2007 + *"* protected components of class ZCL_EXCEL_READER_2007 *"* do not include other source files here!!! +protected section. types: BEGIN OF t_relationship, @@ -171,7 +171,9 @@ public section. methods LOAD_WORKBOOK importing !IP_PATH type STRING - !IP_EXCEL type ref to ZCL_EXCEL . + !IP_EXCEL type ref to ZCL_EXCEL + raising + ZCX_EXCEL . methods LOAD_DRAWING_ANCHOR importing !IO_ANCHOR_ELEMENT type ref to IF_IXML_ELEMENT @@ -180,18 +182,26 @@ public section. methods LOAD_WORKSHEET importing !IP_PATH type STRING - !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + raising + ZCX_EXCEL . methods LOAD_WORKSHEET_DRAWING importing !IP_PATH type STRING - !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + raising + ZCX_EXCEL . methods LOAD_SHARED_STRINGS importing - !IP_PATH type STRING . + !IP_PATH type STRING + raising + ZCX_EXCEL . methods LOAD_STYLES importing !IP_PATH type STRING - !IP_EXCEL type ref to ZCL_EXCEL . + !IP_EXCEL type ref to ZCL_EXCEL + raising + ZCX_EXCEL . methods LOAD_STYLE_BORDERS importing !IP_XML type ref to IF_IXML_DOCUMENT @@ -235,10 +245,16 @@ public section. *"* in the implementation part of the class IXML - - - - + + + + + + METHOD zif_excel_reader~can_read_file. +* For now always Unknown + r_readable = abap_undefined. +ENDMETHOD. + method ZIF_EXCEL_READER~LOAD. @@ -341,9 +357,9 @@ endmethod. r_excel = me->zif_excel_reader~load( excel_data ). endmethod. - - - + + + method FILL_STRUCT_FROM_ATTRIBUTES. DATA: name TYPE string, attributes TYPE REF TO if_ixml_named_node_map, @@ -368,10 +384,10 @@ endmethod. ENDWHILE. endmethod. - - - - + + + + method GET_FROM_ZIP_ARCHIVE. IF me->zip IS NOT BOUND. @@ -408,10 +424,10 @@ endmethod. endmethod. - - - - + + + + method GET_IXML_FROM_ZIP_ARCHIVE. TYPE-POOLS: ixml. @@ -583,8 +599,9 @@ endmethod. endmethod. - - + + + method LOAD_SHARED_STRINGS. DATA: value TYPE string, shared_strings_xml TYPE REF TO if_ixml_document, @@ -609,9 +626,10 @@ endmethod. endmethod. - - - + + + + method LOAD_STYLES. TYPES: BEGIN OF t_xf, applyalignment TYPE string, @@ -780,9 +798,9 @@ endmethod. endmethod. - - - + + + method LOAD_STYLE_BORDERS. DATA: node TYPE REF TO if_ixml_element, node2 TYPE REF TO if_ixml_element, @@ -852,9 +870,9 @@ endmethod. ENDWHILE. endmethod. - - - + + + method LOAD_STYLE_FILLS. DATA: value TYPE string, node TYPE REF TO if_ixml_element, @@ -921,9 +939,9 @@ endmethod. endmethod. - - - + + + method LOAD_STYLE_FONTS. DATA: value TYPE string, node TYPE REF TO if_ixml_element, @@ -999,9 +1017,9 @@ endmethod. endmethod. - - - + + + method LOAD_STYLE_NUM_FORMATS. DATA: node TYPE REF TO if_ixml_element, num_format TYPE t_num_format. @@ -1058,9 +1076,10 @@ endmethod. endmethod. - - - + + + + method LOAD_WORKBOOK. CONSTANTS: lc_shared_strings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', @@ -1184,9 +1203,10 @@ endmethod. endmethod. - - - + + + + method LOAD_WORKSHEET. TYPES: BEGIN OF t_cell, r TYPE string, @@ -1506,7 +1526,8 @@ endmethod. fill_struct_from_attributes( EXPORTING ip_element = sheetformatpr_elem CHANGING cp_structure = sheetformatpr ). IF sheetformatpr-customheight = '1'. height = sheetformatpr-defaultrowheight. - io_worksheet->get_default_row_dimension( )->set_row_height( height ). + row_dimension = io_worksheet->get_default_row_dimension( ). + row_dimension->set_row_height( height ). ENDIF. " TODO... column @@ -1555,9 +1576,10 @@ endmethod. endmethod. - + + method LOAD_WORKSHEET_DRAWING. TYPES: BEGIN OF t_c_nv_pr, diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 7763838..d4dce24 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -1,6 +1,6 @@ - + - + class ZCL_EXCEL_WRITER_2007 definition public create public . @@ -131,27 +131,27 @@ public section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + method ZIF_EXCEL_WRITER~WRITE_FILE. me->excel = io_excel. @@ -159,8 +159,8 @@ public section. ep_file = me->create( ). endmethod. - - + + method CREATE. * Office 2007 file format is a cab of several xml files with extension .xlsx @@ -345,8 +345,8 @@ endmethod. endmethod. - - + + method CREATE_CONTENT_TYPES. @@ -620,8 +620,8 @@ endmethod. endmethod. - - + + method CREATE_DOCPROPS_APP. @@ -843,8 +843,8 @@ endmethod. endmethod. - - + + method CREATE_DOCPROPS_CORE. @@ -968,8 +968,8 @@ endmethod. endmethod. - - + + method CREATE_RELATIONSHIPS. @@ -1067,9 +1067,9 @@ endmethod. endmethod. - - - + + + method CREATE_XL_DRAWINGS. @@ -1090,6 +1090,7 @@ endmethod. lo_ostream TYPE REF TO if_ixml_ostream, lo_renderer TYPE REF TO if_ixml_renderer, lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_drawings TYPE REF TO zcl_excel_drawings, lo_drawing TYPE REF TO zcl_excel_drawing. DATA: lv_rel_id TYPE i. @@ -1121,7 +1122,9 @@ endmethod. CLEAR: lv_rel_id. - lo_iterator = io_worksheet->get_drawings( )->get_iterator( ). + lo_drawings = io_worksheet->get_drawings( ). + + lo_iterator = lo_drawings->get_iterator( ). WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. lo_drawing ?= lo_iterator->if_object_collection_iterator~get_next( ). @@ -1144,9 +1147,9 @@ endmethod. endmethod. - - - + + + method CREATE_XL_DRAWINGS_RELS. ** Constant node name @@ -1170,6 +1173,7 @@ endmethod. lo_ostream TYPE REF TO if_ixml_ostream, lo_renderer TYPE REF TO if_ixml_renderer, lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_drawings TYPE REF TO zcl_excel_drawings, lo_drawing TYPE REF TO zcl_excel_drawing. DATA: lv_value TYPE string, @@ -1199,7 +1203,8 @@ endmethod. " Add sheet Relationship nodes here lv_counter = 0. - lo_iterator = io_worksheet->get_drawings( )->get_iterator( ). + lo_drawings = io_worksheet->get_drawings( ). + lo_iterator = lo_drawings->get_iterator( ). WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. lo_drawing ?= lo_iterator->if_object_collection_iterator~get_next( ). ADD 1 TO lv_counter. @@ -1555,8 +1560,8 @@ endmethod. endmethod. - - + + method CREATE_XL_RELATIONSHIPS. @@ -1703,8 +1708,8 @@ endmethod. endmethod. - - + + method CREATE_XL_SHAREDSTRINGS. @@ -1820,10 +1825,10 @@ endmethod. endmethod. - - - - + + + + method CREATE_XL_SHEET. @@ -3350,10 +3355,10 @@ endmethod. endmethod. - - - - + + + + method CREATE_XL_SHEET_RELS. @@ -3520,8 +3525,8 @@ endmethod. endmethod. - - + + method CREATE_XL_STYLES. @@ -4440,11 +4445,11 @@ endmethod. endmethod. - - - - - + + + + + method CREATE_XL_STYLES_COLOR_NODE. DATA: lo_sub_element TYPE REF TO if_ixml_element, lv_value TYPE string. @@ -4491,9 +4496,9 @@ endmethod. io_parent->append_child( new_child = lo_sub_element ). endmethod. - - - + + + method CREATE_XL_TABLE. DATA: lc_xml_node_table TYPE string VALUE 'table', @@ -4662,8 +4667,8 @@ endmethod. endmethod. - - + + method CREATE_XL_THEME. @@ -4751,8 +4756,8 @@ endmethod. endmethod. - - + + method CREATE_XL_WORKBOOK. ** Constant node name @@ -5017,9 +5022,9 @@ endmethod. endmethod. - - - + + + method FLAG2BOOL. @@ -5030,9 +5035,9 @@ endmethod. ENDIF. endmethod. - - - + + + method GET_SHARED_STRING_INDEX.