From c36e6bd54e1564790853d74c6584963adb63b749 Mon Sep 17 00:00:00 2001 From: Ivan Femia Date: Sat, 11 Jun 2011 09:41:17 +0000 Subject: [PATCH] Fix issues #100 and #104 git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@201 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL.slnk | 37 +++++++++++++----- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 49 ++++++++++++++---------- ZA2X/INTF/ZIF_EXCEL_BOOK_PROPERTIES.slnk | 21 ++++++++++ ZA2X/PROG/ZDEMO_EXCEL13.slnk | 2 +- 4 files changed, 79 insertions(+), 30 deletions(-) create mode 100644 ZA2X/INTF/ZIF_EXCEL_BOOK_PROPERTIES.slnk diff --git a/ZA2X/CLAS/ZCL_EXCEL.slnk b/ZA2X/CLAS/ZCL_EXCEL.slnk index b245b60..3cb1be8 100644 --- a/ZA2X/CLAS/ZCL_EXCEL.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL.slnk @@ -1,5 +1,6 @@ + class ZCL_EXCEL definition @@ -13,8 +14,17 @@ public section. interfaces ZIF_EXCEL_BOOK_PROTECTION . interfaces ZIF_EXCEL_BOOK_VBA_PROJECT . + interfaces ZIF_EXCEL_BOOK_PROPERTIES + data values APPLICATION = 'Microsoft Excel' + APPVERSION = '12.0000' + COMPANY = 'abap2xlsx' + CREATOR = 'Ivan Femia' + DESCRIPTION = 'Created using abap2xlsx' + DOCSECURITY = '0' + LASTMODIFIEDBY = 'Ivan Femia' + SCALECROP = '' + TITLE = 'abap2xlsx' . - data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . data SECURITY type ref to ZCL_EXCEL_SECURITY . methods ADD_NEW_DRAWING @@ -70,9 +80,9 @@ public section. *"* protected components of class ZCL_EXCEL *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL + private section. +*"* private components of class ZCL_EXCEL *"* do not include other source files here!!! -private section. data DRAWINGS type ref to ZCL_EXCEL_DRAWINGS . data RANGES type ref to ZCL_EXCEL_RANGES . @@ -87,11 +97,10 @@ private section. *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - + + + + method ZIF_EXCEL_BOOK_PROTECTION~INITIALIZE. me->zif_excel_book_protection~protected = zif_excel_book_protection=>c_unprotected. @@ -115,6 +124,15 @@ endmethod. METHOD zif_excel_book_vba_project~set_vbaproject. me->zif_excel_book_vba_project~vbaproject = ip_vbaproject. +ENDMETHOD. + + + METHOD zif_excel_book_properties~initialize. + DATA: lv_timestamp TYPE timestampl. + + GET TIME STAMP FIELD lv_timestamp. + me->zif_excel_book_properties~created = lv_timestamp. + me->zif_excel_book_properties~modified = lv_timestamp. ENDMETHOD. @@ -166,7 +184,6 @@ endmethod. lo_style TYPE REF TO zcl_excel_style. * Inizialize instance objects - CREATE OBJECT properties. CREATE OBJECT security. CREATE OBJECT worksheets. CREATE OBJECT ranges. @@ -174,11 +191,13 @@ endmethod. CREATE OBJECT drawings. me->zif_excel_book_protection~initialize( ). + me->zif_excel_book_properties~initialize( ). me->add_new_worksheet( ). me->add_new_style( ). " Standard style lo_style = me->add_new_style( ). " Standard style with fill gray125 lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_pattern_gray125. + endmethod. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index aa28ae0..c5f5005 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -573,7 +573,7 @@ endmethod. - method CREATE_DOCPROPS_APP. + METHOD create_docprops_app. ** Constant node name @@ -643,21 +643,21 @@ endmethod. " Application lo_element = lo_document->create_simple_element( name = lc_xml_node_application parent = lo_document ). - lv_value = excel->properties->application. + lv_value = excel->zif_excel_book_properties~application. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). " DocSecurity lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity parent = lo_document ). - lv_value = excel->properties->docsecurity. + lv_value = excel->zif_excel_book_properties~docsecurity. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). " ScaleCrop lo_element = lo_document->create_simple_element( name = lc_xml_node_scalecrop parent = lo_document ). - lv_value = me->flag2bool( excel->properties->scalecrop ). + lv_value = me->flag2bool( excel->zif_excel_book_properties~scalecrop ). lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). @@ -751,35 +751,35 @@ endmethod. " Company lo_element = lo_document->create_simple_element( name = lc_xml_node_company parent = lo_document ). - lv_value = excel->properties->company. + lv_value = excel->zif_excel_book_properties~company. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). " LinksUpToDate lo_element = lo_document->create_simple_element( name = lc_xml_node_linksuptodate parent = lo_document ). - lv_value = me->flag2bool( excel->properties->linksuptodate ). + lv_value = me->flag2bool( excel->zif_excel_book_properties~linksuptodate ). lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). " SharedDoc lo_element = lo_document->create_simple_element( name = lc_xml_node_shareddoc parent = lo_document ). - lv_value = me->flag2bool( excel->properties->shareddoc ). + lv_value = me->flag2bool( excel->zif_excel_book_properties~shareddoc ). lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). " HyperlinksChanged lo_element = lo_document->create_simple_element( name = lc_xml_node_hyperlinkschanged parent = lo_document ). - lv_value = me->flag2bool( excel->properties->hyperlinkschanged ). + lv_value = me->flag2bool( excel->zif_excel_book_properties~hyperlinkschanged ). lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). " AppVersion lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion parent = lo_document ). - lv_value = excel->properties->appversion. + lv_value = excel->zif_excel_book_properties~appversion. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). @@ -790,11 +790,11 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -endmethod. +ENDMETHOD. - method CREATE_DOCPROPS_CORE. + METHOD create_docprops_core. ** Constant node name @@ -810,7 +810,7 @@ endmethod. lc_cp_ns TYPE string VALUE 'cp', lc_dc_ns TYPE string VALUE 'dc', lc_dcterms_ns TYPE string VALUE 'dcterms', - lc_dcmitype_ns TYPE string VALUE 'dcmitype', +* lc_dcmitype_ns TYPE string VALUE 'dcmitype', lc_xsi_ns TYPE string VALUE 'xsi', lc_xml_node_cp_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties', lc_xml_node_dc_ns TYPE string VALUE 'http://purl.org/dc/elements/1.1/', @@ -827,7 +827,9 @@ endmethod. lo_ostream TYPE REF TO if_ixml_ostream, lo_renderer TYPE REF TO if_ixml_renderer. - DATA: lv_value TYPE string. + DATA: lv_value TYPE string, + lv_date TYPE sydatum, + lv_time TYPE syuzeit. ********************************************************************** * STEP 1: Create [Content_Types].xml into the root of the ZIP @@ -863,7 +865,7 @@ endmethod. lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_creator prefix = lc_dc_ns parent = lo_document ). - lv_value = excel->properties->creator. + lv_value = excel->zif_excel_book_properties~creator. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). @@ -871,7 +873,7 @@ endmethod. lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_lastmodifiedby prefix = lc_cp_ns parent = lo_document ). - lv_value = excel->properties->lastmodifiedby. + lv_value = excel->zif_excel_book_properties~lastmodifiedby. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). @@ -882,8 +884,12 @@ endmethod. lo_element->set_attribute_ns( name = lc_xml_attr_type prefix = lc_xsi_ns value = lc_xml_attr_target ). - lv_value = excel->properties->created. - lv_value = '2010-07-04T14:58:53Z'. + + CONVERT TIME STAMP excel->zif_excel_book_properties~created TIME ZONE sy-zonlo INTO DATE lv_date TIME lv_time. + CONCATENATE lv_date lv_time INTO lv_value RESPECTING BLANKS. + REPLACE ALL OCCURRENCES OF REGEX '([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})' IN lv_value WITH '$1-$2-$3T$4:$5:$6Z'. +* lv_value = excel->zif_excel_book_properties~created. +* lv_value = '2010-07-04T14:58:53Z'. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). @@ -894,8 +900,11 @@ endmethod. lo_element->set_attribute_ns( name = lc_xml_attr_type prefix = lc_xsi_ns value = lc_xml_attr_target ). - lv_value = excel->properties->modified. - lv_value = '2010-07-04T14:58:53Z'. + CONVERT TIME STAMP excel->zif_excel_book_properties~modified TIME ZONE sy-zonlo INTO DATE lv_date TIME lv_time. + CONCATENATE lv_date lv_time INTO lv_value RESPECTING BLANKS. + REPLACE ALL OCCURRENCES OF REGEX '([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})' IN lv_value WITH '$1-$2-$3T$4:$5:$6Z'. +* lv_value = excel->zif_excel_book_properties~modified. +* lv_value = '2010-07-04T14:58:53Z'. lo_element->set_value( value = lv_value ). lo_element_root->append_child( new_child = lo_element ). @@ -906,7 +915,7 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -endmethod. +ENDMETHOD. diff --git a/ZA2X/INTF/ZIF_EXCEL_BOOK_PROPERTIES.slnk b/ZA2X/INTF/ZIF_EXCEL_BOOK_PROPERTIES.slnk new file mode 100644 index 0000000..7267efc --- /dev/null +++ b/ZA2X/INTF/ZIF_EXCEL_BOOK_PROPERTIES.slnk @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/ZA2X/PROG/ZDEMO_EXCEL13.slnk b/ZA2X/PROG/ZDEMO_EXCEL13.slnk index 58e128f..0ee4ea7 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL13.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL13.slnk @@ -1,5 +1,5 @@ - +