diff --git a/ZA2X/CLAS/ZCL_EXCEL.slnk b/ZA2X/CLAS/ZCL_EXCEL.slnk new file mode 100644 index 0000000..65e8c31 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL.slnk @@ -0,0 +1,219 @@ + + + class ZCL_EXCEL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! +public section. + + data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . + data SECURITY type ref to ZCL_EXCEL_SECURITY . + + methods ADD_NEW_DRAWING + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_RANGE + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods ADD_NEW_STYLE + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods ADD_NEW_WORKSHEET + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods CONSTRUCTOR . + methods GET_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_DRAWINGS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_RANGES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_NAME + returning + value(EP_NAME) type ZEXCEL_WORKSHEETS_NAME . + methods GET_WORKSHEETS_SIZE + returning + value(EP_SIZE) type I . + methods GET_NEXT_TABLE_ID + returning + value(EP_ID) type I . + *"* protected components of class ZCL_EXCEL +*"* do not include other source files here!!! +protected 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 . + data STYLES type ref to ZCL_EXCEL_STYLES . + data WORKSHEETS type ref to ZCL_EXCEL_WORKSHEETS . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + method ADD_NEW_DRAWING. + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_title = ip_title. + drawings->add( eo_drawing ). +endmethod. + + + + method ADD_NEW_RANGE. +* Create default blank range + CREATE OBJECT eo_range. + ranges->add( eo_range ). +endmethod. + + + + method ADD_NEW_STYLE. +* Create default style + CREATE OBJECT eo_style. + styles->add( eo_style ). + +endmethod. + + + + + method ADD_NEW_WORKSHEET. + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_excel = me + ip_title = ip_title. + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). +endmethod. + + + method CONSTRUCTOR. + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style TYPE REF TO zcl_excel_style. + +* Inizialize instance objects + CREATE OBJECT properties. + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings. + + 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. + + + + method GET_ACTIVE_WORKSHEET. + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + +endmethod. + + + + method GET_DRAWINGS_ITERATOR. + + eo_iterator = me->drawings->get_iterator( ). + +endmethod. + + + + method GET_NEXT_TABLE_ID. + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lv_tables_count TYPE i. + + lo_iterator = me->get_worksheets_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->get_next( ). + + lv_tables_count = lo_worksheet->get_tables_size( ). + ADD lv_tables_count TO ep_id. + + ENDWHILE. + + ADD 1 TO ep_id. + +endmethod. + + + + method GET_RANGES_ITERATOR. + + eo_iterator = me->ranges->get_iterator( ). + +endmethod. + + + + method GET_STYLES_ITERATOR. + + eo_iterator = me->styles->get_iterator( ). + +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( ). + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk new file mode 100644 index 0000000..cd598a1 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk @@ -0,0 +1,185 @@ + + + class ZCL_EXCEL_COMMON definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +public section. + + class-data C_EXCEL_NUMFMT_OFFSET type INT1 value 164. "#EC NOTEXT . + + class-methods GET_FIELDCATALOG + importing + !IP_TABLE type STANDARD TABLE + returning + value(EP_FIELDCATALOG) type ZEXCEL_T_FIELDCATALOG . + class-methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + class-methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + class-methods NUMBER_TO_EXCEL_STRING + importing + value(IP_VALUE) type NUMERIC + returning + value(EP_VALUE) type ZEXCEL_CELL_VALUE . + class-methods DATE_TO_EXCEL_STRING + importing + !IP_VALUE type D + returning + value(EP_VALUE) type ZEXCEL_CELL_VALUE . + class-methods TIME_TO_EXCEL_STRING + importing + !IP_VALUE type T + returning + value(EP_VALUE) type ZEXCEL_CELL_VALUE . + *"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +private section. + + class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + method CONVERT_COLUMN2ALPHA. + + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +endmethod. + + + + + method CONVERT_COLUMN2INT. + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( zcl_excel_common=>c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( zcl_excel_common=>c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - zcl_excel_common=>c_excel_col_module. + ENDIF. + +endmethod. + + + + + method GET_FIELDCATALOG. + + DATA: lr_data TYPE REF TO data, + lo_tabdescr TYPE REF TO cl_abap_structdescr, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + ls_dfies TYPE dfies, + ls_fieldcatalog TYPE zexcel_s_fieldcatalog. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + + LOOP AT lt_dfies INTO ls_dfies. + MOVE-CORRESPONDING ls_dfies TO ls_fieldcatalog. + APPEND ls_fieldcatalog TO ep_fieldcatalog. + ENDLOOP. + +endmethod. + + + + + METHOD date_to_excel_string. + DATA: lv_date_diff TYPE i, + lc_date_baseline TYPE d VALUE '19000101'. + + lv_date_diff = ip_value - lc_date_baseline + 2. + ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_date_diff ). +ENDMETHOD. + + + + + METHOD number_to_excel_string. + DATA: lv_value_c TYPE c LENGTH 100. + + WRITE ip_value TO lv_value_c EXPONENT 0 NO-GROUPING NO-SIGN. + REPLACE ALL OCCURRENCES OF ',' IN lv_value_c WITH '.'. + + ep_value = lv_value_c. + CONDENSE ep_value. + + IF ip_value < 0. + CONCATENATE '-' ep_value INTO ep_value. + ENDIF. +ENDMETHOD. + + + + + METHOD time_to_excel_string. + DATA: lv_seconds_in_day TYPE i, + lv_day_fraction TYPE f, + lc_time_baseline TYPE t VALUE '000000', + lc_seconds_in_day TYPE i VALUE 86400. + + lv_seconds_in_day = ip_value - lc_time_baseline. + lv_day_fraction = lv_seconds_in_day / lc_seconds_in_day. + ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_day_fraction ). +ENDMETHOD. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk b/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk new file mode 100644 index 0000000..637733a --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk @@ -0,0 +1,56 @@ + + + class ZCL_EXCEL_DATA_VALIDATION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data ALLOWBLANK type FLAG value 'X'. "#EC NOTEXT . + data CELL_ROW type ZEXCEL_CELL_ROW . + class-data C_TYPE_LIST type ZEXCEL_DATA_VAL_TYPE value 'list'. "#EC NOTEXT . + data SHOWERRORMESSAGE type FLAG value 'X'. "#EC NOTEXT . + data SHOWINPUTMESSAGE type FLAG value 'X'. "#EC NOTEXT . + data TYPE type ZEXCEL_DATA_VAL_TYPE . + data VALUE type ZEXCEL_VALIDATION_FORMULA1 . + data CELL_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + + methods CONSTRUCTOR . + *"* protected components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + method CONSTRUCTOR. + + type = me->c_type_list. +* inizialize dimension range + cell_row = 1. + cell_column = 'A'. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATIONS.slnk b/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATIONS.slnk new file mode 100644 index 0000000..8d2d302 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATIONS.slnk @@ -0,0 +1,91 @@ + + + class ZCL_EXCEL_DATA_VALIDATIONS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + methods ADD + importing + !IP_DATA_VALIDATION type ref to ZCL_EXCEL_DATA_VALIDATION . + methods CLEAR . + methods CONSTRUCTOR . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DATA_VALIDATION type ref to ZCL_EXCEL_DATA_VALIDATION . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +private section. + + data DATA_VALIDATIONS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + method ADD. + data_validations->add( ip_data_validation ). +endmethod. + + + method CLEAR. + data_validations->clear( ). +endmethod. + + + method CONSTRUCTOR. + + CREATE OBJECT data_validations. + +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= data_validations->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = data_validations->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + data_validations->remove( ip_data_validation ). +endmethod. + + + + method SIZE. + ep_size = data_validations->if_object_collection~size( ). +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk b/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk new file mode 100644 index 0000000..d79f133 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk @@ -0,0 +1,146 @@ + + + class ZCL_EXCEL_DRAWING definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + data X_REFERENCES type CHAR1 . + data Y_REFERENCES type CHAR1 . + data GRAPH_TYPE type ZEXCEL_GRAPH_TYPE . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + *"* protected components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +private section. + + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + constants C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT + + methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + method CONSTRUCTOR. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +endmethod. + + + + + method CONVERT_COLUMN2ALPHA. + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +endmethod. + + + + + method CONVERT_COLUMN2INT. + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( me->c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( me->c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - me->c_excel_col_module. + ENDIF. + +endmethod. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_DRAWINGS.slnk b/ZA2X/CLAS/ZCL_EXCEL_DRAWINGS.slnk new file mode 100644 index 0000000..ad3adfb --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_DRAWINGS.slnk @@ -0,0 +1,109 @@ + + + class ZCL_EXCEL_DRAWINGS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +private section. + + data DRAWINGS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + + drawings->add( ip_drawing ). +endmethod. + + + method CLEAR. + + drawings->clear( ). +endmethod. + + + method CONSTRUCTOR. + + CREATE OBJECT drawings. + +endmethod. + + + + + method GET. + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_drawing ?= drawings->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. + + eo_iterator ?= drawings->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + + is_empty = drawings->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + + drawings->remove( ip_drawing ). +endmethod. + + + + method SIZE. + + ep_size = drawings->if_object_collection~size( ). +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_PROPERTIES.slnk b/ZA2X/CLAS/ZCL_EXCEL_PROPERTIES.slnk new file mode 100644 index 0000000..906064e --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_PROPERTIES.slnk @@ -0,0 +1,73 @@ + + + class ZCL_EXCEL_PROPERTIES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +public section. + + data CREATOR type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data LASTMODIFIEDBY type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data CREATED type TIMESTAMPL . + data MODIFIED type TIMESTAMPL . + data TITLE type ZEXCEL_TITLE value 'Untitled Spreadsheet'. "#EC NOTEXT . + data SUBJECT type ZEXCEL_SUBJECT . + data DESCRIPTION type ZEXCEL_DESCRIPTION . + data KEYWORDS type ZEXCEL_KEYWORDS . + data CATEGORY type ZEXCEL_CATEGORY . + data COMPANY type ZEXCEL_COMPANY value 'Microsoft Corporation'. "#EC NOTEXT . + data APPLICATION type ZEXCEL_APPLICATION value 'Microsoft Excel'. "#EC NOTEXT . + data DOCSECURITY type ZEXCEL_DOCSECURITY value '0'. "#EC NOTEXT . + data SCALECROP type ZEXCEL_SCALECROP value ''. "#EC NOTEXT . + data LINKSUPTODATE type FLAG . + data SHAREDDOC type FLAG . + data HYPERLINKSCHANGED type FLAG . + data APPVERSION type ZEXCEL_APPVERSION value '12.0000'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_PROPERTIES +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + + DATA: lv_timestamp TYPE timestampl. + + GET TIME STAMP FIELD lv_timestamp. + created = lv_timestamp. + modified = lv_timestamp. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_RANGE.slnk b/ZA2X/CLAS/ZCL_EXCEL_RANGE.slnk new file mode 100644 index 0000000..81aa6ee --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_RANGE.slnk @@ -0,0 +1,86 @@ + + + class ZCL_EXCEL_RANGE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +public section. + + data NAME type ZEXCEL_RANGE_NAME . + data GUID type ZEXCEL_RANGE_GUID . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_RANGE_GUID . + methods SET_VALUE + importing + !IP_SHEET_NAME type ZEXCEL_SHEET_TITLE + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + methods GET_VALUE + returning + value(EP_VALUE) type ZEXCEL_RANGE_VALUE . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +private section. + + data VALUE type ZEXCEL_RANGE_VALUE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + method CONSTRUCTOR. +endmethod. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + method GET_VALUE. + + ep_value = me->value. + +endmethod. + + + + + + + + method SET_VALUE. + DATA: lv_start_row_c TYPE char7, + lv_stop_row_c TYPE char7. + lv_stop_row_c = ip_stop_row. + SHIFT lv_stop_row_c RIGHT DELETING TRAILING space. + SHIFT lv_stop_row_c LEFT DELETING LEADING space. + lv_start_row_c = ip_start_row. + SHIFT lv_start_row_c RIGHT DELETING TRAILING space. + SHIFT lv_start_row_c LEFT DELETING LEADING space. + CONCATENATE ip_sheet_name '!$' ip_start_column '$' lv_start_row_c ':$' ip_stop_column '$' lv_stop_row_c INTO me->value. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_RANGES.slnk b/ZA2X/CLAS/ZCL_EXCEL_RANGES.slnk new file mode 100644 index 0000000..22707b7 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_RANGES.slnk @@ -0,0 +1,101 @@ + + + class ZCL_EXCEL_RANGES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! +private section. + + data RANGES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + ranges->add( ip_range ). +endmethod. + + + method CLEAR. + ranges->clear( ). +endmethod. + + + method CONSTRUCTOR. + + + CREATE OBJECT ranges. + +endmethod. + + + + + method GET. + eo_range ?= ranges->if_object_collection~get( ip_index ). +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= ranges->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = ranges->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + ranges->remove( ip_range ). +endmethod. + + + + method SIZE. + ep_size = ranges->if_object_collection~size( ). +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk new file mode 100644 index 0000000..8de21d6 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk @@ -0,0 +1,421 @@ + + + + class ZCL_EXCEL_READER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_READER_2007 +*"* do not include other source files here!!! +public section. + + interfaces ZIF_EXCEL_READER . + *"* protected components of class ZCL_EXCEL_READER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_READER_2007 +*"* do not include other source files here!!! +private section. + + data EXCEL2007 type XSTRING . + data ZIP type ref to CL_ABAP_ZIP . + + methods GET_FROM_ZIP_ARCHIVE + importing + !I_FILENAME type STRING + returning + value(R_CONTENT) type XSTRING + raising + ZCX_EXCEL . + methods GET_IXML_FROM_ZIP_ARCHIVE + importing + !I_FILENAME type STRING + returning + value(R_IXML) type ref to IF_IXML_DOCUMENT + raising + ZCX_EXCEL . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + + TYPES: + BEGIN OF t_splice_entry, + name TYPE string, + offset TYPE i, + length TYPE i, + compressed TYPE i, + END OF t_splice_entry. + TYPES: + t_splice_entries TYPE STANDARD TABLE OF t_splice_entry WITH DEFAULT KEY. + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + METHOD zif_excel_reader~load. + TYPES: + BEGIN OF t_worksheet, + id TYPE string, + target TYPE string, + END OF t_worksheet. + TYPES: t_worksheets TYPE TABLE OF t_worksheet. + + CONSTANTS: + lc_core_properties TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_office_document TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_shared_strings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + lc_worksheet TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_relationships TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'. + + TYPE-POOLS: ixml. + + DATA: rels TYPE REF TO if_ixml_document, + rels_coll TYPE REF TO if_ixml_node_collection, + rels_coll_index TYPE i, + workbook_path TYPE string, + rels_workbook_path TYPE string, + rels_workbook TYPE REF TO if_ixml_document, + rels_wb_coll TYPE REF TO if_ixml_node_collection, + rels_wb_coll_index TYPE i, + shared_strings_path TYPE string, + shared_strings TYPE REF TO if_ixml_document, + shared_strings_coll TYPE REF TO if_ixml_node_collection, + shared_strings_coll_index TYPE i, + worksheets TYPE t_worksheets, + workbook TYPE REF TO if_ixml_document, + workbook_coll TYPE REF TO if_ixml_node_collection, + workbook_index TYPE i, + worksheet_path TYPE string, + worksheet TYPE REF TO if_ixml_document, + worksheet_coll TYPE REF TO if_ixml_node_collection, + worksheet_index TYPE i. + + FIELD-SYMBOLS: <worksheet> TYPE t_worksheet. + + DATA: node TYPE REF TO if_ixml_node, + value_node TYPE REF TO if_ixml_node, + si TYPE REF TO if_ixml_node_list, + row TYPE REF TO if_ixml_node_list, + row_iterator TYPE REF TO if_ixml_node_iterator, + col TYPE REF TO if_ixml_node, + attributes TYPE REF TO if_ixml_named_node_map, + attribute TYPE REF TO if_ixml_node, + col_attributes TYPE REF TO if_ixml_named_node_map, + attr_type TYPE string, + attr_target TYPE string, + attr_id TYPE string, + tag_name TYPE string, + r TYPE string, + r_width TYPE i, + cell_data_type TYPE string, + cell_column TYPE zexcel_cell_column_alpha, + cell_row TYPE zexcel_cell_row, + value TYPE string, + values TYPE stringtab, + value_index TYPE i, + cell_value TYPE zexcel_cell_value, + stripped_name TYPE chkfile, + dirname TYPE string. + + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + worksheet_title TYPE zexcel_sheet_title, + worksheet_id TYPE string. + + me->excel2007 = i_excel2007. + rels = me->get_ixml_from_zip_archive( '_rels/.rels' ). + + CREATE OBJECT r_excel. + + rels_coll = rels->get_elements_by_tag_name( name = 'Relationship' ). + rels_coll_index = 0. + WHILE rels_coll_index < rels_coll->get_length( ). + node = rels_coll->get_item( rels_coll_index ). + rels_coll_index = rels_coll_index + 1. + attributes ?= node->get_attributes( ). + attribute ?= attributes->get_named_item_ns( 'Type' ). + attr_type = attribute->get_value( ). + CASE attr_type. + WHEN lc_core_properties. + " TODO Map Document Properties to ZCL_EXCEL + WHEN lc_office_document. + attribute ?= attributes->get_named_item_ns( 'Target' ). + workbook_path = attribute->get_value( ). + + CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH' + EXPORTING + full_name = workbook_path + IMPORTING + stripped_name = stripped_name + file_path = dirname. + " Read Workbook Relationships + CONCATENATE dirname '_rels/' stripped_name '.rels' + INTO rels_workbook_path. + rels_workbook = me->get_ixml_from_zip_archive( rels_workbook_path ). + rels_wb_coll = + rels_workbook->get_elements_by_tag_name( name = 'Relationship' ). + rels_wb_coll_index = 0. + WHILE rels_wb_coll_index < rels_wb_coll->get_length( ). + node = rels_wb_coll->get_item( rels_wb_coll_index ). + rels_wb_coll_index = rels_wb_coll_index + 1. + attributes ?= node->get_attributes( ). + attribute ?= attributes->get_named_item_ns( 'Type' ). + attr_type = attribute->get_value( ). + CASE attr_type. + WHEN lc_shared_strings. + " Read Shared Strings + attribute ?= attributes->get_named_item_ns( 'Target' ). + attr_target = attribute->get_value( ). + CONCATENATE dirname attr_target INTO shared_strings_path. + shared_strings = me->get_ixml_from_zip_archive( shared_strings_path ). + shared_strings_coll = + shared_strings->get_elements_by_tag_name( name = 'si' ). + shared_strings_coll_index = 0. + WHILE shared_strings_coll_index < shared_strings_coll->get_length( ). + node = shared_strings_coll->get_item( shared_strings_coll_index ). + shared_strings_coll_index = shared_strings_coll_index + 1. + si = node->get_children( ). + node = si->get_item( 0 ). + tag_name = node->get_name( ). + IF tag_name = 't'. + value = node->get_value( ). + APPEND value TO values. + ELSEIF tag_name = 'r'. + " TODO pharse Ritch text + ENDIF. + ENDWHILE. + WHEN lc_worksheet. + " Read worksheets + APPEND INITIAL LINE TO worksheets ASSIGNING <worksheet>. + attribute ?= attributes->get_named_item_ns( 'Id' ). + <worksheet>-id = attribute->get_value( ). + attribute ?= attributes->get_named_item_ns( 'Target' ). + <worksheet>-target = attribute->get_value( ). + " WRITE: / <worksheet>-id, ':', <worksheet>-target. + WHEN OTHERS. + ENDCASE. + ENDWHILE. + " Read Workbook + workbook = me->get_ixml_from_zip_archive( workbook_path ). + workbook_coll = workbook->get_elements_by_tag_name( name = 'sheet' ). + workbook_index = 0. + WHILE workbook_index < workbook_coll->get_length( ). + node = workbook_coll->get_item( workbook_index ). + workbook_index = workbook_index + 1. + attributes ?= node->get_attributes( ). + attribute ?= attributes->get_named_item_ns( 'name' ). + worksheet_title = attribute->get_value( ). + IF workbook_index > 1. + lo_worksheet = r_excel->add_new_worksheet( worksheet_title ). + ELSE. + lo_worksheet = r_excel->get_active_worksheet( ). + lo_worksheet->title = worksheet_title. + ENDIF. + attribute ?= attributes->get_named_item_ns( + name = 'id' + uri = lc_relationships + ). + worksheet_id = attribute->get_value( ). + READ TABLE worksheets ASSIGNING <worksheet> + WITH KEY id = worksheet_id. + " WRITE: / worksheet_id, worksheet_title, <worksheet>-target. + CONCATENATE dirname <worksheet>-target INTO worksheet_path. + worksheet = me->get_ixml_from_zip_archive( worksheet_path ). + worksheet_coll = worksheet->get_elements_by_tag_name( name = 'row' ). + worksheet_index = 0. + WHILE worksheet_index < worksheet_coll->get_length( ). + node = worksheet_coll->get_item( worksheet_index ). + worksheet_index = worksheet_index + 1. + row = node->get_children( ). + row_iterator = row->create_iterator( ). + col = row_iterator->get_next( ). + WHILE NOT col IS INITIAL. + col_attributes = col->get_attributes( ). + attribute ?= col_attributes->get_named_item_ns( 'r' ). + r = attribute->get_value( ). + CLEAR: cell_data_type, cell_value. + attribute ?= col_attributes->get_named_item_ns( 't' ). + IF attribute IS BOUND. + cell_data_type = attribute->get_value( ). + ENDIF. + " WRITE: / r, cell_data_type. + value_node = col->get_first_child( ). + CASE cell_data_type. + WHEN 's'. " String + value_index = value_node->get_value( ) + 1. + READ TABLE values INTO cell_value INDEX value_index. + WHEN 'b'. " Boolean + " TODO + WHEN 'inlineStr'. " inlineStr + " TODO + WHEN 'e'. " Error + " TODO + WHEN OTHERS. + IF value_node IS BOUND. + cell_value = value_node->get_value( ). + ENDIF. + ENDCASE. + IF NOT value IS INITIAL. + " WRITE: value. + " TODO: wite a robust method which splits r into + " cell_column and cell_row + cell_column = r(1). + r_width = STRLEN( r ). + r_width = r_width - 1. + cell_row = r+1(r_width). + " WRITE: cell_column, cell_row, cell_value. + lo_worksheet->set_cell( + EXPORTING + ip_column = cell_column " Cell Column + ip_row = cell_row " Cell Row + ip_value = cell_value " Cell Value + ). + ENDIF. + col = row_iterator->get_next( ). + ENDWHILE. + ENDWHILE. + ENDWHILE. + WHEN OTHERS. + ENDCASE. + ENDWHILE. + +ENDMETHOD. + + + method ZIF_EXCEL_READER~LOAD_FILE. + DATA: excel_data TYPE xstring. + DATA filelength TYPE i. + DATA bin_tab TYPE TABLE OF x255. + " Background processing + DATA bin_data LIKE LINE OF bin_tab. + DATA len TYPE i. + DATA alen TYPE i. + + IF sy-batch = abap_true. + DESCRIBE FIELD bin_data LENGTH len IN BYTE MODE. + OPEN DATASET i_filename FOR INPUT IN BINARY MODE. + WHILE sy-subrc = 0. + READ DATASET i_filename INTO bin_data MAXIMUM LENGTH len ACTUAL LENGTH alen. + APPEND bin_data TO bin_tab. + filelength = filelength + alen. + ENDWHILE. + CLOSE DATASET i_filename. + ELSE. + cl_gui_frontend_services=>gui_upload( + EXPORTING + filename = i_filename " Name of file + filetype = 'BIN' " File Type (ASCII, Binary) + IMPORTING + filelength = filelength + CHANGING + data_tab = bin_tab + 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 <> 0. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'A problem occured when reading the file'. + ENDIF. + ENDIF. + CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' + EXPORTING + input_length = filelength + IMPORTING + buffer = excel_data + TABLES + binary_tab = bin_tab. + r_excel = me->zif_excel_reader~load( excel_data ). +endmethod. + + + + + + method GET_FROM_ZIP_ARCHIVE. + + IF me->zip IS NOT BOUND. + CREATE OBJECT me->zip. + zip->load( + EXPORTING + zip = me->excel2007 + EXCEPTIONS + zip_parse_error = 1 + OTHERS = 2 + ). + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'ZIP parse error'. + ENDIF. + ENDIF. + + zip->get( + EXPORTING + name = i_filename + IMPORTING + content = r_content " Contents + EXCEPTIONS + zip_index_error = 1 + zip_decompression_error = 2 + OTHERS = 3 + ). + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'ZIP index or decompression error'. + ENDIF. + +endmethod. + + + + + + method GET_IXML_FROM_ZIP_ARCHIVE. + TYPE-POOLS: ixml. + + DATA: content TYPE xstring. + + DATA: ixml TYPE REF TO if_ixml, + streamfactory TYPE REF TO if_ixml_stream_factory, + istream TYPE REF TO if_ixml_istream, + parser TYPE REF TO if_ixml_parser. + + content = me->get_from_zip_archive( i_filename ). + ixml = cl_ixml=>create( ). + streamfactory = ixml->create_stream_factory( ). + istream = streamfactory->create_istream_xstring( content ). + r_ixml = ixml->create_document( ). + parser = ixml->create_parser( stream_factory = streamfactory + istream = istream + document = r_ixml ). + parser->set_normalizing( ). + parser->set_validating( mode = if_ixml_parser=>co_no_validation ). + parser->parse( ). + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_SECURITY.slnk b/ZA2X/CLAS/ZCL_EXCEL_SECURITY.slnk new file mode 100644 index 0000000..b02e187 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_SECURITY.slnk @@ -0,0 +1,56 @@ + + + class ZCL_EXCEL_SECURITY definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SECURITY +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data LOCKREVISION type FLAG . + data LOCKSTRUCTURE type FLAG . + data LOCKWINDOWS type FLAG . + data REVISIONSPASSWORD type ZEXCEL_REVISIONSPASSWORD . + data WORKBOOKPASSWORD type ZEXCEL_WORKBOOKPASSWORD . + + methods CONSTRUCTOR . + methods IS_SECURITY_ENABLED + returning + value(EP_SECURITY_ENABLED) type FLAG . + *"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + method CONSTRUCTOR. +endmethod. + + + + method IS_SECURITY_ENABLED. + IF lockrevision EQ abap_true OR lockstructure EQ abap_true OR lockwindows EQ abap_true. + ep_security_enabled = abap_true. + ENDIF. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_SHEET_SETUP.slnk b/ZA2X/CLAS/ZCL_EXCEL_SHEET_SETUP.slnk new file mode 100644 index 0000000..6be6f5c --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_SHEET_SETUP.slnk @@ -0,0 +1,176 @@ + + + class ZCL_EXCEL_SHEET_SETUP definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants C_PAPERSIZE_LETTER type ZEXCEL_SHEET_PAPER_SIZE value 1. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 2. "#EC NOTEXT + constants C_PAPERSIZE_TABLOID type ZEXCEL_SHEET_PAPER_SIZE value 3. "#EC NOTEXT + constants C_PAPERSIZE_LEDGER type ZEXCEL_SHEET_PAPER_SIZE value 4. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL type ZEXCEL_SHEET_PAPER_SIZE value 5. "#EC NOTEXT + constants C_PAPERSIZE_STATEMENT type ZEXCEL_SHEET_PAPER_SIZE value 6. "#EC NOTEXT + constants C_PAPERSIZE_EXECUTIVE type ZEXCEL_SHEET_PAPER_SIZE value 7. "#EC NOTEXT + constants C_PAPERSIZE_A3 type ZEXCEL_SHEET_PAPER_SIZE value 8. "#EC NOTEXT + constants C_PAPERSIZE_A4 type ZEXCEL_SHEET_PAPER_SIZE value 9. "#EC NOTEXT + constants C_PAPERSIZE_A4_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 10. "#EC NOTEXT + constants C_PAPERSIZE_A5 type ZEXCEL_SHEET_PAPER_SIZE value 11. "#EC NOTEXT + constants C_PAPERSIZE_B4 type ZEXCEL_SHEET_PAPER_SIZE value 12. "#EC NOTEXT + constants C_PAPERSIZE_B5 type ZEXCEL_SHEET_PAPER_SIZE value 13. "#EC NOTEXT + constants C_PAPERSIZE_FOLIO type ZEXCEL_SHEET_PAPER_SIZE value 14. "#EC NOTEXT + constants C_PAPERSIZE_QUARTO type ZEXCEL_SHEET_PAPER_SIZE value 15. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_1 type ZEXCEL_SHEET_PAPER_SIZE value 16. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_2 type ZEXCEL_SHEET_PAPER_SIZE value 17. "#EC NOTEXT + constants C_PAPERSIZE_NOTE type ZEXCEL_SHEET_PAPER_SIZE value 18. "#EC NOTEXT + constants C_PAPERSIZE_NO9_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 19. "#EC NOTEXT + constants C_PAPERSIZE_NO10_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 20. "#EC NOTEXT + constants C_PAPERSIZE_NO11_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 21. "#EC NOTEXT + constants C_PAPERSIZE_NO12_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 22. "#EC NOTEXT + constants C_PAPERSIZE_NO14_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 23. "#EC NOTEXT + constants C_PAPERSIZE_C type ZEXCEL_SHEET_PAPER_SIZE value 24. "#EC NOTEXT + constants C_PAPERSIZE_D type ZEXCEL_SHEET_PAPER_SIZE value 25. "#EC NOTEXT + constants C_PAPERSIZE_E type ZEXCEL_SHEET_PAPER_SIZE value 26. "#EC NOTEXT + constants C_PAPERSIZE_DL_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 27. "#EC NOTEXT + constants C_PAPERSIZE_C5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 28. "#EC NOTEXT + constants C_PAPERSIZE_C3_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 29. "#EC NOTEXT + constants C_PAPERSIZE_C4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 30. "#EC NOTEXT + constants C_PAPERSIZE_C6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 31. "#EC NOTEXT + constants C_PAPERSIZE_C65_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 32. "#EC NOTEXT + constants C_PAPERSIZE_B4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 33. "#EC NOTEXT + constants C_PAPERSIZE_B5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 34. "#EC NOTEXT + constants C_PAPERSIZE_B6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 35. "#EC NOTEXT + constants C_PAPERSIZE_ITALY_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 36. "#EC NOTEXT + constants C_PAPERSIZE_MONARCH_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 37. "#EC NOTEXT + constants C_PAPERSIZE_6_3_4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 38. "#EC NOTEXT + constants C_PAPERSIZE_US_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 39. "#EC NOTEXT + constants C_PAPERSIZE_DE_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 40. "#EC NOTEXT + constants C_PAPERSIZE_DE_LEG_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 41. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B4 type ZEXCEL_SHEET_PAPER_SIZE value 42. "#EC NOTEXT + constants C_PAPERSIZE_JPN_DBL_POSTCARD type ZEXCEL_SHEET_PAPER_SIZE value 43. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_1 type ZEXCEL_SHEET_PAPER_SIZE value 44. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_2 type ZEXCEL_SHEET_PAPER_SIZE value 45. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_3 type ZEXCEL_SHEET_PAPER_SIZE value 46. "#EC NOTEXT + constants C_PAPERSIZE_INVITE_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 47. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 48. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 49. "#EC NOTEXT + constants C_PAPERSIZE_TABL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 50. "#EC NOTEXT + constants C_PAPERSIZE_A4_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 51. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 52. "#EC NOTEXT + constants C_PAPERSIZE_A4_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 53. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 54. "#EC NOTEXT + constants C_PAPERSIZE_SUPERA_A4_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 55. "#EC NOTEXT + constants C_PAPERSIZE_SUPERB_A3_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 56. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 57. "#EC NOTEXT + constants C_PAPERSIZE_A4_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 58. "#EC NOTEXT + constants C_PAPERSIZE_A5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 59. "#EC NOTEXT + constants C_PAPERSIZE_JIS_B5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 60. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 61. "#EC NOTEXT + constants C_PAPERSIZE_A5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 62. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 63. "#EC NOTEXT + constants C_PAPERSIZE_A2_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 64. "#EC NOTEXT + constants C_PAPERSIZE_A3_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 65. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 66. "#EC NOTEXT + constants C_ORIENTATION_DEFAULT type ZEXCEL_SHEET_ORIENATATION value 'default'. "#EC NOTEXT + constants C_ORIENTATION_LANDSCAPE type ZEXCEL_SHEET_ORIENATATION value 'landscape'. "#EC NOTEXT + constants C_ORIENTATION_PORTRAIT type ZEXCEL_SHEET_ORIENATATION value 'portrait'. "#EC NOTEXT + data ORIENTATION type ZEXCEL_SHEET_ORIENATATION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + orientation = me->c_orientation_default. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE.slnk new file mode 100644 index 0000000..f853fe3 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE.slnk @@ -0,0 +1,71 @@ + + + class ZCL_EXCEL_STYLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +public section. + + data FONT type ref to ZCL_EXCEL_STYLE_FONT . + data FILL type ref to ZCL_EXCEL_STYLE_FILL . + data BORDERS type ref to ZCL_EXCEL_STYLE_BORDERS . + data ALIGNMENT type ref to ZCL_EXCEL_STYLE_ALIGNMENT . + data NUMBER_FORMAT type ref to ZCL_EXCEL_STYLE_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_CELL_STYLE . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +private section. + + data PROTECTION type ref to ZCL_EXCEL_STYLE_PROTECTION . + data GUID type ZEXCEL_CELL_STYLE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + method CONSTRUCTOR. + + + CREATE OBJECT font. + CREATE OBJECT fill. + CREATE OBJECT borders. + CREATE OBJECT alignment. + CREATE OBJECT number_format. + CREATE OBJECT protection. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + +endmethod. + + + + method GET_GUID. + + + ep_guid = me->guid. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLES.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLES.slnk new file mode 100644 index 0000000..93a7155 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLES.slnk @@ -0,0 +1,129 @@ + + + class ZCL_EXCEL_STYLES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods SIZE + returning + value(EP_SIZE) type I . + methods REGISTER_NEW_STYLE + importing + !IO_STYLE type ref to ZCL_EXCEL_STYLE + returning + value(EP_STYLE_CODE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +private section. + + data STYLES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + + + styles->add( ip_style ). +endmethod. + + + method CLEAR. + + + styles->clear( ). +endmethod. + + + method CONSTRUCTOR. + + + CREATE OBJECT styles. +endmethod. + + + + + method GET. + + + eo_style ?= styles->if_object_collection~get( ip_index ). +endmethod. + + + + method GET_ITERATOR. + + + eo_iterator ?= styles->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + + + is_empty = styles->if_object_collection~is_empty( ). +endmethod. + + + + + method REGISTER_NEW_STYLE. + + + me->add( io_style ). + ep_style_code = me->size( ) - 1. "style count starts from 0 +endmethod. + + + + method REMOVE. + + + styles->remove( ip_style ). +endmethod. + + + + method SIZE. + + + ep_size = styles->if_object_collection~size( ). +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLES_CONDITIONAL.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLES_CONDITIONAL.slnk new file mode 100644 index 0000000..438cde9 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLES_CONDITIONAL.slnk @@ -0,0 +1,102 @@ + + + class ZCL_EXCEL_STYLES_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_STYLE_CONDITIONAL) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data STYLES_CONDITIONAL type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + styles_conditional->add( ip_style_conditional ). +endmethod. + + + method CLEAR. + styles_conditional->clear( ). +endmethod. + + + method CONSTRUCTOR. + + CREATE OBJECT styles_conditional. + +endmethod. + + + + + method GET. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_style_conditional ?= styles_conditional->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= styles_conditional->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = styles_conditional->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + styles_conditional->remove( ip_style_conditional ). +endmethod. + + + + method SIZE. + ep_size = styles_conditional->if_object_collection~size( ). +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_ALIGNMENT.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_ALIGNMENT.slnk new file mode 100644 index 0000000..e639db5 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_ALIGNMENT.slnk @@ -0,0 +1,87 @@ + + + class ZCL_EXCEL_STYLE_ALIGNMENT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants C_HORIZONTAL_GENERAL type ZEXCEL_ALIGNMENT value 'general'. "#EC NOTEXT + constants C_HORIZONTAL_LEFT type ZEXCEL_ALIGNMENT value 'left'. "#EC NOTEXT + constants C_HORIZONTAL_RIGHT type ZEXCEL_ALIGNMENT value 'right'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER_CONTINUOUS type ZEXCEL_ALIGNMENT value 'centerContinuous'. "#EC NOTEXT + constants C_HORIZONTAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + constants C_VERTICAL_BOTTOM type ZEXCEL_ALIGNMENT value 'bottom'. "#EC NOTEXT + constants C_VERTICAL_TOP type ZEXCEL_ALIGNMENT value 'top'. "#EC NOTEXT + constants C_VERTICAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_VERTICAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + data HORIZONTAL type ZEXCEL_ALIGNMENT . + data VERTICAL type ZEXCEL_ALIGNMENT . + data TEXTROTATION type ZEXCEL_TEXT_ROTATION value 0. "#EC NOTEXT . + data WRAPTEXT type FLAG . + data SHRINKTOFIT type FLAG . + data INDENT type ZEXCEL_INDENT value 0. "#EC NOTEXT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_ALIGNMENT) type ZEXCEL_S_STYLE_ALIGNMENT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + horizontal = me->c_horizontal_general. + vertical = me->c_vertical_bottom. + wrapText = abap_false. + shrinkToFit = abap_false. +endmethod. + + + + METHOD get_structure. + + es_alignment-horizontal = me->horizontal. + es_alignment-vertical = me->vertical. + es_alignment-textrotation = me->textrotation. + es_alignment-wraptext = me->wraptext. + es_alignment-shrinktofit = me->shrinktofit. + es_alignment-indent = me->indent. + +ENDMETHOD. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk new file mode 100644 index 0000000..ce7231e --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk @@ -0,0 +1,65 @@ + + + class ZCL_EXCEL_STYLE_BORDER definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +public section. + + data BORDER_STYLE type ZEXCEL_BORDER . + data BORDER_COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_BORDER_NONE type ZEXCEL_BORDER value 'none'. "#EC NOTEXT . + class-data C_BORDER_DASHDOT type ZEXCEL_BORDER value 'dashDot'. "#EC NOTEXT . + class-data C_BORDER_DASHDOTDOT type ZEXCEL_BORDER value 'dashDotDot'. "#EC NOTEXT . + class-data C_BORDER_DASHED type ZEXCEL_BORDER value 'dashed'. "#EC NOTEXT . + class-data C_BORDER_DOTTED type ZEXCEL_BORDER value 'dotted'. "#EC NOTEXT . + class-data C_BORDER_DOUBLE type ZEXCEL_BORDER value 'double'. "#EC NOTEXT . + class-data C_BORDER_HAIR type ZEXCEL_BORDER value 'hair'. "#EC NOTEXT . + class-data C_BORDER_MEDIUM type ZEXCEL_BORDER value 'medium'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOT type ZEXCEL_BORDER value 'mediumDashDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOTDOT type ZEXCEL_BORDER value 'mediumDashDotDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHED type ZEXCEL_BORDER value 'mediumDashed'. "#EC NOTEXT . + class-data C_BORDER_SLANTDASHDOT type ZEXCEL_BORDER value 'slantDashDot'. "#EC NOTEXT . + class-data C_BORDER_THICK type ZEXCEL_BORDER value 'thick'. "#EC NOTEXT . + class-data C_BORDER_THIN type ZEXCEL_BORDER value 'thin'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + border_style = zcl_excel_style_border=>c_border_none. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDERS.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDERS.slnk new file mode 100644 index 0000000..bab81e1 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDERS.slnk @@ -0,0 +1,97 @@ + + + class ZCL_EXCEL_STYLE_BORDERS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +public section. + + data LEFT type ref to ZCL_EXCEL_STYLE_BORDER . + data RIGHT type ref to ZCL_EXCEL_STYLE_BORDER . + data TOP type ref to ZCL_EXCEL_STYLE_BORDER . + data DOWN type ref to ZCL_EXCEL_STYLE_BORDER . + data DIAGONAL type ref to ZCL_EXCEL_STYLE_BORDER . + data ALLBORDERS type ref to ZCL_EXCEL_STYLE_BORDER . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_BORDER . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +private section. + + constants C_DIAGONAL_NONE type ZEXCEL_DIAGONAL value 0. "#EC NOTEXT + constants C_DIAGONAL_UP type ZEXCEL_DIAGONAL value 1. "#EC NOTEXT + constants C_DIAGONAL_DOWN type ZEXCEL_DIAGONAL value 2. "#EC NOTEXT + constants C_DIAGONAL_BOTH type ZEXCEL_DIAGONAL value 3. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method CONSTRUCTOR. +endmethod. + + + + method GET_STRUCTURE. + +* Check if all borders is set otherwise check single border + IF me->allborders IS BOUND. + es_fill-left_color = me->allborders->border_color. + es_fill-left_style = me->allborders->border_style. + es_fill-right_color = me->allborders->border_color. + es_fill-right_style = me->allborders->border_style. + es_fill-top_color = me->allborders->border_color. + es_fill-top_style = me->allborders->border_style. + es_fill-bottom_color = me->allborders->border_color. + es_fill-bottom_style = me->allborders->border_style. + ELSE. + IF me->left IS BOUND. + es_fill-left_color = me->left->border_color. + es_fill-left_style = me->left->border_style. + ENDIF. + IF me->right IS BOUND. + es_fill-right_color = me->right->border_color. + es_fill-right_style = me->right->border_style. + ENDIF. + IF me->top IS BOUND. + es_fill-top_color = me->top->border_color. + es_fill-top_style = me->top->border_style. + ENDIF. + IF me->down IS BOUND. + es_fill-bottom_color = me->down->border_color. + es_fill-bottom_style = me->down->border_style. + ENDIF. + ENDIF. + +* Check if diagonal is set + IF me->diagonal IS BOUND. + es_fill-diagonal_color = me->diagonal->border_color. + es_fill-diagonal_style = me->diagonal->border_style. + ENDIF. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk new file mode 100644 index 0000000..3b2ef61 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk @@ -0,0 +1,78 @@ + + + class ZCL_EXCEL_STYLE_COLOR definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +public section. + + class-data C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT . + class-data C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT . + class-data C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT . + class-data C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT . + class-data C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT . + class-data C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT . + class-data C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT . + class-data C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT . + class-data C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT . + class-data C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT . + class-data C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT . + + methods CONSTRUCTOR . + class-methods CREATE_NEW_ARGB + importing + !IP_RED type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_GREEN type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_BLU type ZEXCEL_STYLE_COLOR_COMPONENT + returning + value(EP_COLOR_ARGB) type ZEXCEL_STYLE_COLOR_ARGB . + *"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +private section. + + class-data C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + method CONSTRUCTOR. + + +endmethod. + + + + + + + method CREATE_NEW_ARGB. + + + CONCATENATE zcl_excel_style_color=>c_alpha ip_red ip_green ip_blu INTO ep_color_argb. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk new file mode 100644 index 0000000..b11d274 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk @@ -0,0 +1,167 @@ + + + class ZCL_EXCEL_STYLE_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +public section. + + class-data C_ICONSET_3ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '3Arrows'. "#EC NOTEXT . + class-data C_ICONSET_3ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '3ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_3FLAGS type ZEXCEL_CONDITION_RULE_ICONSET value '3Flags'. "#EC NOTEXT . + class-data C_ICONSET_3SIGNS type ZEXCEL_CONDITION_RULE_ICONSET value '3Signs'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols2'. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value ''. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3TrafficLights2'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '4Arrows'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '4ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_4RATING type ZEXCEL_CONDITION_RULE_ICONSET value '4Rating'. "#EC NOTEXT . + class-data C_ICONSET_4REDTOBLACK type ZEXCEL_CONDITION_RULE_ICONSET value '4RedToBlack'. "#EC NOTEXT . + class-data C_ICONSET_4TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value '4TrafficLights'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '5Arrows'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '5ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_5QUARTERS type ZEXCEL_CONDITION_RULE_ICONSET value '5Quarters'. "#EC NOTEXT . + class-data C_ICONSET_5RATING type ZEXCEL_CONDITION_RULE_ICONSET value '5Rating'. "#EC NOTEXT . + class-data C_OPERATOR_BEGINSWITH type ZEXCEL_CONDITION_OPERATOR value 'beginsWith'. "#EC NOTEXT . + class-data C_OPERATOR_BETWEEN type ZEXCEL_CONDITION_OPERATOR value 'between'. "#EC NOTEXT . + class-data C_OPERATOR_CONTAINSTEXT type ZEXCEL_CONDITION_OPERATOR value 'containsText'. "#EC NOTEXT . + class-data C_OPERATOR_ENDSWITH type ZEXCEL_CONDITION_OPERATOR value 'endsWith'. "#EC NOTEXT . + class-data C_OPERATOR_EQUAL type ZEXCEL_CONDITION_OPERATOR value 'equal'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHAN type ZEXCEL_CONDITION_OPERATOR value 'greaterThan'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'greaterThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHAN type ZEXCEL_CONDITION_OPERATOR value 'lessThan'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'lessThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_NONE type ZEXCEL_CONDITION_OPERATOR value ''. "#EC NOTEXT . + class-data C_OPERATOR_NOTCONTAINS type ZEXCEL_CONDITION_OPERATOR value 'notContains'. "#EC NOTEXT . + class-data C_OPERATOR_NOTEQUAL type ZEXCEL_CONDITION_OPERATOR value 'notEqual'. "#EC NOTEXT . + class-data C_RULE_CELLIS type ZEXCEL_CONDITION_RULE value 'cellIs'. "#EC NOTEXT . + class-data C_RULE_CONTAINSTEXT type ZEXCEL_CONDITION_RULE value 'containsText'. "#EC NOTEXT . + class-data C_RULE_EXPRESSION type ZEXCEL_CONDITION_RULE value 'expression'. "#EC NOTEXT . + class-data C_RULE_ICONSET type ZEXCEL_CONDITION_RULE value 'iconSet'. "#EC NOTEXT . + class-data C_RULE_NONE type ZEXCEL_CONDITION_RULE value 'none'. "#EC NOTEXT . + data FORMULA type ZEXCEL_STYLE_FORMULA . + data ICONSET type ZEXCEL_CONDITION_RULE_ICONSET . + data OPERATOR type ZEXCEL_CONDITION_OPERATOR . + data PRIORITY type ZEXCEL_STYLE_PRIORITY value 1. "#EC NOTEXT . + data RULE type ZEXCEL_CONDITION_RULE . + + methods CONSTRUCTOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods SET_RANGE + importing + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data START_CELL type ZEXCEL_S_CELL_DATA . + data STOP_CELL type ZEXCEL_S_CELL_DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + rule = me->c_rule_none. + operator = me->c_operator_none. +* inizialize dimension range + stop_cell-cell_row = 1. + stop_cell-cell_column = 1. + start_cell-cell_row = 1. + start_cell-cell_column = 1. +endmethod. + + + + method GET_DIMENSION_RANGE. + IF stop_cell EQ start_cell. "only one cell + ep_dimension_range = start_cell-cell_coords. + ELSE. + CONCATENATE start_cell-cell_coords ':' stop_cell-cell_coords INTO ep_dimension_range. + ENDIF. +endmethod. + + + + + + + method SET_RANGE. + DATA: lv_column TYPE zexcel_cell_column, + lv_row_alpha TYPE string. + + lv_column = zcl_excel_common=>convert_column2int( ip_stop_column ). + stop_cell-cell_row = 1. + stop_cell-cell_column = lv_column. + lv_row_alpha = ip_stop_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_stop_column lv_row_alpha INTO stop_cell-cell_coords. + + lv_column = zcl_excel_common=>convert_column2int( ip_start_column ). + start_cell-cell_row = 1. + start_cell-cell_column = lv_column. + lv_row_alpha = ip_start_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_start_column lv_row_alpha INTO start_cell-cell_coords. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk new file mode 100644 index 0000000..a15cb44 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk @@ -0,0 +1,96 @@ + + + class ZCL_EXCEL_STYLE_FILL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +public section. + + class-data C_FILL_NONE type ZEXCEL_FILL_TYPE value 'none'. "#EC NOTEXT . + class-data C_FILL_SOLID type ZEXCEL_FILL_TYPE value 'solid'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_LINEAR type ZEXCEL_FILL_TYPE value 'linear'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_PATH type ZEXCEL_FILL_TYPE value 'path'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKDOWN type ZEXCEL_FILL_TYPE value 'darkDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRAY type ZEXCEL_FILL_TYPE value 'darkGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRID type ZEXCEL_FILL_TYPE value 'darkGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKHORIZONTAL type ZEXCEL_FILL_TYPE value 'darkHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKTRELLIS type ZEXCEL_FILL_TYPE value 'darkTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKUP type ZEXCEL_FILL_TYPE value 'darkUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKVERTICAL type ZEXCEL_FILL_TYPE value 'darkVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY0625 type ZEXCEL_FILL_TYPE value 'gray0625'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY125 type ZEXCEL_FILL_TYPE value 'gray125'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTDOWN type ZEXCEL_FILL_TYPE value 'lightDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRAY type ZEXCEL_FILL_TYPE value 'lightGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRID type ZEXCEL_FILL_TYPE value 'lightGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTHORIZONTAL type ZEXCEL_FILL_TYPE value 'lightHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTTRELLIS type ZEXCEL_FILL_TYPE value 'lightTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTUP type ZEXCEL_FILL_TYPE value 'lightUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTVERTICAL type ZEXCEL_FILL_TYPE value 'lightVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_MEDIUMGRAY type ZEXCEL_FILL_TYPE value 'mediumGray'. "#EC NOTEXT . + data FILLTYPE type ZEXCEL_FILL_TYPE . + data ROTATION type ZEXCEL_ROTATION . + data FGCOLOR type ZEXCEL_STYLE_COLOR_ARGB . + data BGCOLOR type ZEXCEL_STYLE_COLOR_ARGB value '64'. "#EC NOTEXT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_FILL . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + filltype = zcl_excel_style_fill=>c_fill_none. + rotation = 0. +endmethod. + + + + method GET_STRUCTURE. + es_fill-rotation = me->rotation. + es_fill-filltype = me->filltype. + es_fill-fgColor = me->fgColor. + es_fill-bgColor = me->bgColor. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk new file mode 100644 index 0000000..c65d0e3 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk @@ -0,0 +1,92 @@ + + + class ZCL_EXCEL_STYLE_FONT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data BOLD type FLAG . + data COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_SCHEME_MAJOR type ZEXCEL_STYLE_FONT_SCHEME value 'major'. "#EC NOTEXT . + class-data C_SCHEME_MINOR type ZEXCEL_STYLE_FONT_SCHEME value 'minor'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLE type CHAR20 value 'double'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLEACCOUNTING type CHAR20 value 'doubleAccounting'. "#EC NOTEXT . + class-data C_UNDERLINE_NONE type CHAR20 value 'none'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLE type CHAR20 value 'single'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLEACCOUNTING type CHAR20 value 'singleAccounting'. "#EC NOTEXT . + data FAMILY type INT1 value 2. "#EC NOTEXT . + data ITALIC type FLAG . + data NAME type CHAR255 value 'Calibri'. "#EC NOTEXT . + data SCHEME type ZEXCEL_STYLE_FONT_SCHEME . + data SIZE type INT1 value 11. "#EC NOTEXT . + data STRIKETHROUGH type FLAG . + data UNDERLINE type FLAG . + data UNDERLINE_MODE type CHAR20 . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FONT) type ZEXCEL_S_STYLE_FONT . + *"* protected components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + me->color = zcl_excel_style_color=>c_black. + me->scheme = zcl_excel_style_font=>c_scheme_minor. + me->underline_mode = zcl_excel_style_font=>c_underline_single. +endmethod. + + + + method GET_STRUCTURE. + + es_font-bold = me->bold. + es_font-italic = me->italic. + es_font-underline = me->underline. + es_font-underline_mode = me->underline_mode. + es_font-strikethrough = me->strikethrough. + es_font-size = me->size. + es_font-color = me->color. + es_font-name = me->name. + es_font-family = me->family. + es_font-scheme = me->scheme. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk new file mode 100644 index 0000000..3719a6c --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_NUMBER_FORMAT.slnk @@ -0,0 +1,111 @@ + + + class ZCL_EXCEL_STYLE_NUMBER_FORMAT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +public section. + + class-data C_FORMAT_NUMBER type ZEXCEL_NUMBER_FORMAT value '0'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_00 type ZEXCEL_NUMBER_FORMAT value '0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP1 type ZEXCEL_NUMBER_FORMAT value '#,##0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP2 type ZEXCEL_NUMBER_FORMAT value '#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE type ZEXCEL_NUMBER_FORMAT value '0%'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE_00 type ZEXCEL_NUMBER_FORMAT value '0.00%'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD2 type ZEXCEL_NUMBER_FORMAT value 'yyyy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD type ZEXCEL_NUMBER_FORMAT value 'yy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DDMMYYYY type ZEXCEL_NUMBER_FORMAT value 'dd/mm/yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYSLASH type ZEXCEL_NUMBER_FORMAT value 'd/m/y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m'. "#EC NOTEXT . + class-data C_FORMAT_DATE_MYMINUS type ZEXCEL_NUMBER_FORMAT value 'm-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX14 type ZEXCEL_NUMBER_FORMAT value 'mm-dd-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX15 type ZEXCEL_NUMBER_FORMAT value 'd-mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX16 type ZEXCEL_NUMBER_FORMAT value 'd-mmm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX17 type ZEXCEL_NUMBER_FORMAT value 'mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX22 type ZEXCEL_NUMBER_FORMAT value 'm/d/yy h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DATETIME type ZEXCEL_NUMBER_FORMAT value 'd/m/y h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME1 type ZEXCEL_NUMBER_FORMAT value 'h:mm AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME2 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME3 type ZEXCEL_NUMBER_FORMAT value 'h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME4 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME5 type ZEXCEL_NUMBER_FORMAT value 'mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME6 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME7 type ZEXCEL_NUMBER_FORMAT value 'i:s.S'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME8 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss@'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDDSLASH type ZEXCEL_NUMBER_FORMAT value 'yy/mm/dd@'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD_SIMPLE type ZEXCEL_NUMBER_FORMAT value '"$"#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD type ZEXCEL_NUMBER_FORMAT value '$#,##0_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_EUR_SIMPLE type ZEXCEL_NUMBER_FORMAT value '[$EUR ]#,##0.00_-'. "#EC NOTEXT . + data FORMAT_CODE type ZEXCEL_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(EP_NUMBER_FORMAT) type ZEXCEL_S_STYLE_NUMFMT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +private section. + + class-data C_FORMAT_GENERAL type ZEXCEL_NUMBER_FORMAT value ''. "#EC NOTEXT . + class-data C_FORMAT_TEXT type ZEXCEL_NUMBER_FORMAT value '@'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + format_code = me->c_format_general. +endmethod. + + + + method GET_STRUCTURE. + ep_number_format-numfmt = me->format_code. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_PROTECTION.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_PROTECTION.slnk new file mode 100644 index 0000000..ff898d1 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_PROTECTION.slnk @@ -0,0 +1,44 @@ + + + class ZCL_EXCEL_STYLE_PROTECTION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +public section. + + constants C_PROTECTION_INHERIT type ZEXCEL_PROTECTION value 'inherit'. "#EC NOTEXT + constants C_PROTECTION_PROTECTED type ZEXCEL_PROTECTION value 'protected'. "#EC NOTEXT + constants C_PROTECTION_UNPROTECTED type ZEXCEL_PROTECTION value 'unprotected'. "#EC NOTEXT + data LOCKED type ZEXCEL_PROTECTION . + data HIDDEN type ZEXCEL_PROTECTION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + method CONSTRUCTOR. + locked = me->c_protection_inherit. + hidden = me->c_protection_inherit. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk b/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk new file mode 100644 index 0000000..e8583d9 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk @@ -0,0 +1,244 @@ + + + class ZCL_EXCEL_TABLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants BUILTINSTYLE_DARK1 type ZEXCEL_TABLE_STYLE value 'TableStyleDark1'. "#EC NOTEXT + constants BUILTINSTYLE_DARK2 type ZEXCEL_TABLE_STYLE value 'TableStyleDark2'. "#EC NOTEXT + constants BUILTINSTYLE_DARK3 type ZEXCEL_TABLE_STYLE value 'TableStyleDark3'. "#EC NOTEXT + constants BUILTINSTYLE_DARK4 type ZEXCEL_TABLE_STYLE value 'TableStyleDark4'. "#EC NOTEXT + constants BUILTINSTYLE_DARK5 type ZEXCEL_TABLE_STYLE value 'TableStyleDark5'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT1 type ZEXCEL_TABLE_STYLE value 'TableStyleLight1'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT2 type ZEXCEL_TABLE_STYLE value 'TableStyleLight2'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT3 type ZEXCEL_TABLE_STYLE value 'TableStyleLight3'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT4 type ZEXCEL_TABLE_STYLE value 'TableStyleLight4'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT5 type ZEXCEL_TABLE_STYLE value 'TableStyleLight5'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM1 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium1'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM2 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium2'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM3 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium3'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM4 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium4'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM5 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium5'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM9 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium9'. "#EC NOTEXT + constants BUILTINSTYLE_PIVOT_LIGHT16 type ZEXCEL_TABLE_STYLE value 'PivotStyleLight16'. "#EC NOTEXT + data FIELDCAT type ZEXCEL_T_FIELDCATALOG . + data SETTINGS type ZEXCEL_S_TABLE_SETTINGS . + constants TOTALS_FUNCTION_AVERAGE type ZEXCEL_TABLE_TOTALS_FUNCTION value 'average'. "#EC NOTEXT + constants TOTALS_FUNCTION_COUNT type ZEXCEL_TABLE_TOTALS_FUNCTION value 'count'. "#EC NOTEXT + constants TOTALS_FUNCTION_MAX type ZEXCEL_TABLE_TOTALS_FUNCTION value 'max'. "#EC NOTEXT + constants TOTALS_FUNCTION_MIN type ZEXCEL_TABLE_TOTALS_FUNCTION value 'min'. "#EC NOTEXT + constants TOTALS_FUNCTION_SUM type ZEXCEL_TABLE_TOTALS_FUNCTION value 'sum'. "#EC NOTEXT + + methods GET_TOTALS_FORMULA + importing + !IP_COLUMN type CLIKE + !IP_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION + returning + value(EP_FORMULA) type STRING . + methods HAS_TOTALS + returning + value(EP_RESULT) type ABAP_BOOL . + methods SET_DATA + importing + !IR_DATA type STANDARD TABLE . + methods GET_ID + returning + value(OV_ID) type I . + methods SET_ID + importing + !IV_ID type I . + methods CONSTRUCTOR . + methods GET_NAME + returning + value(OV_NAME) type STRING . + methods GET_REFERENCE + importing + !IP_INCLUDE_TOTALS_ROW type ABAP_BOOL default ABAP_TRUE + returning + value(OV_REFERENCE) type STRING . + *"* protected components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +private section. + + data ID type I . + data NAME type STRING . + data TABLE_DATA type ref to DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + +endmethod. + + + + method GET_ID. + ov_id = id. +endmethod. + + + + method GET_NAME. + + IF me->name IS INITIAL. + me->name = zcl_excel_common=>number_to_excel_string( ip_value = me->id ). + CONCATENATE 'table' me->name INTO me->name. + ENDIF. + + ov_name = me->name. +endmethod. + + + + + method GET_REFERENCE. + DATA: lv_column TYPE zexcel_cell_column, + lv_table_lines TYPE i, + lv_right_column TYPE zexcel_cell_column_alpha, + ls_field_catalog TYPE zexcel_s_fieldcatalog, + lv_bottom_row TYPE zexcel_cell_row, + lv_top_row_string(10) TYPE c, + lv_bottom_row_string(10) TYPE c. + + FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE. + +*column + lv_column = zcl_excel_common=>convert_column2int( settings-top_left_column ). + lv_table_lines = 0. + LOOP AT fieldcat INTO ls_field_catalog WHERE dynpfld EQ abap_true. + ADD 1 TO lv_table_lines. + ENDLOOP. + lv_column = lv_column + lv_table_lines - 1. + lv_right_column = zcl_excel_common=>convert_column2alpha( lv_column ). + +*row + ASSIGN table_data->* TO <fs_table>. + DESCRIBE TABLE <fs_table> LINES lv_table_lines. + lv_bottom_row = settings-top_left_row + lv_table_lines . + + IF me->has_totals( ) = abap_true AND ip_include_totals_row = abap_true. + add 1 to lv_bottom_row. + ENDIF. + + WRITE settings-top_left_row TO lv_top_row_string. + CONDENSE lv_top_row_string. + WRITE lv_bottom_row TO lv_bottom_row_string. + CONDENSE lv_bottom_row_string. + + CONCATENATE settings-top_left_column lv_top_row_string + ':' + lv_right_column lv_bottom_row_string INTO ov_reference. + +endmethod. + + + + + + method GET_TOTALS_FORMULA. + CONSTANTS: lc_function_id_sum TYPE string VALUE '109', + lc_function_id_min TYPE string VALUE '105', + lc_function_id_max TYPE string VALUE '104', + lc_function_id_count TYPE string VALUE '103', + lc_function_id_average TYPE string VALUE '101'. + + DATA: lv_function_id TYPE string. + + CASE ip_function. + WHEN zcl_excel_table=>totals_function_sum. + lv_function_id = lc_function_id_sum. + + WHEN zcl_excel_table=>totals_function_min. + lv_function_id = lc_function_id_min. + + WHEN zcl_excel_table=>totals_function_max. + lv_function_id = lc_function_id_max. + + WHEN zcl_excel_table=>totals_function_count. + lv_function_id = lc_function_id_count. + + WHEN zcl_excel_table=>totals_function_average. + lv_function_id = lc_function_id_average. + + WHEN OTHERS. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Invalid totals formula. See ZCL_ for possible values'. + ENDCASE. + + CONCATENATE 'SUBTOTAL(' lv_function_id ',[' ip_column '])' INTO ep_formula. +endmethod. + + + + method HAS_TOTALS. + DATA: ls_field_catalog TYPE zexcel_s_fieldcatalog. + + ep_result = abap_false. + + LOOP AT fieldcat INTO ls_field_catalog. + IF ls_field_catalog-totals_function IS NOT INITIAL. + ep_result = abap_true. + EXIT. + ENDIF. + ENDLOOP. + +endmethod. + + + + method SET_DATA. + GET REFERENCE OF ir_data INTO me->table_data. +endmethod. + + + + method SET_ID. + id = iv_id. +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk new file mode 100644 index 0000000..709fcc8 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -0,0 +1,873 @@ + + + class ZCL_EXCEL_WORKSHEET definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + class-data C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT . + class-data C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT . + class-data C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT . + class-data C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_CONTENT_MERGE type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHEET_STATE type ZEXCEL_SHEET_STATE . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + + methods ADD_NEW_CONDITIONAL_STYLE + returning + value(EO_CONDITIONAL_STYLE) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods ADD_NEW_DATA_VALIDATION + returning + value(EO_DATA_VALIDATION) type ref to ZCL_EXCEL_DATA_VALIDATION . + methods BIND_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IT_FIELD_CATALOG type ZEXCEL_T_FIELDCATALOG optional + !IS_TABLE_SETTINGS type ZEXCEL_S_TABLE_SETTINGS optional . + methods CONSTRUCTOR + importing + !IP_EXCEL type ref to ZCL_EXCEL + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods DELETE_MERGE . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING . + methods GET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC . + methods GET_COLUMN_DIMENSION + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(R_COLUMN_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods GET_COLUMN_DIMENSIONS + returning + value(R_COLUMN_DIMENSION) type ZEXCEL_T_WORKSHEET_COLUMNDIME . + methods GET_COND_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_SIZE + returning + value(EP_SIZE) type I . + methods GET_DEFAULT_COLUMN_DIMENSION + returning + value(R_COLUMN_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods GET_DEFAULT_ROW_DIMENSION + returning + value(R_ROW_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods GET_GUID + returning + value(EP_GUID) type OLTPGUID16 . + methods GET_HIGHEST_COLUMN + returning + value(R_HIGHEST_COLUMN) type ZEXCEL_CELL_COLUMN . + methods GET_HIGHEST_ROW + returning + value(R_HIGHEST_ROW) type INT4 . + methods GET_MERGE + returning + value(MERGE_RANGE) type STRING_TABLE . + methods GET_ROW_DIMENSION + importing + !IP_ROW type INT4 + returning + value(R_ROW_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . + methods GET_ROW_DIMENSIONS + returning + value(R_ROW_DIMENSION) type ZEXCEL_T_WORKSHEET_ROWDIMENSIO . + methods SET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type SIMPLE optional + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional . + methods SET_CELL_STYLE + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_STYLE type ZEXCEL_CELL_STYLE + raising + ZCX_EXCEL . + methods SET_MERGE + importing + !IP_COLUMN_START type ZEXCEL_CELL_COLUMN_ALPHA optional + !IP_COLUMN_END type ZEXCEL_CELL_COLUMN_ALPHA optional + !IP_ROW type ZEXCEL_CELL_ROW optional . + methods SET_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . + methods GET_TABLES_SIZE + returning + value(EP_SIZE) type I . + methods GET_TABLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + *"* protected components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CONDITIONAL_STYLES type ref to ZCL_EXCEL_STYLES_CONDITIONAL . + data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . + data GUID type OLTPGUID16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + data COLUMN_DIMENSIONS type ZEXCEL_T_WORKSHEET_COLUMNDIME . + data ROW_DIMENSIONS type ZEXCEL_T_WORKSHEET_ROWDIMENSIO . + data DEFAULT_COLUMN_DIMENSION type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + data DEFAULT_ROW_DIMENSION type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . + data EXCEL type ref to ZCL_EXCEL . + data TABLES type ref to CL_OBJECT_COLLECTION . + + methods UPDATE_DIMENSION_RANGE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + method ADD_NEW_CONDITIONAL_STYLE. + + CREATE OBJECT eo_conditional_style. + conditional_styles->add( eo_conditional_style ). +endmethod. + + + + method ADD_NEW_DATA_VALIDATION. + + CREATE OBJECT eo_data_validation. + data_validations->add( eo_data_validation ). +endmethod. + + + + + + METHOD bind_table. + + DATA: + lv_row_int TYPE zexcel_cell_row, + lv_first_row TYPE zexcel_cell_row, + lv_last_row TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lt_field_catalog TYPE zexcel_t_fieldcatalog, + lv_id TYPE i, + lv_rows TYPE i, + lv_formula TYPE string, + ls_settings TYPE zexcel_s_table_settings, + lo_table TYPE REF TO zcl_excel_table, + lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line, + lv_value TYPE string, + lv_syindex TYPE char3. + + CONSTANTS: + lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'B', + lc_top_left_row TYPE zexcel_cell_row VALUE '3'. + + FIELD-SYMBOLS: <ls_field_catalog> TYPE zexcel_s_fieldcatalog, + <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY. + + ls_settings = is_table_settings. + + IF ls_settings-top_left_column IS INITIAL. + ls_settings-top_left_column = lc_top_left_column. + ENDIF. + + IF ls_settings-table_style IS INITIAL. + ls_settings-table_style = zcl_excel_table=>builtinstyle_medium2. + ENDIF. + + IF ls_settings-top_left_row IS INITIAL. + ls_settings-top_left_row = lc_top_left_row. + ENDIF. + + IF it_field_catalog IS NOT SUPPLIED. + lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = ip_table ). + ELSE. + lt_field_catalog = it_field_catalog. + ENDIF. + + CREATE OBJECT lo_table. + lo_table->settings = ls_settings. + lo_table->set_data( ir_data = ip_table ). + lv_id = me->excel->get_next_table_id( ). + lo_table->set_id( iv_id = lv_id ). +* lo_table->fieldcat = lt_field_catalog[]. + + me->tables->add( lo_table ). + + lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ). + lv_row_int = ls_settings-top_left_row. + + " get the row number + DESCRIBE TABLE ip_table LINES lv_rows. + +* It is better to loop column by column (only visible column) + LOOP AT lt_field_catalog ASSIGNING <ls_field_catalog> WHERE dynpfld EQ abap_true. + + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + + " Due restrinction of new table object we cannot have two column with the same name + " Check if a column with the same name exists, if exists add a counter + lv_value = <ls_field_catalog>-scrtext_m. + WHILE 1 = 1. + READ TABLE lt_column_name_buffer TRANSPORTING NO FIELDS WITH KEY table_line = lv_value BINARY SEARCH. + IF sy-subrc <> 0. + <ls_field_catalog>-scrtext_m = lv_value. + INSERT lv_value INTO TABLE lt_column_name_buffer. + EXIT. + ELSE. + lv_syindex = sy-index. + CONCATENATE <ls_field_catalog>-scrtext_m lv_syindex INTO lv_value. + ENDIF. + ENDWHILE. + " First of all write column header + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_value ). + + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <ls_field_catalog>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = <fs_fldval> + ). + ADD 1 TO lv_row_int. + ENDLOOP. + + " totals + IF <ls_field_catalog>-totals_function IS NOT INITIAL. + lv_formula = lo_table->get_totals_formula( ip_column = <ls_field_catalog>-scrtext_m ip_function = <ls_field_catalog>-totals_function ). + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = lv_formula ). + ENDIF. + + lv_row_int = ls_settings-top_left_row. + ADD 1 TO lv_column_int. + + " conditional formatting + IF <ls_field_catalog>-cond_style IS NOT INITIAL. + lv_first_row = ls_settings-top_left_row + 1. " +1 to exclude header + lv_last_row = ls_settings-top_left_row + lv_rows. + <ls_field_catalog>-cond_style->set_range( ip_start_column = lv_column_alpha + ip_start_row = lv_first_row + ip_stop_column = lv_column_alpha + ip_stop_row = lv_last_row ). + ENDIF. + ENDLOOP. + + " Set field catalog + lo_table->fieldcat = lt_field_catalog[]. + +ENDMETHOD. + + + + + method CONSTRUCTOR. + + me->excel = ip_excel. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + sheet_state = me->c_sheet_state_visible. + + CREATE OBJECT sheet_setup. + CREATE OBJECT conditional_styles. + CREATE OBJECT data_validations. + CREATE OBJECT tables. + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +endmethod. + + + method DELETE_MERGE. + + DELETE sheet_content_merge INDEX 1. + DELETE sheet_content_merge INDEX 1. + +endmethod. + + + + method GET_ACTIVE_CELL. + + DATA: lv_active_column TYPE zexcel_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = zcl_excel_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + +endmethod. + + + + + + + method GET_CELL. + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = ip_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. +endmethod. + + + + + method GET_COLUMN_DIMENSION. + FIELD-SYMBOLS: <fs_column_dimension> LIKE LINE OF column_dimensions. + + READ TABLE me->column_dimensions ASSIGNING <fs_column_dimension> + WITH KEY column = ip_column. + + IF NOT <fs_column_dimension> IS ASSIGNED. + CREATE OBJECT r_column_dimension + EXPORTING + ip_index = ip_column. + APPEND INITIAL LINE TO me->column_dimensions ASSIGNING <fs_column_dimension>. + <fs_column_dimension>-column = ip_column. + <fs_column_dimension>-column_dimension = r_column_dimension. + ELSE. + r_column_dimension = <fs_column_dimension>-column_dimension. + ENDIF. + +endmethod. + + + + method GET_COLUMN_DIMENSIONS. + r_column_dimension[] = me->column_dimensions[]. +endmethod. + + + + method GET_COND_STYLES_ITERATOR. + + eo_iterator = me->conditional_styles->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_ITERATOR. + + eo_iterator = me->data_validations->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_SIZE. + ep_size = me->data_validations->size( ). +endmethod. + + + + method GET_DEFAULT_COLUMN_DIMENSION. + r_column_dimension = me->default_column_dimension. +endmethod. + + + + method GET_DEFAULT_ROW_DIMENSION. + r_row_dimension = me->default_row_dimension. +endmethod. + + + + method GET_DIMENSION_RANGE. + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + ep_dimension_range = upper_cell-cell_coords. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + +endmethod. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + method GET_HIGHEST_COLUMN. + me->update_dimension_range( ). + r_highest_column = me->lower_cell-cell_column. +endmethod. + + + + method GET_HIGHEST_ROW. + me->update_dimension_range( ). + r_highest_row = me->lower_cell-cell_row. +endmethod. + + + + method GET_MERGE. + + DATA: lv_column_start TYPE string, + lv_column_end TYPE string, + lv_row TYPE string, + lv_index TYPE sy-tabix, + ls_sheet_content TYPE zexcel_s_cell_data, + range_from TYPE string, + range_to TYPE string, + lv_merge_range TYPE string, + lv_count TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + DESCRIBE TABLE sheet_content_merge LINES lv_count. + + WHILE lv_count GT lv_index. +* LOOP AT sheet_content_merge ASSIGNING <fs_sheet_content>. + lv_index = lv_index + 1. + READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX lv_index. + lv_column_start = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). + lv_row = <fs_sheet_content>-cell_row. + SHIFT lv_column_start RIGHT DELETING TRAILING space. + SHIFT lv_column_start LEFT DELETING LEADING space. + SHIFT lv_row RIGHT DELETING TRAILING space. + SHIFT lv_row LEFT DELETING LEADING space. + CONCATENATE lv_column_start lv_row + INTO range_from. + + lv_index = lv_index + 1. + READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX lv_index. + lv_column_end = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). + SHIFT lv_column_end RIGHT DELETING TRAILING space. + SHIFT lv_column_end LEFT DELETING LEADING space. + CONCATENATE lv_column_end lv_row + INTO range_to. + + CONCATENATE range_from range_to INTO lv_merge_range + SEPARATED BY ':'. + APPEND lv_merge_range TO merge_range. + ENDWHILE. +* ENDLOOP. + +* READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX 1. +* IF sy-subrc EQ 0 AND <fs_sheet_content> IS ASSIGNED. +* lv_column_start = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). +* lv_row = <fs_sheet_content>-cell_row. +* SHIFT lv_column_start RIGHT DELETING TRAILING space. +* SHIFT lv_column_start LEFT DELETING LEADING space. +* SHIFT lv_row RIGHT DELETING TRAILING space. +* SHIFT lv_row LEFT DELETING LEADING space. +* CONCATENATE lv_column_start lv_row +* INTO range_from. +* ENDIF. +* READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX 2. +* IF sy-subrc EQ 0 AND <fs_sheet_content> IS ASSIGNED. +* lv_column_end = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). +* SHIFT lv_column_end RIGHT DELETING TRAILING space. +* SHIFT lv_column_end LEFT DELETING LEADING space. +* CONCATENATE lv_column_end lv_row +* INTO range_to. +* ENDIF. + +* IF range_from NE space AND range_to NE space. +* CONCATENATE range_from range_to INTO ep_merge_range +* SEPARATED BY ':'. +* ENDIF. + +endmethod. + + + + + method GET_ROW_DIMENSION. + FIELD-SYMBOLS: <fs_row_dimension> LIKE LINE OF row_dimensions. + + READ TABLE me->row_dimensions ASSIGNING <fs_row_dimension> + WITH KEY row = ip_row. + + IF NOT <fs_row_dimension> IS ASSIGNED. + CREATE OBJECT r_row_dimension + EXPORTING + ip_index = ip_row. + APPEND INITIAL LINE TO me->row_dimensions ASSIGNING <fs_row_dimension>. + <fs_row_dimension>-row = ip_row. + <fs_row_dimension>-row_dimension = r_row_dimension. + ELSE. + r_row_dimension = <fs_row_dimension>-row_dimension. + ENDIF. + +endmethod. + + + + method GET_ROW_DIMENSIONS. + r_row_dimension[] = me->row_dimensions[]. +endmethod. + + + + method GET_TABLES_ITERATOR. + eo_iterator = tables->get_iterator( ). +endmethod. + + + + method GET_TABLES_SIZE. + ep_size = tables->size( ). +endmethod. + + + + + + + + method SET_CELL. + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string, + lv_value TYPE zexcel_cell_value, + lv_data_type TYPE zexcel_cell_data_type, + lv_value_type TYPE abap_typekind, + lo_style TYPE REF TO zcl_excel_style, + lv_style_guid TYPE zexcel_cell_style. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + IF ip_value IS NOT SUPPLIED AND ip_formula IS NOT SUPPLIED. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Pleas provide the vaue or formula'. + ENDIF. + + lv_style_guid = ip_style. + + IF ip_value IS SUPPLIED. + DESCRIBE FIELD ip_value TYPE lv_value_type. + CASE lv_value_type. + WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2 OR + cl_abap_typedescr=>typekind_float OR cl_abap_typedescr=>typekind_packed. + lv_value = zcl_excel_common=>number_to_excel_string( ip_value = ip_value ). + + WHEN cl_abap_typedescr=>typekind_char OR cl_abap_typedescr=>typekind_string OR cl_abap_typedescr=>typekind_num. + lv_value = ip_value. + lv_data_type = 's'. + + WHEN cl_abap_typedescr=>typekind_date. + lv_value = zcl_excel_common=>date_to_excel_string( ip_value = ip_value ). + + IF ip_style IS NOT SUPPLIED. "get default date format for user in case parameter is initial + lo_style = excel->add_new_style( ). + cl_abap_datfm=>get_date_format_des( IMPORTING ex_dateformat = lo_style->number_format->format_code ). + lv_style_guid = lo_style->get_guid( ). + ENDIF. + + WHEN cl_abap_typedescr=>typekind_time. + lv_value = zcl_excel_common=>time_to_excel_string( ip_value = ip_value ). + + IF ip_style IS NOT SUPPLIED. "get default time format for user in case parameter is initial + lo_style = excel->add_new_style( ). + lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_date_time6. + lv_style_guid = lo_style->get_guid( ). + ENDIF. + + WHEN OTHERS. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Invalid data type of input value'. + ENDCASE. + ENDIF. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_value = lv_value. + <fs_sheet_content>-cell_formula = ip_formula. + <fs_sheet_content>-cell_style = lv_style_guid. + <fs_sheet_content>-data_type = lv_data_type. + ELSE. + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column. + ls_sheet_content-cell_value = lv_value. + ls_sheet_content-cell_formula = ip_formula. + ls_sheet_content-cell_style = lv_style_guid. + ls_sheet_content-data_type = lv_data_type. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content. + SORT sheet_content BY cell_row cell_column. + " me->update_dimension_range( ). + + ENDIF. + +endmethod. + + + + + + + method SET_CELL_STYLE. + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string, + lo_style TYPE REF TO zcl_excel_style, + lv_style_guid TYPE zexcel_cell_style. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_style_guid = ip_style. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_style = lv_style_guid. + ELSE. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'No Data in this cell'. + ENDIF. + +endmethod. + + + + + + method SET_MERGE. + + DATA: lv_column_start TYPE zexcel_cell_column, + lv_column_end TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column_start = zcl_excel_common=>convert_column2int( ip_column_start ). + lv_column_end = zcl_excel_common=>convert_column2int( ip_column_end ). + + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column_start. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column_start lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content_merge. + + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column_end. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column_end lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content_merge. + +endmethod. + + + + + + + + + method SET_TABLE. + + DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, + lr_data TYPE REF TO data, + ls_newline TYPE REF TO data, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + lv_row_header TYPE zexcel_cell_row VALUE '2', + lv_col_header TYPE zexcel_cell_column_alpha VALUE 'B', + lv_row_int TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lv_cell_value TYPE zexcel_cell_value. + + + FIELD-SYMBOLS: <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY, + <fs_dfies> TYPE dfies, + <fs_cell_value> TYPE zexcel_cell_value. + + lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). + lv_row_int = ip_top_left_row. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + +* It is better to loop column by column + LOOP AT lt_dfies ASSIGNING <fs_dfies>. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + " First of all write column header + lv_cell_value = <fs_dfies>-scrtext_m. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_hdr_style ). + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <fs_dfies>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + MOVE <fs_fldval> TO lv_cell_value. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_body_style ). + ADD 1 TO lv_row_int. + ENDLOOP. + lv_row_int = ip_top_left_row. + ADD 1 TO lv_column_int. + ENDLOOP. + +endmethod. + + + method UPDATE_DIMENSION_RANGE. + + DATA: ls_sheet_content TYPE zexcel_s_cell_data, + lt_sheet_content TYPE zexcel_t_cell_data_unsorted, + lv_row_alpha TYPE string, + lv_column_alpha TYPE zexcel_cell_column_alpha. + +* update dimension range + lt_sheet_content = sheet_content. + "upper left corner + SORT lt_sheet_content BY cell_row. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = upper_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( upper_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO upper_cell-cell_coords. + + "bottom right corner + SORT lt_sheet_content BY cell_row DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = lower_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lower_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEETS.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEETS.slnk new file mode 100644 index 0000000..77ee784 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEETS.slnk @@ -0,0 +1,121 @@ + + + class ZCL_EXCEL_WORKSHEETS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +public section. + + data ACTIVE_WORKSHEET type ZEXCEL_ACTIVE_WORKSHEET value 1. "#EC NOTEXT . + data NAME type ZEXCEL_WORKSHEETS_NAME value 'Worksheets'. "#EC NOTEXT . + + methods ADD + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +private section. + + data WORKSHEETS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + method ADD. + + worksheets->add( ip_worksheet ). + +endmethod. + + + method CLEAR. + + worksheets->clear( ). + +endmethod. + + + method CONSTRUCTOR. + + CREATE OBJECT worksheets. + +endmethod. + + + + + method GET. + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_worksheet ?= worksheets->if_object_collection~get( lv_index ). + +endmethod. + + + + method GET_ITERATOR. + + eo_iterator ?= worksheets->if_object_collection~get_iterator( ). + +endmethod. + + + + method IS_EMPTY. + + is_empty = worksheets->if_object_collection~is_empty( ). + +endmethod. + + + + method REMOVE. + + worksheets->remove( ip_worksheet ). + +endmethod. + + + + method SIZE. + + ep_size = worksheets->if_object_collection~size( ). + +endmethod. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk new file mode 100644 index 0000000..9fd066d --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk @@ -0,0 +1,240 @@ + + + class ZCL_EXCEL_WORKSHEET_COLUMNDIME definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET_COLUMNDIME +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + methods CONSTRUCTOR + importing + !IP_INDEX type ZEXCEL_CELL_COLUMN_ALPHA . + methods GET_COLUMN_INDEX + returning + value(R_COLUMN_INDEX) type INT4 . + methods GET_OUTLINE_LEVEL + returning + value(R_OUTLINE_LEVEL) type INT4 . + methods GET_WIDTH + returning + value(R_WIDTH) type FLOAT . + methods GET_XF_INDEX + returning + value(R_XF_INDEX) type INT4 . + methods SET_COLUMN_INDEX + importing + !IP_INDEX type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods SET_OUTLINE_LEVEL + importing + !IP_OUTLINE_LEVEL type INT4 . + methods SET_WIDTH + importing + !IP_WIDTH type FLOAT + returning + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods SET_XF_INDEX + importing + !IP_XF_INDEX type INT4 + returning + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods GET_AUTO_SIZE + returning + value(R_AUTO_SIZE) type ABAP_BOOL . + methods GET_COLLAPSED + returning + value(R_COLLAPSED) type ABAP_BOOL . + methods GET_VISIBLE + returning + value(R_VISIBLE) type ABAP_BOOL . + methods SET_AUTO_SIZE + importing + !IP_AUTO_SIZE type ABAP_BOOL + returning + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods SET_COLLAPSED + importing + !IP_COLLAPSED type ABAP_BOOL + returning + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods SET_VISIBLE + importing + !IP_VISIBLE type ABAP_BOOL + returning + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + *"* protected components of class ZCL_EXCEL_WORKSHEET_COLUMNDIME +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET_COLUMNDIME +*"* do not include other source files here!!! +private section. + + data COLUMN_INDEX type INT4 . + data WIDTH type FLOAT . + type-pools ABAP . + data AUTO_SIZE type ABAP_BOOL . + data VISIBLE type ABAP_BOOL . + data OUTLINE_LEVEL type INT4 . + data COLLAPSED type ABAP_BOOL . + data XF_INDEX type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + ABAP + + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 Gregor Wolf +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Gregor Wolf +* @homepage http://www.computerservice-wolf.com/ +* @copyright Copyright (c) 2010 Gregor Wolf +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.5, 2010-08-11 +********************************************************************** + me->column_index = zcl_excel_common=>convert_column2int( ip_index ). + me->width = -1. + me->auto_size = abap_false. + me->visible = abap_true. + me->outline_level = 0. + me->collapsed = abap_false. + + " set default index to cellXf + me->xf_index = 0. +ENDMETHOD. + + + + METHOD get_auto_size. + r_auto_size = me->auto_size. +ENDMETHOD. + + + + METHOD GET_COLLAPSED. + r_Collapsed = me->Collapsed. +ENDMETHOD. + + + + METHOD get_column_index. + r_column_index = me->column_index. +ENDMETHOD. + + + + METHOD get_outline_level. + r_outline_level = me->outline_level. +ENDMETHOD. + + + + METHOD GET_VISIBLE. + r_Visible = me->Visible. +ENDMETHOD. + + + + METHOD GET_WIDTH. + r_WIDTH = me->WIDTH. +ENDMETHOD. + + + + METHOD get_xf_index. + r_xf_index = me->xf_index. +ENDMETHOD. + + + + + METHOD set_auto_size. + me->auto_size = ip_auto_size. + r_worksheet_columndime = me. +ENDMETHOD. + + + + + METHOD SET_COLLAPSED. + me->Collapsed = ip_Collapsed. + r_worksheet_columndime = me. +ENDMETHOD. + + + + + METHOD set_column_index. + me->column_index = zcl_excel_common=>convert_column2int( ip_index ). + r_worksheet_columndime = me. +ENDMETHOD. + + + + METHOD set_outline_level. + me->outline_level = ip_outline_level. +ENDMETHOD. + + + + + METHOD SET_VISIBLE. + me->Visible = ip_Visible. + r_worksheet_columndime = me. +ENDMETHOD. + + + + + METHOD set_width. + me->width = ip_width. + r_worksheet_columndime = me. +ENDMETHOD. + + + + + METHOD SET_XF_INDEX. + me->XF_INDEX = ip_XF_INDEX. + r_worksheet_columndime = me. +ENDMETHOD. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk new file mode 100644 index 0000000..b53547c --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk @@ -0,0 +1,179 @@ + + + class ZCL_EXCEL_WORKSHEET_ROWDIMENSI definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET_ROWDIMENSI +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + methods CONSTRUCTOR + importing + !IP_INDEX type INT4 default 0 . + methods GET_OUTLINE_LEVEL + returning + value(R_OUTLINE_LEVEL) type INT4 . + methods GET_ROW_INDEX + returning + value(R_ROW_INDEX) type INT4 . + methods GET_XF_INDEX + returning + value(R_XF_INDEX) type INT4 . + methods SET_OUTLINE_LEVEL + importing + !IP_OUTLINE_LEVEL type INT4 + raising + ZCX_EXCEL . + methods SET_ROW_INDEX + importing + !IP_INDEX type INT4 . + methods SET_XF_INDEX + importing + !IP_XF_INDEX type INT4 . + methods GET_ROW_HEIGHT + returning + value(R_ROW_HEIGHT) type FLOAT . + methods SET_ROW_HEIGHT + importing + !IP_ROW_HEIGHT type FLOAT . + methods GET_COLLAPSED + returning + value(R_COLLAPSED) type BOOLEAN . + methods GET_VISIBLE + returning + value(R_VISIBLE) type BOOLEAN . + methods SET_COLLAPSED + importing + !IP_COLLAPSED type BOOLEAN . + methods SET_VISIBLE + importing + !IP_VISIBLE type BOOLEAN . + *"* protected components of class ZCL_EXCEL_WORKSHEET_ROWDIMENSI +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET_ROWDIMENSI +*"* do not include other source files here!!! +private section. + + data ROW_INDEX type INT4 . + data ROW_HEIGHT type FLOAT . + data VISIBLE type BOOLEAN . + data OUTLINE_LEVEL type INT4 value 0. "#EC NOTEXT . + data COLLAPSED type BOOLEAN . + data XF_INDEX type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + ABAP + + + + + + + + + METHOD constructor. + " Initialise values + me->row_index = ip_index. + me->row_height = -1. + me->visible = abap_true. + me->outline_level = 0. + me->collapsed = abap_false. + + " set row dimension as unformatted by default + me->xf_index = 0. +ENDMETHOD. + + + + METHOD get_collapsed. + r_collapsed = me->collapsed. +ENDMETHOD. + + + + METHOD get_outline_level. + r_outline_level = me->outline_level. +ENDMETHOD. + + + + METHOD get_row_height. + r_row_height = me->row_height. +ENDMETHOD. + + + + METHOD get_row_index. + r_row_index = me->row_index. +ENDMETHOD. + + + + METHOD get_visible. + r_visible = me->visible. +ENDMETHOD. + + + + METHOD get_xf_index. + r_xf_index = me->xf_index. +ENDMETHOD. + + + + METHOD set_collapsed. + me->collapsed = ip_collapsed. +ENDMETHOD. + + + + + METHOD set_outline_level. + IF ip_outline_level < 0 + OR ip_outline_level > 7. + + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Outline level must range between 0 and 7.'. + + ENDIF. + me->outline_level = ip_outline_level. +ENDMETHOD. + + + + METHOD set_row_height. + me->row_height = ip_row_height. +ENDMETHOD. + + + + METHOD set_row_index. + me->row_index = ip_index. +ENDMETHOD. + + + + METHOD set_visible. + me->visible = ip_visible. +ENDMETHOD. + + + + METHOD SET_XF_INDEX. + me->XF_INDEX = ip_XF_INDEX. +ENDMETHOD. + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk new file mode 100644 index 0000000..291dc83 --- /dev/null +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -0,0 +1,3147 @@ + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + interfaces ZIF_EXCEL_WRITER . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_TABLE + importing + !IO_TABLE type ref to ZCL_EXCEL_TABLE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* 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. + ep_file = me->create( ). +ENDMETHOD. + + + + method CREATE. + + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_nested_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string, + lv_value TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( lo_worksheet ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + + lo_nested_iterator = lo_worksheet->get_tables_iterator( ). + + WHILE lo_nested_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_table ?= lo_nested_iterator->if_object_collection_iterator~get_next( ). + lv_content = me->create_xl_table( lo_table ). + + lv_value = lo_table->get_name( ). + CONCATENATE 'xl/tables/' lv_value '.xml' into lv_value. + lo_zip->add( name = lv_value + content = lv_content ). + ENDWHILE. + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +endmethod. + + + + method CREATE_CONTENT_TYPES. + + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml', + lc_xml_node_table_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_nested_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i, + lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_worksheet_ct ). + lo_element_root->append_child( lo_element ). + ENDDO. + + lo_iterator = me->excel->get_worksheets_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->get_next( ). + + lo_nested_iterator = lo_worksheet->get_tables_iterator( ). + + WHILE lo_nested_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_nested_iterator->get_next( ). + + lv_value = lo_table->get_name( ). + CONCATENATE '/xl/tables/' lv_value '.xml' INTO lv_value. + + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_table_ct ). + lo_element_root->append_child( lo_element ). + ENDWHILE. + ENDWHILE. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_APP. + + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_CORE. + + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_RELATIONSHIPS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_RELATIONSHIPS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_SHAREDSTRINGS. + + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + + method CREATE_XL_SHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software. you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation. either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY. without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library. if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_sheetpr TYPE string VALUE 'sheetPr', + lc_xml_node_outlinepr TYPE string VALUE 'outlinePr', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_cols TYPE string VALUE 'cols', + lc_xml_node_col TYPE string VALUE 'col', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + lc_xml_node_datavalidations TYPE string VALUE 'dataValidations', + lc_xml_node_datavalidation TYPE string VALUE 'dataValidation', + lc_xml_node_formula1 TYPE string VALUE 'formula1', + lc_xml_node_mergecell TYPE string VALUE 'mergeCell', + lc_xml_node_mergecells TYPE string VALUE 'mergeCells', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_summarybelow TYPE string VALUE 'summaryBelow', + lc_xml_attr_summaryright TYPE string VALUE 'summaryRight', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_showgridlines TYPE string VALUE 'showGridLines', + lc_xml_attr_showrowcolheaders TYPE string VALUE 'showRowColHeaders', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_min TYPE string VALUE 'min', + lc_xml_attr_max TYPE string VALUE 'max', + lc_xml_attr_hidden TYPE string VALUE 'hidden', + lc_xml_attr_width TYPE string VALUE 'width', + lc_xml_attr_defaultwidth TYPE string VALUE '9.10', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_true TYPE string VALUE 'true', + lc_xml_attr_bestfit TYPE string VALUE 'bestFit', + lc_xml_attr_customheight TYPE string VALUE 'customHeight', + lc_xml_attr_customwidth TYPE string VALUE 'customWidth', + lc_xml_attr_collapsed TYPE string VALUE 'collapsed', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_defaultcolwidth TYPE string VALUE 'defaultColWidth', + lc_xml_attr_outlinelevelrow TYPE string VALUE 'x14ac:outlineLevelRow', + lc_xml_attr_outlinelevelcol TYPE string VALUE 'x14ac:outlineLevelCol', + lc_xml_attr_outlinelevel TYPE string VALUE 'outlineLevel', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + lc_xml_attr_allowblank TYPE string VALUE 'allowBlank', + lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage', + lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage', + lc_xml_attr_count TYPE string VALUE 'count', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + lc_xml_node_comp_ns TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006', + lc_xml_node_comp_pref TYPE string VALUE 'x14ac', + lc_xml_node_ig_ns TYPE string VALUE 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_value TYPE string, + t_range_merge TYPE string_table, + lv_merge TYPE string, + lv_column_p TYPE zexcel_cell_column_alpha, + lv_column TYPE zexcel_cell_column, + lv_flag TYPE c, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + lv_cell_row_s TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + DATA: default_col_dimension TYPE REF TO zcl_excel_worksheet_columndime, + default_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data, + <fs_range_merge> LIKE LINE OF t_range_merge. + DATA: column_dimensions TYPE zexcel_t_worksheet_columndime. + FIELD-SYMBOLS: <column_dimension> LIKE LINE OF column_dimensions. + DATA: row_dimensions TYPE zexcel_t_worksheet_rowdimensio. + FIELD-SYMBOLS: <row_dimension> LIKE LINE OF row_dimensions. + DATA: outline_level_row TYPE i VALUE 0, + outline_level_col TYPE i VALUE 0. + DATA: col_count TYPE int4. + DATA: row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + DATA: write_current_row TYPE boolean. +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:mc' + value = lc_xml_node_comp_ns ). + lo_element_root->set_attribute_ns( name = 'mc:Ignorable' + value = lc_xml_node_comp_pref ). + lo_element_root->set_attribute_ns( name = 'xmlns:x14ac' + value = lc_xml_node_ig_ns ). + + +********************************************************************** +* STEP 4: Create subnodes + " sheetPr + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetpr + parent = lo_document ). + " TODO tabColor + + " outlinePr + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_outlinepr + parent = lo_document ). + " TODO read attribute summaryBelow and set the attribute to 0 + lo_element_2->set_attribute_ns( name = lc_xml_attr_summarybelow + value = '1' ). + " TODO read attribute summaryRight and set the attribute to 0 + lo_element_2->set_attribute_ns( name = lc_xml_attr_summaryright + value = '1' ). + + lo_element->append_child( lo_element_2 ). + " TODO pageSetUpPr + + lo_element_root->append_child( lo_element ). + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + " showGridLines attribute + lo_element_2->set_attribute_ns( name = lc_xml_attr_showgridlines + value = 'true' ). + " showRowColHeaders attribute + lo_element_2->set_attribute_ns( name = lc_xml_attr_showrowcolheaders + value = '1' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + column_dimensions[] = io_worksheet->get_column_dimensions( ). + row_dimensions[] = io_worksheet->get_row_dimensions( ). + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + " defaultRowHeight + default_row_dimension = io_worksheet->get_default_row_dimension( ). + IF default_row_dimension IS BOUND. + IF default_row_dimension->get_row_height( ) >= 0. + lo_element->set_attribute_ns( name = lc_xml_attr_customheight + value = lc_xml_attr_true ). + lv_value = default_row_dimension->get_row_height( ). + ELSE. + lv_value = '12.75'. + ENDIF. + ELSE. + lv_value = '12.75'. + ENDIF. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + " defaultColWidth + default_col_dimension = io_worksheet->get_default_column_dimension( ). + IF default_col_dimension IS BOUND. + IF default_col_dimension->get_width( ) >= 0. + lv_value = default_col_dimension->get_width( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultcolwidth + value = lv_value ). + ENDIF. + ENDIF. + " outlineLevelRow + LOOP AT row_dimensions ASSIGNING <row_dimension>. + IF <row_dimension>-row_dimension->get_outline_level( ) > outline_level_row. + outline_level_row = <row_dimension>-row_dimension->get_outline_level( ). + ENDIF. + ENDLOOP. + lv_value = outline_level_row. + lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelrow + value = lv_value ). + " outlineLevelCol + LOOP AT column_dimensions ASSIGNING <column_dimension>. + IF <column_dimension>-column_dimension->get_outline_level( ) > outline_level_col. + outline_level_col = <column_dimension>-column_dimension->get_outline_level( ). + ENDIF. + ENDLOOP. + lv_value = outline_level_col. + lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelcol + value = lv_value ). + + lo_element_root->append_child( lo_element ). " sheetFormatPr node + " cols node + IF NOT column_dimensions IS INITIAL. + lo_element = lo_document->create_simple_element( name = lc_xml_node_cols + parent = lo_document ). + LOOP AT column_dimensions ASSIGNING <column_dimension>. + " col node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_col + parent = lo_document ). + lv_value = <column_dimension>-column_dimension->get_column_index( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_min + value = lv_value ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_max + value = lv_value ). + " Width + IF <column_dimension>-column_dimension->get_width( ) < 0. + lo_element_2->set_attribute_ns( name = lc_xml_attr_width + value = lc_xml_attr_defaultwidth ). + ELSE. + lv_value = <column_dimension>-column_dimension->get_width( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_width + value = lv_value ). + ENDIF. + " Column visibility + IF <column_dimension>-column_dimension->get_visible( ) = abap_false. + lo_element_2->set_attribute_ns( name = lc_xml_attr_hidden + value = lc_xml_attr_true ). + ENDIF. + " Auto size? + IF <column_dimension>-column_dimension->get_auto_size( ) = abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_bestfit + value = lc_xml_attr_true ). + ENDIF. + " Custom width? + IF default_col_dimension IS BOUND. + IF <column_dimension>-column_dimension->get_width( ) + <> default_col_dimension->get_width( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_customwidth + value = lc_xml_attr_true ). + + ENDIF. + ELSE. + lo_element_2->set_attribute_ns( name = lc_xml_attr_customwidth + value = lc_xml_attr_true ). + ENDIF. + " Collapsed + IF <column_dimension>-column_dimension->get_collapsed( ) = abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_collapsed + value = lc_xml_attr_true ). + ENDIF. + " outlineLevel + IF <column_dimension>-column_dimension->get_outline_level( ) > 0. + lv_value = <column_dimension>-column_dimension->get_outline_level( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_outlinelevel + value = lv_value ). + ENDIF. + " Style + lv_value = <column_dimension>-column_dimension->get_xf_index( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + + lo_element->append_child( lo_element_2 ). " col node + ENDLOOP. + ENDIF. + lo_element_root->append_child( lo_element ). " cols node + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + " Get column count + col_count = io_worksheet->get_highest_column( ). + + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + " Add new row + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + " r + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + " Spans + lv_value = col_count. + CONCATENATE '1:' lv_value INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = lv_value ). + row_dimension = io_worksheet->get_row_dimension( <ls_sheet_content>-cell_row ). + " Do we need the row dimension attributes? + IF row_dimension->get_row_height( ) >= 0 OR + row_dimension->get_visible( ) = abap_false OR + row_dimension->get_collapsed( ) = abap_true OR + row_dimension->get_outline_level( ) > 0 OR + row_dimension->get_xf_index( ) <> 0. + " Row dimensions + IF row_dimension->get_row_height( ) >= 0. + lo_element_2->set_attribute_ns( name = 'customHeight' value = '1'). + lv_value = row_dimension->get_row_height( ). + lo_element_2->set_attribute_ns( name = 'ht' value = lv_value ). + ENDIF. + " Row visibility + IF row_dimension->get_visible( ) = abap_false. + lo_element_2->set_attribute_ns( name = 'hidden' value = 'true'). + ENDIF. + " Collapsed + IF row_dimension->get_collapsed( ) = abap_true. + lo_element_2->set_attribute_ns( name = 'collapsed' value = 'true'). + ENDIF. + " Outline level + IF row_dimension->get_outline_level( ) > 0. + lv_value = row_dimension->get_outline_level( ). + lo_element_2->set_attribute_ns( name = 'outlineLevel' value = lv_value ). + ENDIF. + " Style + IF row_dimension->get_xf_index( ) <> 0. + lv_value = row_dimension->get_xf_index( ). + lo_element_2->set_attribute_ns( name = 's' value = lv_value ). + lo_element_2->set_attribute_ns( name = 'customFormat' value = '1'). + ENDIF. + ENDIF. + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + + " For cells with formula ignore the value - Excel will calculate it + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ELSE. + IF <ls_sheet_content>-data_type IS NOT INITIAL. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = <ls_sheet_content>-data_type ). + ENDIF. + + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF <ls_sheet_content>-data_type EQ 's'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + ENDIF. + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + + + IF io_worksheet->get_data_validations_size( ) GT 0. + " dataValidations node + lo_element = lo_document->create_simple_element( name = lc_xml_node_datavalidations + parent = lo_document ). + " Conditional formatting node + lo_iterator = io_worksheet->get_data_validations_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_data_validation ?= lo_iterator->get_next( ). + " dataValidation node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_datavalidation + parent = lo_document ). + lv_value = lo_data_validation->type. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + IF lo_data_validation->allowblank EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_allowblank + value = lv_value ). + IF lo_data_validation->showinputmessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showinputmessage + value = lv_value ). + IF lo_data_validation->showerrormessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showerrormessage + value = lv_value ). + lv_cell_row_s = lo_data_validation->cell_row. + SHIFT lv_cell_row_s RIGHT DELETING TRAILING space. + SHIFT lv_cell_row_s LEFT DELETING LEADING space. + CONCATENATE lo_data_validation->cell_column lv_cell_row_s INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + " formula1 node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula1 + parent = lo_document ). + lv_value = lo_data_validation->value. + lo_element_3->set_value( lv_value ). + + lo_element_2->append_child( lo_element_3 ). " formula1 node + + lo_element->append_child( lo_element_2 ). " dataValidation node + ENDWHILE. + lo_element_root->append_child( lo_element ). " dataValidations node + ENDIF. + + t_range_merge = io_worksheet->get_merge( ). + IF t_range_merge IS NOT INITIAL. + lo_element = lo_document->create_simple_element( name = lc_xml_node_mergecells + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + LOOP AT t_range_merge ASSIGNING <fs_range_merge>. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_mergecell + parent = lo_document ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_ref + value = <fs_range_merge> ). + lo_element->append_child( lo_element_2 ). + lo_element_root->append_child( lo_element ). + io_worksheet->delete_merge( ). + ENDLOOP. + ENDIF. + + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +* tables + DATA lv_table_count TYPE i. + + lv_table_count = io_worksheet->get_tables_size( ). + IF lv_table_count > 0. + lo_element = lo_document->create_simple_element( name = 'tableParts' + parent = lo_document ). + lv_value = lv_table_count. + CONDENSE lv_value. + lo_element->set_attribute_ns( name = 'count' + value = lv_value ). + + lv_table_count = 0. + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_iterator->get_next( ). + add 1 to lv_table_count. + + lv_value = lv_table_count. + condense lv_value. + CONCATENATE 'rId' lv_value INTO lv_value. + lo_element_2 = lo_document->create_simple_element( name = 'tablePart' + parent = lo_element ). + lo_element_2->set_attribute_ns( name = 'r:id' + value = lv_value ). + lo_element->append_child( lo_element_2 ). + + ENDWHILE. + + lo_element_root->append_child( lo_element ). + + ENDIF. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + method CREATE_XL_SHEET_RELS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + lc_xml_node_rid_table_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_value TYPE string, + lv_counter TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Add sheet Relationship nodes here + lv_counter = 0. + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_iterator->get_next( ). + ADD 1 TO lv_counter. + + lv_value = lv_counter. + CONDENSE lv_value. + CONCATENATE 'rId' lv_value INTO lv_value. + + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_table_tp ). + + lv_value = lo_table->get_name( ). + CONCATENATE '../tables/' lv_value '.xml' INTO lv_value. + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_value ). + lo_element_root->append_child( lo_element ). + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + METHOD create_xl_styles. + + +** Constant node name + CONSTANTS: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " numfmt + lc_xml_node_numfmts TYPE string VALUE 'numFmts', + lc_xml_node_numfmt TYPE string VALUE 'numFmt', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + lc_xml_node_alignment TYPE string VALUE 'alignment', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + lc_xml_attr_applyalignment TYPE string VALUE 'applyAlignment', + lc_xml_attr_horizontal TYPE string VALUE 'horizontal', + lc_xml_attr_formatcode TYPE string VALUE 'formatCode', + lc_xml_attr_vertical TYPE string VALUE 'vertical', + lc_xml_attr_wraptext TYPE string VALUE 'wrapText', + lc_xml_attr_textrotation TYPE string VALUE 'textRotation', + lc_xml_attr_shrinktofit TYPE string VALUE 'shrinkToFit', + lc_xml_attr_indent TYPE string VALUE 'indent', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + CONSTANTS: lc_on TYPE string VALUE '1', + lc_off TYPE string VALUE '0'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_numfmts TYPE REF TO if_ixml_element, + lo_element_numfmt TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + lt_numfmts TYPE zexcel_t_style_numfmt, + ls_numfmt TYPE zexcel_s_style_numfmt, + lt_alignments TYPE zexcel_t_style_alignment, + ls_alignment TYPE zexcel_s_style_alignment, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i, + lv_align_flag TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + + lo_element_numfmts = lo_document->create_simple_element( name = lc_xml_node_numfmts + parent = lo_document ). + + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_alignment = lo_style->alignment->get_structure( ). + ls_numfmt = lo_style->number_format->get_structure( ). + + CLEAR ls_cellxfs. + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress alignment + READ TABLE lt_alignments FROM ls_alignment TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-alignmentid = sy-tabix. + ELSE. + APPEND ls_alignment TO lt_alignments. + DESCRIBE TABLE lt_alignments LINES ls_cellxfs-alignmentid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-alignmentid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + +* Compress number formats + IF ls_numfmt IS NOT INITIAL. + READ TABLE lt_numfmts FROM ls_numfmt TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-numfmtid = sy-tabix. + ELSE. + APPEND ls_numfmt TO lt_numfmts. + DESCRIBE TABLE lt_numfmts LINES ls_cellxfs-numfmtid. + ENDIF. + ADD zcl_excel_common=>c_excel_numfmt_offset TO ls_cellxfs-numfmtid. " Add OXML offset for custom styles + ls_cellxfs-applynumberformat = 1. + ELSE. + ls_cellxfs-applynumberformat = 0. + ENDIF. + + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-alignmentid NE 0. + ls_cellxfs-applyalignment = 1. + ELSE. + ls_cellxfs-applyalignment = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create numfmt elements + LOOP AT lt_numfmts INTO ls_numfmt. + lo_element_numfmt = lo_document->create_simple_element( name = lc_xml_node_numfmt + parent = lo_document ). + lv_value = sy-tabix + zcl_excel_common=>c_excel_numfmt_offset. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_numfmt->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + lv_value = ls_numfmt-numfmt. + lo_element_numfmt->set_attribute_ns( name = lc_xml_attr_formatcode + value = lv_value ). + lo_element_numfmts->append_child( lo_element_numfmt ). + ENDLOOP. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_numfmts ). + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lc_off ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyalignment EQ 1. " depends on each style not for all the sheet + MOVE ls_cellxfs-applyalignment TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyalignment + value = lv_value ). + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_alignment + parent = lo_document ). + ADD 1 TO ls_cellxfs-alignmentid. "Table index starts from 1 + READ TABLE lt_alignments INTO ls_alignment INDEX ls_cellxfs-alignmentid. + SUBTRACT 1 FROM ls_cellxfs-alignmentid. + IF ls_alignment-horizontal IS NOT INITIAL. + MOVE ls_alignment-horizontal TO lv_value. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_horizontal + value = lv_value ). + ENDIF. + IF ls_alignment-vertical IS NOT INITIAL. + MOVE ls_alignment-vertical TO lv_value. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_vertical + value = lv_value ). + ENDIF. + IF ls_alignment-wraptext EQ abap_true. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_wraptext + value = lc_on ). + ENDIF. + IF ls_alignment-textrotation IS NOT INITIAL. + MOVE ls_alignment-textrotation TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_textrotation + value = lv_value ). + ENDIF. + IF ls_alignment-shrinktofit EQ abap_true. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_shrinktofit + value = lc_on ). + ENDIF. + IF ls_alignment-indent IS NOT INITIAL. + MOVE ls_alignment-indent TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indent + value = lv_value ). + ENDIF. + + lo_element->append_child( lo_sub_element_2 ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = lc_off ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = zcl_excel_table=>builtinstyle_medium9 ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = zcl_excel_table=>builtinstyle_pivot_light16 ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + METHOD create_xl_table. + + DATA: lc_xml_node_table TYPE string VALUE 'table', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_display_name TYPE string VALUE 'displayName', + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_totals TYPE string VALUE 'totalsRowShown', + " Node namespace + lc_xml_node_table_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + + lv_table_name TYPE string, + lv_id TYPE i, + lv_syindex TYPE char3, + lv_ref TYPE string, + lv_value TYPE string, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lv_num_columns TYPE i, + ls_fieldcat TYPE zexcel_s_fieldcatalog. + + +********************************************************************** +* STEP 1: Create xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node table + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_table + parent = lo_document ). + + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_table_ns ). + + lv_id = io_table->get_id( ). + lv_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_id ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_id + value = lv_value ). + + lv_table_name = io_table->get_name( ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_name + value = lv_table_name ). + + lo_element_root->set_attribute_ns( name = lc_xml_attr_display_name + value = lv_table_name ). + + lv_ref = io_table->get_reference( ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_ref + value = lv_ref ). + IF io_table->has_totals( ) = abap_true. + lo_element_root->set_attribute_ns( name = 'totalsRowCount' + value = '1' ). + ELSE. + lo_element_root->set_attribute_ns( name = lc_xml_attr_totals + value = '0' ). + ENDIF. + +********************************************************************** +* STEP 4: Create subnodes + + " autoFilter + lo_element = lo_document->create_simple_element( name = 'autoFilter' + parent = lo_document ). + + lv_ref = io_table->get_reference( ip_include_totals_row = abap_false ). + lo_element->set_attribute_ns( name = 'ref' + value = lv_ref ). + + lo_element_root->append_child( lo_element ). + + "columns + lo_element = lo_document->create_simple_element( name = 'tableColumns' + parent = lo_document ). + +* lo_columns = io_table->get_columns( ). + LOOP AT io_table->fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true. + ADD 1 TO lv_num_columns. + ENDLOOP. + + lv_value = lv_num_columns. + CONDENSE lv_value. + lo_element->set_attribute_ns( name = 'count' + value = lv_value ). + + lo_element_root->append_child( lo_element ). + + LOOP AT io_table->fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true. + lo_element2 = lo_document->create_simple_element_ns( name = 'tableColumn' + parent = lo_element ). + + lv_value = ls_fieldcat-position. + SHIFT lv_value LEFT DELETING LEADING '0'. + lo_element2->set_attribute_ns( name = 'id' + value = lv_value ). + lv_value = ls_fieldcat-scrtext_m. + lo_element2->set_attribute_ns( name = 'name' + value = lv_value ). + + IF ls_fieldcat-totals_function IS NOT INITIAL. + lo_element2->set_attribute_ns( name = 'totalsRowFunction' + value = ls_fieldcat-totals_function ). + ENDIF. + + lo_element->append_child( lo_element2 ). + ENDLOOP. + + + lo_element = lo_document->create_simple_element( name = 'tableStyleInfo' + parent = lo_element_root ). + + lo_element->set_attribute_ns( name = 'name' + value = io_table->settings-table_style ). + + lo_element->set_attribute_ns( name = 'showFirstColumn' + value = '0' ). + + lo_element->set_attribute_ns( name = 'showLastColumn' + value = '0' ). + + IF io_table->settings-show_row_stripes = abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + + lo_element->set_attribute_ns( name = 'showRowStripes' + value = lv_value ). + + IF io_table->settings-show_column_stripes = abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + + lo_element->set_attribute_ns( name = 'showColumnStripes' + value = lv_value ). + + lo_element_root->append_child( lo_element ). +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + method CREATE_XL_THEME. + + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +endmethod. + + + + method CREATE_XL_WORKBOOK. + + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + lc_xml_node_definednames TYPE string VALUE 'definedNames', + lc_xml_node_definedname TYPE string VALUE 'definedName', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + + " ranges node + lo_element = lo_document->create_simple_element( name = lc_xml_node_definedNames + parent = lo_document ). + lo_iterator = excel->get_ranges_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " range node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_definedName + parent = lo_document ). + lo_range ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_range->name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lv_value = lo_range->get_value( ). + lo_sub_element->set_value( lv_value ). + lo_element->append_child( lo_sub_element ). " range node + ENDWHILE. + lo_element_root->append_child( lo_element )." ranges node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + method FLAG2BOOL. + + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +endmethod. + + + + + method GET_SHARED_STRING_INDEX. + + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +endmethod. + + diff --git a/ZA2X/CLAS/ZCX_EXCEL.slnk b/ZA2X/CLAS/ZCX_EXCEL.slnk new file mode 100644 index 0000000..4bb07f7 --- /dev/null +++ b/ZA2X/CLAS/ZCX_EXCEL.slnk @@ -0,0 +1,59 @@ + + + class ZCX_EXCEL definition + public + inheriting from CX_STATIC_CHECK + final + create public . + +*"* public components of class ZCX_EXCEL +*"* do not include other source files here!!! +public section. + + constants ZCX_EXCEL type SOTR_CONC value 'DFA64849FDF4F6F1B39A000C29B7D360'. "#EC NOTEXT + data ERROR type STRING . + + methods CONSTRUCTOR + importing + !TEXTID like TEXTID optional + !PREVIOUS like PREVIOUS optional + !ERROR type STRING optional . + *"* protected components of class ZCX_EXCEL +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCX_EXCEL +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + method CONSTRUCTOR. +CALL METHOD SUPER->CONSTRUCTOR +EXPORTING +TEXTID = TEXTID +PREVIOUS = PREVIOUS +. + IF textid IS INITIAL. + me->textid = ZCX_EXCEL . + ENDIF. +me->ERROR = ERROR . +endmethod. + + diff --git a/ZA2X/DOMA/ZEXCEL_FORMAT.slnk b/ZA2X/DOMA/ZEXCEL_FORMAT.slnk new file mode 100644 index 0000000..101645f --- /dev/null +++ b/ZA2X/DOMA/ZEXCEL_FORMAT.slnk @@ -0,0 +1,5 @@ + + + + + diff --git a/ZA2X/DTEL/ZEXCEL_ACTIVE_WORKSHEET.slnk b/ZA2X/DTEL/ZEXCEL_ACTIVE_WORKSHEET.slnk new file mode 100644 index 0000000..67203ff --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_ACTIVE_WORKSHEET.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_ALIGNMENT.slnk b/ZA2X/DTEL/ZEXCEL_ALIGNMENT.slnk new file mode 100644 index 0000000..ddb21c2 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_ALIGNMENT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_APPLICATION.slnk b/ZA2X/DTEL/ZEXCEL_APPLICATION.slnk new file mode 100644 index 0000000..9a21478 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_APPLICATION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_APPVERSION.slnk b/ZA2X/DTEL/ZEXCEL_APPVERSION.slnk new file mode 100644 index 0000000..9ebb970 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_APPVERSION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_BORDER.slnk b/ZA2X/DTEL/ZEXCEL_BORDER.slnk new file mode 100644 index 0000000..07c427c --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_BORDER.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_BREAK.slnk b/ZA2X/DTEL/ZEXCEL_BREAK.slnk new file mode 100644 index 0000000..cd1a862 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_BREAK.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CATEGORY.slnk b/ZA2X/DTEL/ZEXCEL_CATEGORY.slnk new file mode 100644 index 0000000..6c89914 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CATEGORY.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_COLUMN.slnk b/ZA2X/DTEL/ZEXCEL_CELL_COLUMN.slnk new file mode 100644 index 0000000..a19f23d --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_COLUMN.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_COLUMN_ALPHA.slnk b/ZA2X/DTEL/ZEXCEL_CELL_COLUMN_ALPHA.slnk new file mode 100644 index 0000000..abb4860 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_COLUMN_ALPHA.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_COORDS.slnk b/ZA2X/DTEL/ZEXCEL_CELL_COORDS.slnk new file mode 100644 index 0000000..a9dac75 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_COORDS.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_DATA_TYPE.slnk b/ZA2X/DTEL/ZEXCEL_CELL_DATA_TYPE.slnk new file mode 100644 index 0000000..8a57233 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_DATA_TYPE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_FORMULA.slnk b/ZA2X/DTEL/ZEXCEL_CELL_FORMULA.slnk new file mode 100644 index 0000000..1765321 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_FORMULA.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_ROW.slnk b/ZA2X/DTEL/ZEXCEL_CELL_ROW.slnk new file mode 100644 index 0000000..ff8d5e4 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_ROW.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_STYLE.slnk b/ZA2X/DTEL/ZEXCEL_CELL_STYLE.slnk new file mode 100644 index 0000000..b8df375 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_STYLE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CELL_VALUE.slnk b/ZA2X/DTEL/ZEXCEL_CELL_VALUE.slnk new file mode 100644 index 0000000..191fab9 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CELL_VALUE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_COLOR.slnk b/ZA2X/DTEL/ZEXCEL_COLOR.slnk new file mode 100644 index 0000000..36403e8 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_COLOR.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_COMPANY.slnk b/ZA2X/DTEL/ZEXCEL_COMPANY.slnk new file mode 100644 index 0000000..04abf58 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_COMPANY.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CONDITIONAL.slnk b/ZA2X/DTEL/ZEXCEL_CONDITIONAL.slnk new file mode 100644 index 0000000..8ebfda7 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CONDITIONAL.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CONDITION_OPERATOR.slnk b/ZA2X/DTEL/ZEXCEL_CONDITION_OPERATOR.slnk new file mode 100644 index 0000000..0c9fd38 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CONDITION_OPERATOR.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CONDITION_RULE.slnk b/ZA2X/DTEL/ZEXCEL_CONDITION_RULE.slnk new file mode 100644 index 0000000..dc388d6 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CONDITION_RULE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CONDITION_RULE_ICONSET.slnk b/ZA2X/DTEL/ZEXCEL_CONDITION_RULE_ICONSET.slnk new file mode 100644 index 0000000..8a26903 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CONDITION_RULE_ICONSET.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_CREATOR.slnk b/ZA2X/DTEL/ZEXCEL_CREATOR.slnk new file mode 100644 index 0000000..575b6db --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_CREATOR.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_DATA_VAL_TYPE.slnk b/ZA2X/DTEL/ZEXCEL_DATA_VAL_TYPE.slnk new file mode 100644 index 0000000..5dc6210 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_DATA_VAL_TYPE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_DESCRIPTION.slnk b/ZA2X/DTEL/ZEXCEL_DESCRIPTION.slnk new file mode 100644 index 0000000..92195ab --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_DESCRIPTION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_DIAGONAL.slnk b/ZA2X/DTEL/ZEXCEL_DIAGONAL.slnk new file mode 100644 index 0000000..5f69802 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_DIAGONAL.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_DOCSECURITY.slnk b/ZA2X/DTEL/ZEXCEL_DOCSECURITY.slnk new file mode 100644 index 0000000..49a45e1 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_DOCSECURITY.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_FILL.slnk b/ZA2X/DTEL/ZEXCEL_FILL.slnk new file mode 100644 index 0000000..016192c --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_FILL.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_FILL_TYPE.slnk b/ZA2X/DTEL/ZEXCEL_FILL_TYPE.slnk new file mode 100644 index 0000000..b354d80 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_FILL_TYPE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_FONT.slnk b/ZA2X/DTEL/ZEXCEL_FONT.slnk new file mode 100644 index 0000000..31c4572 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_FONT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_FORMAT.slnk b/ZA2X/DTEL/ZEXCEL_FORMAT.slnk new file mode 100644 index 0000000..9a4f160 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_FORMAT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_GRAPH_TYPE.slnk b/ZA2X/DTEL/ZEXCEL_GRAPH_TYPE.slnk new file mode 100644 index 0000000..645ec0b --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_GRAPH_TYPE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_INDENT.slnk b/ZA2X/DTEL/ZEXCEL_INDENT.slnk new file mode 100644 index 0000000..7685234 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_INDENT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_KEYWORDS.slnk b/ZA2X/DTEL/ZEXCEL_KEYWORDS.slnk new file mode 100644 index 0000000..2583e5d --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_KEYWORDS.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_NUMBER_FORMAT.slnk b/ZA2X/DTEL/ZEXCEL_NUMBER_FORMAT.slnk new file mode 100644 index 0000000..894b12d --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_NUMBER_FORMAT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_PROTECTION.slnk b/ZA2X/DTEL/ZEXCEL_PROTECTION.slnk new file mode 100644 index 0000000..04fcb7a --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_PROTECTION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_RANGE_GUID.slnk b/ZA2X/DTEL/ZEXCEL_RANGE_GUID.slnk new file mode 100644 index 0000000..8fd4a2e --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_RANGE_GUID.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_RANGE_NAME.slnk b/ZA2X/DTEL/ZEXCEL_RANGE_NAME.slnk new file mode 100644 index 0000000..89ea6d3 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_RANGE_NAME.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_RANGE_VALUE.slnk b/ZA2X/DTEL/ZEXCEL_RANGE_VALUE.slnk new file mode 100644 index 0000000..41f9da8 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_RANGE_VALUE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_REVISIONSPASSWORD.slnk b/ZA2X/DTEL/ZEXCEL_REVISIONSPASSWORD.slnk new file mode 100644 index 0000000..74847bc --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_REVISIONSPASSWORD.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_ROTATION.slnk b/ZA2X/DTEL/ZEXCEL_ROTATION.slnk new file mode 100644 index 0000000..558c0e7 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_ROTATION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_SCALECROP.slnk b/ZA2X/DTEL/ZEXCEL_SCALECROP.slnk new file mode 100644 index 0000000..32a9856 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_SCALECROP.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_SHEET_ORIENATATION.slnk b/ZA2X/DTEL/ZEXCEL_SHEET_ORIENATATION.slnk new file mode 100644 index 0000000..5d7f44b --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_SHEET_ORIENATATION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_SHEET_PAPER_SIZE.slnk b/ZA2X/DTEL/ZEXCEL_SHEET_PAPER_SIZE.slnk new file mode 100644 index 0000000..c4e5908 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_SHEET_PAPER_SIZE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_SHEET_STATE.slnk b/ZA2X/DTEL/ZEXCEL_SHEET_STATE.slnk new file mode 100644 index 0000000..92b73a1 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_SHEET_STATE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_SHEET_TITLE.slnk b/ZA2X/DTEL/ZEXCEL_SHEET_TITLE.slnk new file mode 100644 index 0000000..fefe0fb --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_SHEET_TITLE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_ARGB.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_ARGB.slnk new file mode 100644 index 0000000..f5df235 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_ARGB.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_COMPONENT.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_COMPONENT.slnk new file mode 100644 index 0000000..41dd250 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_COMPONENT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_FONT_SCHEME.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_FONT_SCHEME.slnk new file mode 100644 index 0000000..920e1f6 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_FONT_SCHEME.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_FORMULA.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_FORMULA.slnk new file mode 100644 index 0000000..33b6ebf --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_FORMULA.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_PRIORITY.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_PRIORITY.slnk new file mode 100644 index 0000000..f185821 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_PRIORITY.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_SUBJECT.slnk b/ZA2X/DTEL/ZEXCEL_SUBJECT.slnk new file mode 100644 index 0000000..f53f2d1 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_SUBJECT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_TABLE_STYLE.slnk b/ZA2X/DTEL/ZEXCEL_TABLE_STYLE.slnk new file mode 100644 index 0000000..c4208b6 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_TABLE_STYLE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_TABLE_TOTALS_FUNCTION.slnk b/ZA2X/DTEL/ZEXCEL_TABLE_TOTALS_FUNCTION.slnk new file mode 100644 index 0000000..0bf438c --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_TABLE_TOTALS_FUNCTION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_TEXT_ROTATION.slnk b/ZA2X/DTEL/ZEXCEL_TEXT_ROTATION.slnk new file mode 100644 index 0000000..e8a09ea --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_TEXT_ROTATION.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_TITLE.slnk b/ZA2X/DTEL/ZEXCEL_TITLE.slnk new file mode 100644 index 0000000..e363d86 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_TITLE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_VALIDATION_FORMULA1.slnk b/ZA2X/DTEL/ZEXCEL_VALIDATION_FORMULA1.slnk new file mode 100644 index 0000000..92e23ba --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_VALIDATION_FORMULA1.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_WORKBOOKPASSWORD.slnk b/ZA2X/DTEL/ZEXCEL_WORKBOOKPASSWORD.slnk new file mode 100644 index 0000000..a616e27 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_WORKBOOKPASSWORD.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_WORKSHEETS_NAME.slnk b/ZA2X/DTEL/ZEXCEL_WORKSHEETS_NAME.slnk new file mode 100644 index 0000000..9985c78 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_WORKSHEETS_NAME.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/INTF/ZIF_EXCEL_READER.slnk b/ZA2X/INTF/ZIF_EXCEL_READER.slnk new file mode 100644 index 0000000..d0aab45 --- /dev/null +++ b/ZA2X/INTF/ZIF_EXCEL_READER.slnk @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/ZA2X/INTF/ZIF_EXCEL_WRITER.slnk b/ZA2X/INTF/ZIF_EXCEL_WRITER.slnk new file mode 100644 index 0000000..e4b0a67 --- /dev/null +++ b/ZA2X/INTF/ZIF_EXCEL_WRITER.slnk @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ZA2X/PROG/ZAKE_SVN_A2X.slnk b/ZA2X/PROG/ZAKE_SVN_A2X.slnk new file mode 100644 index 0000000..b144411 --- /dev/null +++ b/ZA2X/PROG/ZAKE_SVN_A2X.slnk @@ -0,0 +1,132 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report Z_ZAKE_SVN +*& +*&---------------------------------------------------------------------* +*& Checkout / Checkin the ZAKE_SVN Project +*& +*&---------------------------------------------------------------------* + +REPORT zake_svn_a2x. + +CONSTANTS cl_svn TYPE seoclsname VALUE 'ZCL_ZAKE_SVN'. +CONSTANTS cl_tortoise_svn TYPE seoclsname VALUE 'ZCL_ZAKE_TORTOISE_SVN'. + +DATA package TYPE devclass. +DATA zake TYPE REF TO zake. + +DATA zake_objects TYPE scts_tadir. + +DATA files TYPE string_table. +DATA file LIKE LINE OF files. + +DATA zake_build TYPE string. +DATA zake_nuggetname TYPE string. + +DATA comment_str TYPE string. +DATA loclpath_str TYPE string. +DATA svnpath_str TYPE string. +DATA username_str TYPE string. +DATA password_str TYPE string. +DATA class TYPE seoclsname. + +DATA: ex TYPE REF TO zcx_saplink, + message TYPE string. + +SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE a. +PARAMETERS: + checkout TYPE flag RADIOBUTTON GROUP act, + update TYPE flag RADIOBUTTON GROUP act DEFAULT 'X', + checkin TYPE flag RADIOBUTTON GROUP act. +SELECTION-SCREEN END OF BLOCK a. + +SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE b. +PARAMETERS: + svn TYPE flag RADIOBUTTON GROUP cl, + tortoise TYPE flag RADIOBUTTON GROUP cl. +SELECTION-SCREEN END OF BLOCK b. + +SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE c. +PARAMETERS: + loclpath TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx' LOWER CASE OBLIGATORY, + zakebuil TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx\build\NUGG_ABAP2XLSX_V_1_0.nugg' LOWER CASE OBLIGATORY, + zakenugg TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx\nuggs\NUGG_ABAP2XLSX_V_1_0.nugg' LOWER CASE OBLIGATORY, + svnpath TYPE char512 DEFAULT 'https://abap2xlsx.googlecode.com/svn/trunk/abap2xlsx' LOWER CASE OBLIGATORY, + comment TYPE char512 DEFAULT '' LOWER CASE, + username TYPE char512 LOWER CASE, + password TYPE char512 LOWER CASE, + testrun TYPE flag DEFAULT 'X'. +SELECTION-SCREEN END OF BLOCK c. + +INITIALIZATION. + a = 'Action'. + b = 'Version Controll Program'. + c = 'Parameters'. + +START-OF-SELECTION. + + svnpath_str = svnpath. + loclpath_str = loclpath. + zake_build = zakebuil. + zake_nuggetname = zakenugg. + comment_str = comment. + + SELECT * INTO TABLE zake_objects FROM tadir WHERE devclass = 'ZABAP2XLSX'. + DELETE zake_objects WHERE object = 'DEVC'. + + TRY. + IF svn = 'X'. + class = cl_svn. + ELSE. + class = cl_tortoise_svn. + ENDIF. + + CREATE OBJECT zake + TYPE + (class) + EXPORTING + i_svnpath = svnpath_str + i_localpath = loclpath_str. + zake->set_testrun( testrun ). + + IF checkin = 'X'. + zake->set_package( 'ZA2X' ). + zake->set_checkin_objects( zake_objects ). + zake->create_slinkees( zake_nuggetname ). + " Build a complete package for download +* zake->set_package( 'ZA2X' ). +* zake->set_checkin_objects( zake_objects ). +* " Let's add the CMD Scripts to the complete package +* CONCATENATE loclpath 'bin/svn-script.cmd' INTO file. +* APPEND file TO files. +* CONCATENATE loclpath 'bin/tortoise-svn-script.cmd' INTO file. +* APPEND file TO files. +* zake->add_files_to_zip( files ). +* " We don't want that for the complete Package Slinkees are created +* " in the ZAKE folder +* zake->download_slinkees_to_lm = space. +* zake->download_nugget_to_lm = space. +* zake->create_slinkees( zake_nuggetname ). + IF testrun IS INITIAL. + zake->checkin( comment_str ). + ENDIF. + ELSE. + IF update = 'X'. + zake->update( ). + ELSE. + zake->checkout( ). + ENDIF. + " zake->install_slinkees_from_lm( testrun ). + zake->install_objects( zake_objects ). + ENDIF. + CATCH zcx_saplink INTO ex. + message = ex->msg. + WRITE: / 'An Error occured: ', message. + ENDTRY. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL.slnk b/ZA2X/PROG/ZDEMO_EXCEL.slnk new file mode 100644 index 0000000..e84fc3d --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL.slnk @@ -0,0 +1,34 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel. + +SUBMIT zdemo_excel1 AND RETURN. " Hello world +SUBMIT zdemo_excel2 AND RETURN. " Styles +SUBMIT zdemo_excel3 AND RETURN. " iTab binding +SUBMIT zdemo_excel4 AND RETURN. " Multi sheets +SUBMIT zdemo_excel5 AND RETURN. " Conditional formatting +SUBMIT zdemo_excel6 AND RETURN. " Formulas +SUBMIT zdemo_excel7 AND RETURN. " Conditional formatting +SUBMIT zdemo_excel8 AND RETURN. " Ranges +SUBMIT zdemo_excel9 AND RETURN. " Data validation +SUBMIT zdemo_excel10 AND RETURN. " Bind table with field catalog +" zdemo_excel11 is not added because it has a selection screen and +" you also need to have business partners maintained in transaction BP +SUBMIT zdemo_excel12 AND RETURN. " Column size +SUBMIT zdemo_excel13 AND RETURN. " Merge cell +SUBMIT zdemo_excel14 AND RETURN. " Alignment +SUBMIT zdemo_excel15 AND RETURN. " Read Excel and write it back + diff --git a/ZA2X/PROG/ZDEMO_EXCEL1.slnk b/ZA2X/PROG/ZDEMO_EXCEL1.slnk new file mode 100644 index 0000000..49ca2b5 --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL1.slnk @@ -0,0 +1,56 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel1. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer TYPE REF TO zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = sy-datum ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = sy-uzeit ). + +CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HelloWorld.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL10.slnk b/ZA2X/PROG/ZDEMO_EXCEL10.slnk new file mode 100644 index 0000000..2967939 --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL10.slnk @@ -0,0 +1,102 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel10. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional2 TYPE REF TO zcl_excel_style_conditional, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_field_catalog TYPE zexcel_t_fieldcatalog, + ls_field_catalog TYPE zexcel_s_fieldcatalog, + ls_table_settings TYPE zexcel_s_table_settings, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +"Conditional style +lo_style_conditional2 = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional2->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional2->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional2->priority = 1. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. + +lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_test ). + +LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>. + CASE <fs_field_catalog>-fieldname. + WHEN 'CARRID'. + <fs_field_catalog>-position = 3. + <fs_field_catalog>-dynpfld = abap_true. + <fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_count. + WHEN 'CONNID'. + <fs_field_catalog>-position = 4. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FLDATE'. + <fs_field_catalog>-position = 2. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'PRICE'. + <fs_field_catalog>-position = 1. + <fs_field_catalog>-dynpfld = abap_true. + <fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_sum. + <fs_field_catalog>-cond_style = lo_style_conditional2. + WHEN OTHERS. + <fs_field_catalog>-dynpfld = abap_false. + ENDCASE. +ENDLOOP. + +ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5. + +lo_worksheet->bind_table( ip_table = lt_test + is_table_settings = ls_table_settings + it_field_catalog = lt_field_catalog ). + +column_dimension = lo_worksheet->get_column_dimension( 'D' ). "make date field a bit wider +column_dimension->set_width( 13 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTabFieldCatalog.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL11.slnk b/ZA2X/PROG/ZDEMO_EXCEL11.slnk new file mode 100644 index 0000000..4f262fa --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL11.slnk @@ -0,0 +1,458 @@ + + + + + + + + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL11 +*& Export Organisation and Contact Persons using ABAP2XLSX +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel11. + +TYPE-POOLS: abap. + +DATA: central_search TYPE bapibus1006_central_search, + addressdata_search TYPE bapibus1006_addr_search, + others_search TYPE bapibus1006_other_data. +DATA: searchresult TYPE TABLE OF bapibus1006_bp_addr, + return TYPE TABLE OF bapiret2. +DATA: lines TYPE i. +FIELD-SYMBOLS: <searchresult_line> LIKE LINE OF searchresult. +DATA: centraldata TYPE bapibus1006_central, + centraldataperson TYPE bapibus1006_central_person, + centraldataorganization TYPE bapibus1006_central_organ. +DATA: addressdata TYPE bapibus1006_address. +DATA: relationships TYPE TABLE OF bapibus1006_relations. +FIELD-SYMBOLS: <relationship> LIKE LINE OF relationships. +DATA: relationship_centraldata TYPE bapibus1006002_central. +DATA: relationship_addresses TYPE TABLE OF bapibus1006002_addresses. +FIELD-SYMBOLS: <relationship_address> LIKE LINE OF relationship_addresses. + +DATA: lt_download TYPE TABLE OF zexcel_s_org_rel. +FIELD-SYMBOLS: <download> LIKE LINE OF lt_download. + +PARAMETERS: md TYPE flag RADIOBUTTON GROUP act. + +SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE a. +PARAMETERS: partnerc TYPE bu_type DEFAULT 2, " Organizations + postlcod TYPE ad_pstcd1 DEFAULT '8334*', + country TYPE land1 DEFAULT 'DE', + maxsel TYPE bu_maxsel DEFAULT 100. +SELECTION-SCREEN END OF BLOCK a. + +PARAMETERS: rel TYPE flag RADIOBUTTON GROUP act DEFAULT 'X'. + +SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE b. +PARAMETERS: reltyp TYPE bu_reltyp DEFAULT 'BUR011', + partner TYPE bu_partner DEFAULT '191'. +SELECTION-SCREEN END OF BLOCK b. + +INITIALIZATION. + a = 'Select by master data'. + b = 'Select by relationship'. + +START-OF-SELECTION. + IF md = abap_true. + " Read all Companies by Master Data + central_search-partnercategory = partnerc. + addressdata_search-postl_cod1 = postlcod. + addressdata_search-country = country. + others_search-maxsel = maxsel. + others_search-no_search_for_contactperson = 'X'. + + CALL FUNCTION 'BAPI_BUPA_SEARCH_2' + EXPORTING + centraldata = central_search + addressdata = addressdata_search + OTHERS = others_search + TABLES + searchresult = searchresult + return = return. + + SORT searchresult BY partner. + DELETE ADJACENT DUPLICATES FROM searchresult COMPARING partner. + ELSEIF rel = abap_true. + " Read by Relationship + SELECT but050~partner1 AS partner FROM but050 + INNER JOIN but000 ON but000~partner = but050~partner1 AND but000~type = '2' + INTO CORRESPONDING FIELDS OF TABLE searchresult + WHERE but050~partner2 = partner + AND but050~reltyp = reltyp. + ENDIF. + + DESCRIBE TABLE searchresult LINES lines. + WRITE: / 'Number of search results: ', lines. + + LOOP AT searchresult ASSIGNING <searchresult_line>. + " Read Details of Organization + CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL' + EXPORTING + businesspartner = <searchresult_line>-partner + IMPORTING + centraldataorganization = centraldataorganization. + " Read Standard Address of Organization + CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL' + EXPORTING + businesspartner = <searchresult_line>-partner + IMPORTING + addressdata = addressdata. + + " Add Organization to Download + APPEND INITIAL LINE TO lt_download ASSIGNING <download>. + " Fill Organization Partner Numbers + CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS' + EXPORTING + businesspartner = <searchresult_line>-partner + IMPORTING + businesspartnerout = <download>-org_number + businesspartnerguidout = <download>-org_guid. + + MOVE-CORRESPONDING centraldataorganization TO <download>. + MOVE-CORRESPONDING addressdata TO <download>. + CLEAR: addressdata. + + " Read all Relationships + CLEAR: relationships. + CALL FUNCTION 'BAPI_BUPA_RELATIONSHIPS_GET' + EXPORTING + businesspartner = <searchresult_line>-partner + TABLES + relationships = relationships. + DELETE relationships WHERE relationshipcategory <> 'BUR001'. + LOOP AT relationships ASSIGNING <relationship>. + " Read details of Contact person + CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL' + EXPORTING + businesspartner = <relationship>-partner2 + IMPORTING + centraldata = centraldata + centraldataperson = centraldataperson. + " Read details of the Relationship + CALL FUNCTION 'BAPI_BUPR_CONTP_GETDETAIL' + EXPORTING + businesspartner = <relationship>-partner1 + contactperson = <relationship>-partner2 + IMPORTING + centraldata = relationship_centraldata. + " Read relationship address + CLEAR: relationship_addresses. + + CALL FUNCTION 'BAPI_BUPR_CONTP_ADDRESSES_GET' + EXPORTING + businesspartner = <relationship>-partner1 + contactperson = <relationship>-partner2 + TABLES + addresses = relationship_addresses. + + READ TABLE relationship_addresses + ASSIGNING <relationship_address> + WITH KEY standardaddress = 'X'. + + IF <relationship_address> IS ASSIGNED. + " Read Relationship Address + CLEAR addressdata. + CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL' + EXPORTING + businesspartner = <searchresult_line>-partner + addressguid = <relationship_address>-addressguid + IMPORTING + addressdata = addressdata. + + APPEND INITIAL LINE TO lt_download ASSIGNING <download>. + CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS' + EXPORTING + businesspartner = <relationship>-partner1 + IMPORTING + businesspartnerout = <download>-org_number + businesspartnerguidout = <download>-org_guid. + + CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS' + EXPORTING + businesspartner = <relationship>-partner2 + IMPORTING + businesspartnerout = <download>-contpers_number + businesspartnerguidout = <download>-contpers_guid. + + MOVE-CORRESPONDING centraldataorganization TO <download>. + MOVE-CORRESPONDING addressdata TO <download>. + MOVE-CORRESPONDING centraldataperson TO <download>. + MOVE-CORRESPONDING relationship_centraldata TO <download>. + + WRITE: / <relationship>-partner1, <relationship>-partner2. + WRITE: centraldataorganization-name1(20), centraldataorganization-name2(10). + WRITE: centraldataperson-firstname(15), centraldataperson-lastname(15). + WRITE: addressdata-street(25), addressdata-house_no, + addressdata-postl_cod1, addressdata-city(25). + ENDIF. + ENDLOOP. + + ENDLOOP. + + DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer TYPE REF TO zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_body TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime, + row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + DATA: lv_style_body_odd_guid TYPE zexcel_cell_style, + lv_style_body_even_guid TYPE zexcel_cell_style, + lv_style_body_green TYPE zexcel_cell_style, + lv_style_body_odd_n_guid TYPE zexcel_cell_style, + lv_style_body_even_n_guid TYPE zexcel_cell_style. + + DATA: row TYPE zexcel_cell_row. + + DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + + DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog, + ls_table_settings TYPE zexcel_s_table_settings. + + DATA: column TYPE zexcel_cell_column, + column_alpha TYPE zexcel_cell_column_alpha, + value TYPE zexcel_cell_value. + + FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog. + + " Creates active sheet + CREATE OBJECT lo_excel. + + " Create border object + CREATE OBJECT lo_border_dark. + lo_border_dark->border_color = zcl_excel_style_color=>c_black. + lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. + "Create style with border odd + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->filltype = zcl_excel_style_fill=>c_fill_solid. + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_gray. + lo_style_body->borders->allborders = lo_border_dark. + lv_style_body_odd_guid = lo_style_body->get_guid( ). + "Create style with border even + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_yellow. + lo_style_body->borders->allborders = lo_border_dark. + lv_style_body_even_guid = lo_style_body->get_guid( ). + "Create style with border and green fill + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_green. + lo_style_body->borders->allborders = lo_border_dark. + lv_style_body_green = lo_style_body->get_guid( ). + "Create style numeric with border odd + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->filltype = zcl_excel_style_fill=>c_fill_solid. + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_gray. + lo_style_body->borders->allborders = lo_border_dark. + lo_style_body->number_format->format_code = zcl_excel_style_number_format=>c_format_number. + lv_style_body_odd_n_guid = lo_style_body->get_guid( ). + "Create style numeric with border odd + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->borders->allborders = lo_border_dark. + lo_style_body->number_format->format_code = zcl_excel_style_number_format=>c_format_number. + lv_style_body_even_n_guid = lo_style_body->get_guid( ). + + " Get active sheet + lo_worksheet = lo_excel->get_active_worksheet( ). + lo_worksheet->title = 'Internal table'. + + lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_download ). + + LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>. + CASE <fs_field_catalog>-fieldname. + WHEN 'ORG_NUMBER'. + <fs_field_catalog>-position = 1. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'CONTPERS_NUMBER'. + <fs_field_catalog>-position = 2. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'NAME1'. + <fs_field_catalog>-position = 3. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'NAME2'. + <fs_field_catalog>-position = 4. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'STREET'. + <fs_field_catalog>-position = 5. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'HOUSE_NO'. + <fs_field_catalog>-position = 6. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'POSTL_COD1'. + <fs_field_catalog>-position = 7. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'CITY'. + <fs_field_catalog>-position = 8. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'COUNTRYISO'. + <fs_field_catalog>-position = 9. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FIRSTNAME'. + <fs_field_catalog>-position = 10. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'LASTNAME'. + <fs_field_catalog>-position = 11. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FUNCTIONNAME'. + <fs_field_catalog>-position = 12. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'DEPARTMENTNAME'. + <fs_field_catalog>-position = 13. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'TEL1_NUMBR'. + <fs_field_catalog>-position = 14. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'TEL1_EXT'. + <fs_field_catalog>-position = 15. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FAX_NUMBER'. + <fs_field_catalog>-position = 16. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FAX_EXTENS'. + <fs_field_catalog>-position = 17. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'E_MAIL'. + <fs_field_catalog>-position = 18. + <fs_field_catalog>-dynpfld = abap_true. + WHEN OTHERS. + <fs_field_catalog>-dynpfld = abap_false. + ENDCASE. + ENDLOOP. + + ls_table_settings-top_left_column = 'A'. + ls_table_settings-top_left_row = '2'. + ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5. + + lo_worksheet->bind_table( ip_table = lt_download + is_table_settings = ls_table_settings + it_field_catalog = lt_field_catalog ). + LOOP AT lt_download ASSIGNING <download>. + row = sy-tabix + 2. + IF NOT <download>-org_number IS INITIAL + AND <download>-contpers_number IS INITIAL. + " Mark fields of Organization which can be changed green + lo_worksheet->set_cell_style( + ip_column = 'C' + ip_row = row + ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'D' + ip_row = row + ip_style = lv_style_body_green + ). +* CATCH zcx_excel. " Exceptions for ABAP2XLSX + ELSEIF NOT <download>-org_number IS INITIAL + AND NOT <download>-contpers_number IS INITIAL. + " Mark fields of Relationship which can be changed green + lo_worksheet->set_cell_style( + ip_column = 'L' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'M' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'N' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'O' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'P' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'Q' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'R' ip_row = row ip_style = lv_style_body_green + ). + ENDIF. + ENDLOOP. + " Add Fieldnames in first row and hide the row + LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog> + WHERE position <> '' AND dynpfld = abap_true. + column = <fs_field_catalog>-position. + column_alpha = zcl_excel_common=>convert_column2alpha( column ). + value = <fs_field_catalog>-fieldname. + lo_worksheet->set_cell( ip_column = column_alpha + ip_row = 1 + ip_value = value + ip_style = lv_style_body_even_guid ). + ENDLOOP. + " Hide first row + row_dimension = lo_worksheet->get_row_dimension( 1 ). + row_dimension->set_visible( abap_false ). + + " Set Column width + column_dimension = lo_worksheet->get_column_dimension( 'A' ). + column_dimension->set_width( 11 ). + column_dimension = lo_worksheet->get_column_dimension( 'B' ). + column_dimension->set_width( 11 ). + column_dimension = lo_worksheet->get_column_dimension( 'C' ). + column_dimension->set_width( 35 ). + column_dimension = lo_worksheet->get_column_dimension( 'E' ). + column_dimension->set_width( 18 ). + column_dimension = lo_worksheet->get_column_dimension( 'F' ). + column_dimension->set_width( 5 ). + column_dimension = lo_worksheet->get_column_dimension( 'G' ). + column_dimension->set_width( 6 ). + column_dimension = lo_worksheet->get_column_dimension( 'H' ). + column_dimension->set_width( 12 ). + column_dimension = lo_worksheet->get_column_dimension( 'I' ). + column_dimension->set_width( 3 ). + column_dimension = lo_worksheet->get_column_dimension( 'J' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'K' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'L' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'M' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'N' ). + column_dimension->set_width( 12 ). + column_dimension = lo_worksheet->get_column_dimension( 'O' ). + column_dimension->set_width( 9 ). + column_dimension = lo_worksheet->get_column_dimension( 'P' ). + column_dimension->set_width( 12 ). + column_dimension = lo_worksheet->get_column_dimension( 'Q' ). + column_dimension->set_width( 9 ). + column_dimension = lo_worksheet->get_column_dimension( 'R' ). + column_dimension->set_width( 40 ). + + CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. + lv_file = lo_excel_writer->write_file( lo_excel ). + + " Convert to binary + CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + + " Save the file + CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\ZDEMO_EXCEL11.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL12.slnk b/ZA2X/PROG/ZDEMO_EXCEL12.slnk new file mode 100644 index 0000000..10803ee --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL12.slnk @@ -0,0 +1,95 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL12 +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel12. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime, + row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world in AutoSize column' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Hello world in a column width size 50' ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Hello world (hidden column)' ). +lo_worksheet->set_cell( ip_column = 'F' ip_row = 2 ip_value = 'Outline column level 0' ). +lo_worksheet->set_cell( ip_column = 'G' ip_row = 2 ip_value = 'Outline column level 1' ). +lo_worksheet->set_cell( ip_column = 'H' ip_row = 2 ip_value = 'Outline column level 2' ). + + +lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Hello world (hidden row)' ). +lo_worksheet->set_cell( ip_column = 'E' ip_row = 5 ip_value = 'Hello world in a row height size 20' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Outline row level 0' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 7 ip_value = 'Outline row level 1' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 8 ip_value = 'Outline row level 2' ). + +" Column Settings +column_dimension = lo_worksheet->get_column_dimension( 'B' ). +column_dimension->set_auto_size( abap_true ). +column_dimension = lo_worksheet->get_column_dimension( 'C' ). +column_dimension->set_width( 50 ). +column_dimension = lo_worksheet->get_column_dimension( 'D' ). +column_dimension->set_visible( abap_false ). +" Implementation in the Writer is not working yet ===== TODO ===== +column_dimension = lo_worksheet->get_column_dimension( 'F' ). +column_dimension->set_outline_level( 0 ). +column_dimension = lo_worksheet->get_column_dimension( 'G' ). +column_dimension->set_outline_level( 1 ). +column_dimension = lo_worksheet->get_column_dimension( 'H' ). +column_dimension->set_outline_level( 2 ). + +row_dimension = lo_worksheet->get_row_dimension( 1 ). +row_dimension->set_visible( abap_false ). +row_dimension = lo_worksheet->get_row_dimension( 5 ). +row_dimension->set_row_height( 20 ). +" Implementation in the Writer is not working yet ===== TODO ===== +row_dimension = lo_worksheet->get_row_dimension( 6 ). +row_dimension->set_outline_level( 0 ). +row_dimension = lo_worksheet->get_row_dimension( 7 ). +row_dimension->set_outline_level( 1 ). +row_dimension = lo_worksheet->get_row_dimension( 8 ). +row_dimension->set_outline_level( 2 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HideSizeOutlineRowsAndColumns.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL13.slnk b/ZA2X/PROG/ZDEMO_EXCEL13.slnk new file mode 100644 index 0000000..b32ec40 --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL13.slnk @@ -0,0 +1,77 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL13 +*& +*&---------------------------------------------------------------------* +*& Example by: Alvaro "Blag" Tejada Galindo. +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel13. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1, + lv_style_bold_border_guid TYPE zexcel_cell_style, + lo_style_bold_border TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. + +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. + +lo_style_bold_border = lo_excel->add_new_style( ). +lo_style_bold_border->font->bold = abap_true. +lo_style_bold_border->font->italic = abap_false. +lo_style_bold_border->font->color = zcl_excel_style_color=>c_black. +lo_style_bold_border->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lo_style_bold_border->borders->allborders = lo_border_dark. +lv_style_bold_border_guid = lo_style_bold_border->get_guid( ). + +lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = 'Test' ). + +lo_worksheet->set_cell( ip_row = 2 ip_column = 'B' ip_value = 'Banana' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'C' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'D' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'E' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'F' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'G' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_merge( ip_row = 2 ip_column_start = 'B' ip_column_end = 'G' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Merged_Cells.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL14.slnk b/ZA2X/PROG/ZDEMO_EXCEL14.slnk new file mode 100644 index 0000000..68b914d --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL14.slnk @@ -0,0 +1,168 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL13 +*& +*&---------------------------------------------------------------------* +*& Example by: Alvaro "Blag" Tejada Galindo. +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel14. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer TYPE REF TO zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1, + lo_style_center TYPE REF TO zcl_excel_style, + lo_style_right TYPE REF TO zcl_excel_style, + lo_style_left TYPE REF TO zcl_excel_style, + lo_style_general TYPE REF TO zcl_excel_style, + lo_style_bottom TYPE REF TO zcl_excel_style, + lo_style_middle TYPE REF TO zcl_excel_style, + lo_style_top TYPE REF TO zcl_excel_style, + lo_style_justify TYPE REF TO zcl_excel_style, + lo_style_mixed TYPE REF TO zcl_excel_style, + lo_style_rotated TYPE REF TO zcl_excel_style, + lo_style_shrink TYPE REF TO zcl_excel_style, + lo_style_indent TYPE REF TO zcl_excel_style, + lv_style_center_guid TYPE zexcel_cell_style, + lv_style_right_guid TYPE zexcel_cell_style, + lv_style_left_guid TYPE zexcel_cell_style, + lv_style_general_guid TYPE zexcel_cell_style, + lv_style_bottom_guid TYPE zexcel_cell_style, + lv_style_middle_guid TYPE zexcel_cell_style, + lv_style_top_guid TYPE zexcel_cell_style, + lv_style_justify_guid TYPE zexcel_cell_style, + lv_style_mixed_guid TYPE zexcel_cell_style, + lv_style_rotated_guid TYPE zexcel_cell_style, + lv_style_shrink_guid TYPE zexcel_cell_style, + lv_style_indent_guid TYPE zexcel_cell_style. + +DATA: lo_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. + +"Center +lo_style_center = lo_excel->add_new_style( ). +lo_style_center->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lv_style_center_guid = lo_style_center->get_guid( ). +"Right +lo_style_right = lo_excel->add_new_style( ). +lo_style_right->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_right. +lv_style_right_guid = lo_style_right->get_guid( ). +"Left +lo_style_left = lo_excel->add_new_style( ). +lo_style_left->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_left. +lv_style_left_guid = lo_style_left->get_guid( ). +"General +lo_style_general = lo_excel->add_new_style( ). +lo_style_general->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_general. +lv_style_general_guid = lo_style_general->get_guid( ). +"Bottom +lo_style_bottom = lo_excel->add_new_style( ). +lo_style_bottom->alignment->vertical = zcl_excel_style_alignment=>c_vertical_bottom. +lv_style_bottom_guid = lo_style_bottom->get_guid( ). +"Middle +lo_style_middle = lo_excel->add_new_style( ). +lo_style_middle->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. +lv_style_middle_guid = lo_style_middle->get_guid( ). +"Top +lo_style_top = lo_excel->add_new_style( ). +lo_style_top->alignment->vertical = zcl_excel_style_alignment=>c_vertical_top. +lv_style_top_guid = lo_style_top->get_guid( ). +"Justify +lo_style_justify = lo_excel->add_new_style( ). +lo_style_justify->alignment->vertical = zcl_excel_style_alignment=>c_vertical_justify. +lv_style_justify_guid = lo_style_justify->get_guid( ). + +"Shrink +lo_style_shrink = lo_excel->add_new_style( ). +lo_style_shrink->alignment->shrinktofit = abap_true. +lv_style_shrink_guid = lo_style_shrink->get_guid( ). + +"Indent +lo_style_indent = lo_excel->add_new_style( ). +lo_style_indent->alignment->indent = 5. +lv_style_indent_guid = lo_style_indent->get_guid( ). + +"Middle / Centered / Wrap +lo_style_mixed = lo_excel->add_new_style( ). +lo_style_mixed->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lo_style_mixed->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. +lo_style_mixed->alignment->wraptext = abap_true. +lv_style_mixed_guid = lo_style_mixed->get_guid( ). + +"Center +lo_style_rotated = lo_excel->add_new_style( ). +lo_style_rotated->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lo_style_rotated->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. +lo_style_rotated->alignment->textrotation = 165. " -75° == 90° + 75° +lv_style_rotated_guid = lo_style_rotated->get_guid( ). + + +" Set row size for first 7 rows to 40 +DO 7 TIMES. + lo_row_dimension = lo_worksheet->get_row_dimension( sy-index ). + lo_row_dimension->set_row_height( 40 ). +ENDDO. + +"Horizontal alignment +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'Centered Text' ip_style = lv_style_center_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 'Right Text' ip_style = lv_style_right_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 'Left Text' ip_style = lv_style_left_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 'General Text' ip_style = lv_style_general_guid ). + +" Shrink & indent +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'Text shrinked' ip_style = lv_style_shrink_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = 'Text indented' ip_style = lv_style_indent_guid ). + +"Vertical alignment + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'Bottom Text' ip_style = lv_style_bottom_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 'Middle Text' ip_style = lv_style_middle_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 'Top Text' ip_style = lv_style_top_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = 'Justify Text' ip_style = lv_style_justify_guid ). + +" Wrapped +lo_worksheet->set_cell( ip_row = 10 ip_column = 'B' + ip_value = 'This is a wrapped text centered in the middle' + ip_style = lv_style_mixed_guid ). + +" Rotated +lo_worksheet->set_cell( ip_row = 10 ip_column = 'D' + ip_value = 'This is a centered text rotated by -75°' + ip_style = lv_style_rotated_guid ). + +CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Alignment.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL15.slnk b/ZA2X/PROG/ZDEMO_EXCEL15.slnk new file mode 100644 index 0000000..3859adb --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL15.slnk @@ -0,0 +1,50 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL15 +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel15. + +DATA: excel TYPE REF TO zcl_excel, + reader TYPE REF TO zif_excel_reader. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +TRY. + CREATE OBJECT reader TYPE zcl_excel_reader_2007. + excel = reader->load_file( 'C:\iTab.xlsx' ). + lv_file = excel->save_as( zcl_excel=>c_xlsx ). + + " Convert to binary + CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + + " Save the file + CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTabFromReader.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + CATCH zcx_excel. " Exceptions for ABAP2XLSX +ENDTRY. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL2.slnk b/ZA2X/PROG/ZDEMO_EXCEL2.slnk new file mode 100644 index 0000000..933f44e --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL2.slnk @@ -0,0 +1,117 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& Test Styles for ABAP2XLSX +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel2. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_bold TYPE REF TO zcl_excel_style, + lo_style_underline TYPE REF TO zcl_excel_style, + lo_style_filled TYPE REF TO zcl_excel_style, + lo_style_border TYPE REF TO zcl_excel_style, + lo_style_button TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_bold_guid TYPE zexcel_cell_style, + lv_style_underline_guid TYPE zexcel_cell_style, + lv_style_filled_guid TYPE zexcel_cell_style, + lv_style_filled_green_guid TYPE zexcel_cell_style, + lv_style_border_guid TYPE zexcel_cell_style, + lv_style_button_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +CREATE OBJECT lo_border_light. +lo_border_light->border_color = zcl_excel_style_color=>c_gray. +lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. +" Create a bold / italic style +lo_style_bold = lo_excel->add_new_style( ). +lo_style_bold->font->bold = abap_true. +lo_style_bold->font->italic = abap_true. +lo_style_bold->font->color = zcl_excel_style_color=>c_red. +lv_style_bold_guid = lo_style_bold->get_guid( ). +" Create an underline double style +lo_style_underline = lo_excel->add_new_style( ). +lo_style_underline->font->underline = abap_true. +lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double. +lv_style_underline_guid = lo_style_underline->get_guid( ). +" Create filled style yellow +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lv_style_filled_guid = lo_style_filled->get_guid( ). +" Create border with button effects +lo_style_button = lo_excel->add_new_style( ). +lo_style_button->borders->right = lo_border_dark. +lo_style_button->borders->down = lo_border_dark. +lo_style_button->borders->left = lo_border_light. +lo_style_button->borders->top = lo_border_light. +lv_style_button_guid = lo_style_button->get_guid( ). +"Create style with border +lo_style_border = lo_excel->add_new_style( ). +lo_style_border->borders->allborders = lo_border_dark. +lv_style_border_guid = lo_style_border->get_guid( ). +" Create filled style green +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_green. +lv_style_filled_green_guid = lo_style_filled->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Styles'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ). +" Fill the cell and apply one style +lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +" Change the style +lo_worksheet->set_cell_style( ip_column = 'B' ip_row = 6 ip_style = lv_style_filled_green_guid ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Styles.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL3.slnk b/ZA2X/PROG/ZDEMO_EXCEL3.slnk new file mode 100644 index 0000000..e2b6025 --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL3.slnk @@ -0,0 +1,64 @@ + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel3. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime. + +DATA: ls_table_settings TYPE zexcel_s_table_settings. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. + +ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2. +ls_table_settings-show_row_stripes = abap_true. + +lo_worksheet->bind_table( ip_table = lt_test + is_table_settings = ls_table_settings ). + +column_dimension = lo_worksheet->get_column_dimension( 'E' ). "make date field a bit wider +column_dimension->set_width( 11 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTab.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL4.slnk b/ZA2X/PROG/ZDEMO_EXCEL4.slnk new file mode 100644 index 0000000..ece3e3c --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL4.slnk @@ -0,0 +1,58 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel4. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ). + +lo_worksheet = lo_excel->add_new_worksheet( ). +lo_worksheet->title = 'Sheet2'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Sheets.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL5.slnk b/ZA2X/PROG/ZDEMO_EXCEL5.slnk new file mode 100644 index 0000000..6170568 --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL5.slnk @@ -0,0 +1,66 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel5. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 100 ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 1000 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 150 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 500 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\CondFormatting.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL6.slnk b/ZA2X/PROG/ZDEMO_EXCEL6.slnk new file mode 100644 index 0000000..c8a4176 --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL6.slnk @@ -0,0 +1,56 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel6. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 100 ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 1000 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 150 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = -10 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 500 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_formula = 'SUM(C4:C8)' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Formula.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL7.slnk b/ZA2X/PROG/ZDEMO_EXCEL7.slnk new file mode 100644 index 0000000..f4f4b1e --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL7.slnk @@ -0,0 +1,321 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel7. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 5 + ip_stop_column = 'B' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 5 + ip_stop_column = 'C' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = 50 ). +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3flags. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 5 + ip_stop_column = 'D' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'C_ICONSET_3FLAGS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'D' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'D' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 5 + ip_stop_column = 'E' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'C_ICONSET_3TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'E' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 5 + ip_stop_column = 'F' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'C_ICONSET_3TRAFFICLIGHTS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'F' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'F' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'F' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'F' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'G' + ip_start_row = 5 + ip_stop_column = 'G' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = 'C_ICONSET_3SIGNS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'G' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'G' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'G' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'G' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'G' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'H' + ip_start_row = 5 + ip_stop_column = 'H' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'H' ip_value = 'C_ICONSET_3SYMBOLS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'H' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'H' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'H' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'H' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'H' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'I' + ip_start_row = 5 + ip_stop_column = 'I' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'I' ip_value = 'C_ICONSET_3SYMBOLS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'I' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'I' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'I' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'I' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'I' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 12 + ip_stop_column = 'B' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = 'C_ICONSET_4ARROWS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'B' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'B' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'B' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 12 + ip_stop_column = 'C' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'C' ip_value = 'C_ICONSET_4ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'C' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'C' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'C' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'C' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 12 + ip_stop_column = 'D' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'D' ip_value = 'C_ICONSET_4REDTOBLACK' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'D' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'D' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'D' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 12 + ip_stop_column = 'E' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'E' ip_value = 'C_ICONSET_4RATING' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'E' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'E' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'E' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'E' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 12 + ip_stop_column = 'F' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'F' ip_value = 'C_ICONSET_4TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'F' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'F' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'F' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'F' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 19 + ip_stop_column = 'B' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'B' ip_value = 'C_ICONSET_5ARROWS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'B' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'B' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'B' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'B' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'B' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 19 + ip_stop_column = 'C' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'C' ip_value = 'C_ICONSET_5ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'C' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'C' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'C' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'C' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 19 + ip_stop_column = 'D' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'D' ip_value = 'C_ICONSET_5RATING' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'D' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'D' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'D' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'D' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'D' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5quarters. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 19 + ip_stop_column = 'E' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = 50 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Iconset.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL8.slnk b/ZA2X/PROG/ZDEMO_EXCEL8.slnk new file mode 100644 index 0000000..97aecdb --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL8.slnk @@ -0,0 +1,66 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel8. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Range.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL9.slnk b/ZA2X/PROG/ZDEMO_EXCEL9.slnk new file mode 100644 index 0000000..674a19d --- /dev/null +++ b/ZA2X/PROG/ZDEMO_EXCEL9.slnk @@ -0,0 +1,73 @@ + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel9. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + +lo_data_validation = lo_worksheet->add_new_data_validation( ). +lo_data_validation->value = lo_range->name. +lo_data_validation->cell_row = 4. +lo_data_validation->cell_column = 'A'. + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Select a value' ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\DataValidation.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + diff --git a/ZA2X/TABL/ZEXCEL_S_CELLXFS.slnk b/ZA2X/TABL/ZEXCEL_S_CELLXFS.slnk new file mode 100644 index 0000000..39f9110 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_CELLXFS.slnk @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_CELL_DATA.slnk b/ZA2X/TABL/ZEXCEL_S_CELL_DATA.slnk new file mode 100644 index 0000000..e45a42e --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_CELL_DATA.slnk @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_FIELDCATALOG.slnk b/ZA2X/TABL/ZEXCEL_S_FIELDCATALOG.slnk new file mode 100644 index 0000000..79800f2 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_FIELDCATALOG.slnk @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_ORG_REL.slnk b/ZA2X/TABL/ZEXCEL_S_ORG_REL.slnk new file mode 100644 index 0000000..afb8b25 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_ORG_REL.slnk @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_SHARED_STRING.slnk b/ZA2X/TABL/ZEXCEL_S_SHARED_STRING.slnk new file mode 100644 index 0000000..92b7b70 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_SHARED_STRING.slnk @@ -0,0 +1,6 @@ + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLES_MAPPING.slnk b/ZA2X/TABL/ZEXCEL_S_STYLES_MAPPING.slnk new file mode 100644 index 0000000..673045e --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLES_MAPPING.slnk @@ -0,0 +1,6 @@ + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_ALIGNMENT.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_ALIGNMENT.slnk new file mode 100644 index 0000000..ea370a7 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_ALIGNMENT.slnk @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk new file mode 100644 index 0000000..0dd48c2 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk new file mode 100644 index 0000000..3c70c4b --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk.old b/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk.old new file mode 100644 index 0000000..d2993a3 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk.old @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk new file mode 100644 index 0000000..0a252ce --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_NUMFMT.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_NUMFMT.slnk new file mode 100644 index 0000000..b996db7 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_NUMFMT.slnk @@ -0,0 +1,5 @@ + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_TABLE_SETTINGS.slnk b/ZA2X/TABL/ZEXCEL_S_TABLE_SETTINGS.slnk new file mode 100644 index 0000000..807b9a0 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_TABLE_SETTINGS.slnk @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_WORKSHEET_COLUMNDIME.slnk b/ZA2X/TABL/ZEXCEL_S_WORKSHEET_COLUMNDIME.slnk new file mode 100644 index 0000000..a36e8af --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_WORKSHEET_COLUMNDIME.slnk @@ -0,0 +1,6 @@ + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_WORKSHEET_ROWDIMENSIO.slnk b/ZA2X/TABL/ZEXCEL_S_WORKSHEET_ROWDIMENSIO.slnk new file mode 100644 index 0000000..64f2e1d --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_WORKSHEET_ROWDIMENSIO.slnk @@ -0,0 +1,6 @@ + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_CELLXFS.slnk b/ZA2X/TTYP/ZEXCEL_T_CELLXFS.slnk new file mode 100644 index 0000000..fd9a169 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_CELLXFS.slnk @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_CELL_DATA.slnk b/ZA2X/TTYP/ZEXCEL_T_CELL_DATA.slnk new file mode 100644 index 0000000..f25e698 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_CELL_DATA.slnk @@ -0,0 +1,5 @@ + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_CELL_DATA_UNSORTED.slnk b/ZA2X/TTYP/ZEXCEL_T_CELL_DATA_UNSORTED.slnk new file mode 100644 index 0000000..abaf13b --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_CELL_DATA_UNSORTED.slnk @@ -0,0 +1,2 @@ + + diff --git a/ZA2X/TTYP/ZEXCEL_T_FIELDCATALOG.slnk b/ZA2X/TTYP/ZEXCEL_T_FIELDCATALOG.slnk new file mode 100644 index 0000000..f852a4d --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_FIELDCATALOG.slnk @@ -0,0 +1,2 @@ + + diff --git a/ZA2X/TTYP/ZEXCEL_T_SHARED_STRING.slnk b/ZA2X/TTYP/ZEXCEL_T_SHARED_STRING.slnk new file mode 100644 index 0000000..72eacfa --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_SHARED_STRING.slnk @@ -0,0 +1,2 @@ + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLES_MAPPING.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLES_MAPPING.slnk new file mode 100644 index 0000000..06c4a9b --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLES_MAPPING.slnk @@ -0,0 +1,2 @@ + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLE_ALIGNMENT.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLE_ALIGNMENT.slnk new file mode 100644 index 0000000..fb30252 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLE_ALIGNMENT.slnk @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLE_BORDER.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLE_BORDER.slnk new file mode 100644 index 0000000..89c9273 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLE_BORDER.slnk @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLE_FILL.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLE_FILL.slnk new file mode 100644 index 0000000..6e19440 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLE_FILL.slnk @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLE_FONT.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLE_FONT.slnk new file mode 100644 index 0000000..1564172 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLE_FONT.slnk @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLE_NUMFMT.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLE_NUMFMT.slnk new file mode 100644 index 0000000..6da9c5f --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLE_NUMFMT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_WORKSHEET_COLUMNDIME.slnk b/ZA2X/TTYP/ZEXCEL_T_WORKSHEET_COLUMNDIME.slnk new file mode 100644 index 0000000..10629bb --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_WORKSHEET_COLUMNDIME.slnk @@ -0,0 +1,2 @@ + + diff --git a/ZA2X/TTYP/ZEXCEL_T_WORKSHEET_ROWDIMENSIO.slnk b/ZA2X/TTYP/ZEXCEL_T_WORKSHEET_ROWDIMENSIO.slnk new file mode 100644 index 0000000..da2bfe6 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_WORKSHEET_ROWDIMENSIO.slnk @@ -0,0 +1,2 @@ + + diff --git a/ZA2X/licence.txt b/ZA2X/licence.txt new file mode 100644 index 0000000..07dabfa --- /dev/null +++ b/ZA2X/licence.txt @@ -0,0 +1,20 @@ + + abap2xlsx" + + Copyright (c) 2010 - 2011 Plinky.it + + This library is free software; you can redistribute it and/or + modify it under the terms of the SAP Community Developer Edition + Licence as published by SAP (http://www.sap.com). + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + @category ABAP xlsx Manager + @package ZABAP2XLSX + @author Ivan Femia + @company Techedge SpA + @homepage http://www.plinky.it/software + @licence http://www.sdn.sap.com/irj/scn/nw-downloads + @copyright Copyright (c) 2010 - 2011 http://www.plinky.it diff --git a/ZA2X/readme.txt b/ZA2X/readme.txt new file mode 100644 index 0000000..5008f11 --- /dev/null +++ b/ZA2X/readme.txt @@ -0,0 +1 @@ +Check out the Installation Guide at http://code.google.com/p/abap2xlsx/wiki/InstallationGuide \ No newline at end of file diff --git a/bin/svn-script.cmd b/bin/svn-script.cmd new file mode 100644 index 0000000..118086d --- /dev/null +++ b/bin/svn-script.cmd @@ -0,0 +1,5 @@ +@echo on +shift +rem echo %2 %3 %4 %5 %6 %7 %8 %9 +%ProgramFiles%\Subversion\bin\svn.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 > %0 2>&1 +rem pause \ No newline at end of file diff --git a/bin/tortoise-svn-script.cmd b/bin/tortoise-svn-script.cmd new file mode 100644 index 0000000..c56bc8b --- /dev/null +++ b/bin/tortoise-svn-script.cmd @@ -0,0 +1,5 @@ +@echo on +shift +rem echo %2 %3 %4 %5 %6 %7 %8 %9 +"%ProgramFiles%\TortoiseSVN\bin\TortoiseProc.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 > %0 2>&1 +rem pause \ No newline at end of file diff --git a/build/ABAP2XLSX_V_2_0.zip b/build/ABAP2XLSX_V_2_0.zip new file mode 100644 index 0000000..36e8f2a Binary files /dev/null and b/build/ABAP2XLSX_V_2_0.zip differ diff --git a/build/ABAP2XLSX_daily.nugg.zip b/build/ABAP2XLSX_daily.nugg.zip new file mode 100644 index 0000000..bbfeea3 Binary files /dev/null and b/build/ABAP2XLSX_daily.nugg.zip differ diff --git a/build/NUGG_ABAP2XLSX_V_1_0.nugg b/build/NUGG_ABAP2XLSX_V_1_0.nugg new file mode 100644 index 0000000..8a10341 --- /dev/null +++ b/build/NUGG_ABAP2XLSX_V_1_0.nugg @@ -0,0 +1,15306 @@ + + + + class ZCL_EXCEL_STYLE_ALIGNMENT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data HORIZONTAL type ZEXCEL_ALIGNMENT . + data VERTICAL type ZEXCEL_ALIGNMENT . + data TEXTROTATION type ZEXCEL_TEXT_ROTATION value 0. "#EC NOTEXT . + data WRAPTEXT type FLAG . + data SHRINKTOFIT type FLAG . + data INDENT type ZEXCEL_INDENT value 0. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +private section. + + constants C_HORIZONTAL_GENERAL type ZEXCEL_ALIGNMENT value 'general'. "#EC NOTEXT + constants C_HORIZONTAL_LEFT type ZEXCEL_ALIGNMENT value 'left'. "#EC NOTEXT + constants C_HORIZONTAL_RIGHT type ZEXCEL_ALIGNMENT value 'right'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER_CONTINUOUS type ZEXCEL_ALIGNMENT value 'centerContinuous'. "#EC NOTEXT + constants C_HORIZONTAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + constants C_VERTICAL_BOTTOM type ZEXCEL_ALIGNMENT value 'bottom'. "#EC NOTEXT + constants C_VERTICAL_TOP type ZEXCEL_ALIGNMENT value 'top'. "#EC NOTEXT + constants C_VERTICAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_VERTICAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + METHOD constructor. + horizontal = me->c_horizontal_general. + vertical = me->c_vertical_bottom. + wrapText = abap_false. + shrinkToFit = abap_false. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_BORDER definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +public section. + + data BORDER_STYLE type ZEXCEL_BORDER . + data BORDER_COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_BORDER_NONE type ZEXCEL_BORDER value 'none'. "#EC NOTEXT . + class-data C_BORDER_DASHDOT type ZEXCEL_BORDER value 'dashDot'. "#EC NOTEXT . + class-data C_BORDER_DASHDOTDOT type ZEXCEL_BORDER value 'dashDotDot'. "#EC NOTEXT . + class-data C_BORDER_DASHED type ZEXCEL_BORDER value 'dashed'. "#EC NOTEXT . + class-data C_BORDER_DOTTED type ZEXCEL_BORDER value 'dotted'. "#EC NOTEXT . + class-data C_BORDER_DOUBLE type ZEXCEL_BORDER value 'double'. "#EC NOTEXT . + class-data C_BORDER_HAIR type ZEXCEL_BORDER value 'hair'. "#EC NOTEXT . + class-data C_BORDER_MEDIUM type ZEXCEL_BORDER value 'medium'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOT type ZEXCEL_BORDER value 'mediumDashDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOTDOT type ZEXCEL_BORDER value 'mediumDashDotDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHED type ZEXCEL_BORDER value 'mediumDashed'. "#EC NOTEXT . + class-data C_BORDER_SLANTDASHDOT type ZEXCEL_BORDER value 'slantDashDot'. "#EC NOTEXT . + class-data C_BORDER_THICK type ZEXCEL_BORDER value 'thick'. "#EC NOTEXT . + class-data C_BORDER_THIN type ZEXCEL_BORDER value 'thin'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + METHOD constructor. + border_style = zcl_excel_style_border=>c_border_none. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_BORDERS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +public section. + + data LEFT type ref to ZCL_EXCEL_STYLE_BORDER . + data RIGHT type ref to ZCL_EXCEL_STYLE_BORDER . + data TOP type ref to ZCL_EXCEL_STYLE_BORDER . + data DOWN type ref to ZCL_EXCEL_STYLE_BORDER . + data DIAGONAL type ref to ZCL_EXCEL_STYLE_BORDER . + data ALLBORDERS type ref to ZCL_EXCEL_STYLE_BORDER . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_BORDER . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +private section. + + constants C_DIAGONAL_NONE type ZEXCEL_DIAGONAL value 0. "#EC NOTEXT + constants C_DIAGONAL_UP type ZEXCEL_DIAGONAL value 1. "#EC NOTEXT + constants C_DIAGONAL_DOWN type ZEXCEL_DIAGONAL value 2. "#EC NOTEXT + constants C_DIAGONAL_BOTH type ZEXCEL_DIAGONAL value 3. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method CONSTRUCTOR. +endmethod. + + + + METHOD get_structure. + +* Check if all borders is set otherwise check single border + IF me->allborders IS BOUND. + es_fill-left_color = me->allborders->border_color. + es_fill-left_style = me->allborders->border_style. + es_fill-right_color = me->allborders->border_color. + es_fill-right_style = me->allborders->border_style. + es_fill-top_color = me->allborders->border_color. + es_fill-top_style = me->allborders->border_style. + es_fill-bottom_color = me->allborders->border_color. + es_fill-bottom_style = me->allborders->border_style. + ELSE. + IF me->left IS BOUND. + es_fill-left_color = me->left->border_color. + es_fill-left_style = me->left->border_style. + ENDIF. + IF me->right IS BOUND. + es_fill-right_color = me->right->border_color. + es_fill-right_style = me->right->border_style. + ENDIF. + IF me->top IS BOUND. + es_fill-top_color = me->top->border_color. + es_fill-top_style = me->top->border_style. + ENDIF. + IF me->down IS BOUND. + es_fill-bottom_color = me->down->border_color. + es_fill-bottom_style = me->down->border_style. + ENDIF. + ENDIF. + +* Check if diagonal is set + IF me->diagonal IS BOUND. + es_fill-diagonal_color = me->diagonal->border_color. + es_fill-diagonal_style = me->diagonal->border_style. + ENDIF. + +ENDMETHOD. "get_structure + + + + class ZCL_EXCEL_STYLE_COLOR definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +public section. + + class-data C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT . + class-data C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT . + class-data C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT . + class-data C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT . + class-data C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT . + class-data C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT . + class-data C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT . + class-data C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT . + class-data C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT . + class-data C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT . + class-data C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT . + + methods CONSTRUCTOR . + class-methods CREATE_NEW_ARGB + importing + !IP_RED type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_GREEN type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_BLU type ZEXCEL_STYLE_COLOR_COMPONENT + returning + value(EP_COLOR_ARGB) type ZEXCEL_STYLE_COLOR_ARGB . + *"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +private section. + + class-data C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +endmethod. + + + + + + + METHOD create_new_argb. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CONCATENATE zcl_excel_style_color=>c_alpha ip_red ip_green ip_blu INTO ep_color_argb. + +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +public section. + + class-data C_ICONSET_3ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '3Arrows'. "#EC NOTEXT . + class-data C_ICONSET_3ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '3ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_3FLAGS type ZEXCEL_CONDITION_RULE_ICONSET value '3Flags'. "#EC NOTEXT . + class-data C_ICONSET_3SIGNS type ZEXCEL_CONDITION_RULE_ICONSET value '3Signs'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols2'. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value ''. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3TrafficLights2'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '4Arrows'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '4ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_4RATING type ZEXCEL_CONDITION_RULE_ICONSET value '4Rating'. "#EC NOTEXT . + class-data C_ICONSET_4REDTOBLACK type ZEXCEL_CONDITION_RULE_ICONSET value '4RedToBlack'. "#EC NOTEXT . + class-data C_ICONSET_4TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value '4TrafficLights'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '5Arrows'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '5ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_5QUARTERS type ZEXCEL_CONDITION_RULE_ICONSET value '5Quarters'. "#EC NOTEXT . + class-data C_ICONSET_5RATING type ZEXCEL_CONDITION_RULE_ICONSET value '5Rating'. "#EC NOTEXT . + class-data C_OPERATOR_BEGINSWITH type ZEXCEL_CONDITION_OPERATOR value 'beginsWith'. "#EC NOTEXT . + class-data C_OPERATOR_BETWEEN type ZEXCEL_CONDITION_OPERATOR value 'between'. "#EC NOTEXT . + class-data C_OPERATOR_CONTAINSTEXT type ZEXCEL_CONDITION_OPERATOR value 'containsText'. "#EC NOTEXT . + class-data C_OPERATOR_ENDSWITH type ZEXCEL_CONDITION_OPERATOR value 'endsWith'. "#EC NOTEXT . + class-data C_OPERATOR_EQUAL type ZEXCEL_CONDITION_OPERATOR value 'equal'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHAN type ZEXCEL_CONDITION_OPERATOR value 'greaterThan'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'greaterThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHAN type ZEXCEL_CONDITION_OPERATOR value 'lessThan'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'lessThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_NONE type ZEXCEL_CONDITION_OPERATOR value ''. "#EC NOTEXT . + class-data C_OPERATOR_NOTCONTAINS type ZEXCEL_CONDITION_OPERATOR value 'notContains'. "#EC NOTEXT . + class-data C_OPERATOR_NOTEQUAL type ZEXCEL_CONDITION_OPERATOR value 'notEqual'. "#EC NOTEXT . + class-data C_RULE_CELLIS type ZEXCEL_CONDITION_RULE value 'cellIs'. "#EC NOTEXT . + class-data C_RULE_CONTAINSTEXT type ZEXCEL_CONDITION_RULE value 'containsText'. "#EC NOTEXT . + class-data C_RULE_EXPRESSION type ZEXCEL_CONDITION_RULE value 'expression'. "#EC NOTEXT . + class-data C_RULE_ICONSET type ZEXCEL_CONDITION_RULE value 'iconSet'. "#EC NOTEXT . + class-data C_RULE_NONE type ZEXCEL_CONDITION_RULE value 'none'. "#EC NOTEXT . + data FORMULA type ZEXCEL_STYLE_FORMULA . + data ICONSET type ZEXCEL_CONDITION_RULE_ICONSET . + data OPERATOR type ZEXCEL_CONDITION_OPERATOR . + data PRIORITY type ZEXCEL_STYLE_PRIORITY value 1. "#EC NOTEXT . + data RULE type ZEXCEL_CONDITION_RULE . + + methods CONSTRUCTOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods SET_RANGE + importing + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data START_CELL type ZEXCEL_S_CELL_DATA . + data STOP_CELL type ZEXCEL_S_CELL_DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + rule = me->c_rule_none. + operator = me->c_operator_none. +* inizialize dimension range + stop_cell-cell_row = 1. + stop_cell-cell_column = 1. + start_cell-cell_row = 1. + start_cell-cell_column = 1. +ENDMETHOD. + + + + METHOD get_dimension_range. + IF stop_cell EQ start_cell. "only one cell + ep_dimension_range = start_cell-cell_coords. + ELSE. + CONCATENATE start_cell-cell_coords ':' stop_cell-cell_coords INTO ep_dimension_range. + ENDIF. +ENDMETHOD. + + + + + + + METHOD set_range. + DATA: lv_column TYPE zexcel_cell_column, + lv_row_alpha TYPE string. + + lv_column = zcl_excel_common=>convert_column2int( ip_stop_column ). + stop_cell-cell_row = 1. + stop_cell-cell_column = lv_column. + lv_row_alpha = ip_stop_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_stop_column lv_row_alpha INTO stop_cell-cell_coords. + + lv_column = zcl_excel_common=>convert_column2int( ip_start_column ). + start_cell-cell_row = 1. + start_cell-cell_column = lv_column. + lv_row_alpha = ip_start_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_start_column lv_row_alpha INTO start_cell-cell_coords. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_FILL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +public section. + + class-data C_FILL_NONE type ZEXCEL_FILL_TYPE value 'none'. "#EC NOTEXT . + class-data C_FILL_SOLID type ZEXCEL_FILL_TYPE value 'solid'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_LINEAR type ZEXCEL_FILL_TYPE value 'linear'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_PATH type ZEXCEL_FILL_TYPE value 'path'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKDOWN type ZEXCEL_FILL_TYPE value 'darkDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRAY type ZEXCEL_FILL_TYPE value 'darkGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRID type ZEXCEL_FILL_TYPE value 'darkGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKHORIZONTAL type ZEXCEL_FILL_TYPE value 'darkHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKTRELLIS type ZEXCEL_FILL_TYPE value 'darkTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKUP type ZEXCEL_FILL_TYPE value 'darkUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKVERTICAL type ZEXCEL_FILL_TYPE value 'darkVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY0625 type ZEXCEL_FILL_TYPE value 'gray0625'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY125 type ZEXCEL_FILL_TYPE value 'gray125'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTDOWN type ZEXCEL_FILL_TYPE value 'lightDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRAY type ZEXCEL_FILL_TYPE value 'lightGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRID type ZEXCEL_FILL_TYPE value 'lightGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTHORIZONTAL type ZEXCEL_FILL_TYPE value 'lightHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTTRELLIS type ZEXCEL_FILL_TYPE value 'lightTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTUP type ZEXCEL_FILL_TYPE value 'lightUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTVERTICAL type ZEXCEL_FILL_TYPE value 'lightVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_MEDIUMGRAY type ZEXCEL_FILL_TYPE value 'mediumGray'. "#EC NOTEXT . + data FILLTYPE type ZEXCEL_FILL_TYPE . + data ROTATION type ZEXCEL_ROTATION . + data FGCOLOR type ZEXCEL_STYLE_COLOR_ARGB . + data BGCOLOR type ZEXCEL_STYLE_COLOR_ARGB value '64'. "#EC NOTEXT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_FILL . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + filltype = zcl_excel_style_fill=>c_fill_none. + rotation = 0. +ENDMETHOD. + + + + METHOD get_structure. + es_fill-rotation = me->rotation. + es_fill-filltype = me->filltype. + es_fill-fgColor = me->fgColor. + es_fill-bgColor = me->bgColor. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_FONT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data BOLD type FLAG . + data COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_SCHEME_MAJOR type ZEXCEL_STYLE_FONT_SCHEME value 'major'. "#EC NOTEXT . + class-data C_SCHEME_MINOR type ZEXCEL_STYLE_FONT_SCHEME value 'minor'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLE type CHAR20 value 'double'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLEACCOUNTING type CHAR20 value 'doubleAccounting'. "#EC NOTEXT . + class-data C_UNDERLINE_NONE type CHAR20 value 'none'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLE type CHAR20 value 'single'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLEACCOUNTING type CHAR20 value 'singleAccounting'. "#EC NOTEXT . + data FAMILY type INT1 value 2. "#EC NOTEXT . + data ITALIC type FLAG . + data NAME type CHAR255 value 'Calibri'. "#EC NOTEXT . + data SCHEME type ZEXCEL_STYLE_FONT_SCHEME . + data SIZE type INT1 value 11. "#EC NOTEXT . + data STRIKETHROUGH type FLAG . + data UNDERLINE type FLAG . + data UNDERLINE_MODE type CHAR20 . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FONT) type ZEXCEL_S_STYLE_FONT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->color = zcl_excel_style_color=>c_black. + me->scheme = zcl_excel_style_font=>c_scheme_minor. + me->underline_mode = zcl_excel_style_font=>c_underline_single. +ENDMETHOD. + + + + METHOD get_structure. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + es_font-bold = me->bold. + es_font-italic = me->italic. + es_font-underline = me->underline. + es_font-underline_mode = me->underline_mode. + es_font-strikethrough = me->strikethrough. + es_font-size = me->size. + es_font-color = me->color. + es_font-name = me->name. + es_font-family = me->family. + es_font-scheme = me->scheme. + +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_NUMBER_FORMAT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +public section. + + class-data C_FORMAT_NUMBER type ZEXCEL_NUMBER_FORMAT value '0'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_00 type ZEXCEL_NUMBER_FORMAT value '0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP1 type ZEXCEL_NUMBER_FORMAT value '#,##0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP2 type ZEXCEL_NUMBER_FORMAT value '#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE type ZEXCEL_NUMBER_FORMAT value '0%'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE_00 type ZEXCEL_NUMBER_FORMAT value '0.00%'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD2 type ZEXCEL_NUMBER_FORMAT value 'yyyy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD type ZEXCEL_NUMBER_FORMAT value 'yy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DDMMYYYY type ZEXCEL_NUMBER_FORMAT value 'dd/mm/yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYSLASH type ZEXCEL_NUMBER_FORMAT value 'd/m/y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m'. "#EC NOTEXT . + class-data C_FORMAT_DATE_MYMINUS type ZEXCEL_NUMBER_FORMAT value 'm-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX14 type ZEXCEL_NUMBER_FORMAT value 'mm-dd-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX15 type ZEXCEL_NUMBER_FORMAT value 'd-mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX16 type ZEXCEL_NUMBER_FORMAT value 'd-mmm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX17 type ZEXCEL_NUMBER_FORMAT value 'mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX22 type ZEXCEL_NUMBER_FORMAT value 'm/d/yy h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DATETIME type ZEXCEL_NUMBER_FORMAT value 'd/m/y h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME1 type ZEXCEL_NUMBER_FORMAT value 'h:mm AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME2 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME3 type ZEXCEL_NUMBER_FORMAT value 'h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME4 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME5 type ZEXCEL_NUMBER_FORMAT value 'mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME6 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME7 type ZEXCEL_NUMBER_FORMAT value 'i:s.S'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME8 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss@'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDDSLASH type ZEXCEL_NUMBER_FORMAT value 'yy/mm/dd@'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD_SIMPLE type ZEXCEL_NUMBER_FORMAT value '"$"#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD type ZEXCEL_NUMBER_FORMAT value '$#,##0_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_EUR_SIMPLE type ZEXCEL_NUMBER_FORMAT value '[$EUR ]#,##0.00_-'. "#EC NOTEXT . + data FORMAT_CODE type ZEXCEL_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(EP_NUMBER_FORMAT) type ZEXCEL_NUMBER_FORMAT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +private section. + + class-data C_FORMAT_GENERAL type ZEXCEL_NUMBER_FORMAT value ''. "#EC NOTEXT . + class-data C_FORMAT_TEXT type ZEXCEL_NUMBER_FORMAT value '@'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + format_code = me->c_format_general. +ENDMETHOD. + + + + METHOD get_structure. + ep_number_format = me->format_code. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_PROTECTION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +public section. + + constants C_PROTECTION_INHERIT type ZEXCEL_PROTECTION value 'inherit'. "#EC NOTEXT + constants C_PROTECTION_PROTECTED type ZEXCEL_PROTECTION value 'protected'. "#EC NOTEXT + constants C_PROTECTION_UNPROTECTED type ZEXCEL_PROTECTION value 'unprotected'. "#EC NOTEXT + data LOCKED type ZEXCEL_PROTECTION . + data HIDDEN type ZEXCEL_PROTECTION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + METHOD constructor. + locked = me->c_protection_inherit. + hidden = me->c_protection_inherit. +ENDMETHOD. + + + + class ZCL_EXCEL_WORKSHEET definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + class-data C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT . + class-data C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT . + class-data C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT . + class-data C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT . + data DEFAULTROWHEIGHT type INT1 value 15. "#EC NOTEXT . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHEET_STATE type ZEXCEL_SHEET_STATE . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING . + methods GET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + methods SET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type ZEXCEL_CELL_VALUE + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional . + methods SET_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING optional + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . + methods ADD_NEW_CONDITIONAL_STYLE + returning + value(EO_CONDITIONAL_STYLE) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_COND_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CONDITIONAL_STYLES type ref to ZCL_EXCEL_STYLES_CONDITIONAL . + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + + methods UPDATE_DIMENSION_RANGE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + METHOD add_new_conditional_style. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT eo_conditional_style. + conditional_styles->add( eo_conditional_style ). +ENDMETHOD. + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + sheet_state = me->c_sheet_state_visible. + + CREATE OBJECT sheet_setup. + CREATE OBJECT conditional_styles. + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +ENDMETHOD. + + + + METHOD get_active_cell. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_active_column TYPE zexcel_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = zcl_excel_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + +ENDMETHOD. + + + + + + + METHOD get_cell. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = ip_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. +ENDMETHOD. + + + + method GET_COND_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->conditional_styles->get_iterator( ). +endmethod. + + + + METHOD get_dimension_range. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + ep_dimension_range = upper_cell-cell_coords. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + +ENDMETHOD. + + + + method GET_GUID. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. + +endmethod. + + + + + + + + METHOD set_cell. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = ZCL_EXCEL_COMMON=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_value = ip_value. + <fs_sheet_content>-cell_formula = ip_formula. + <fs_sheet_content>-cell_style = ip_style. + ELSE. + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column. + ls_sheet_content-cell_value = ip_value. + ls_sheet_content-cell_formula = ip_formula. + ls_sheet_content-cell_style = ip_style. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content. + SORT sheet_content BY cell_row cell_column. +* me->update_dimension_range( ). + + ENDIF. + +ENDMETHOD. + + + + + + + + + METHOD set_table. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, + lr_data TYPE REF TO data, + ls_newline TYPE REF TO data, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + lv_row_header TYPE zexcel_cell_row VALUE '2', + lv_col_header TYPE zexcel_cell_column_alpha VALUE 'B', + lv_row_int TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lv_cell_value TYPE zexcel_cell_value. + + + FIELD-SYMBOLS: <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY, + <fs_dfies> TYPE dfies, + <fs_cell_value> TYPE zexcel_cell_value. + + lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). + lv_row_int = ip_top_left_row. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + +* It is better to loop column by column + LOOP AT lt_dfies ASSIGNING <fs_dfies>. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + " First of all write column header + lv_cell_value = <fs_dfies>-scrtext_m. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_hdr_style ). + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <fs_dfies>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + MOVE <fs_fldval> TO lv_cell_value. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_body_style ). + ADD 1 TO lv_row_int. + ENDLOOP. + lv_row_int = ip_top_left_row. + ADD 1 TO lv_column_int. + ENDLOOP. + +ENDMETHOD. + + + METHOD update_dimension_range. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: ls_sheet_content TYPE zexcel_s_cell_data, + lt_sheet_content TYPE zexcel_t_cell_data_unsorted, + lv_row_alpha TYPE string, + lv_column_alpha TYPE zexcel_cell_column_alpha. + +* update dimension range + lt_sheet_content = sheet_content. + "upper left corner + SORT lt_sheet_content BY cell_row. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = upper_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( upper_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO upper_cell-cell_coords. + + "bottom right corner + SORT lt_sheet_content BY cell_row DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = lower_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lower_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. + +ENDMETHOD. + + + + class ZCL_EXCEL_WORKSHEETS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +public section. + + data ACTIVE_WORKSHEET type ZEXCEL_ACTIVE_WORKSHEET value 1. "#EC NOTEXT . + data NAME type ZEXCEL_WORKSHEETS_NAME value 'Worksheets'. "#EC NOTEXT . + + methods ADD + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +private section. + + data WORKSHEETS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + METHOD ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->add( ip_worksheet ). +ENDMETHOD. + + + METHOD clear. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->clear( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT worksheets. + +ENDMETHOD. + + + + + METHOD get. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_worksheet ?= worksheets->if_object_collection~get( lv_index ). +ENDMETHOD. + + + + METHOD get_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= worksheets->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = worksheets->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->remove( ip_worksheet ). +ENDMETHOD. + + + + METHOD size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = worksheets->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + methods CONSTRUCTOR + importing + !IO_EXCEL type ref to ZCL_EXCEL . + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_CALCCHAIN type STRING value 'xl/calcChain.xml'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_CALCCHAIN + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->excel = io_excel. +ENDMETHOD. + + + + METHOD create. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sharedStrings.xml to zip + lv_content = me->create_xl_calcchain( ). + lo_zip->add( name = me->c_xl_calcchain + content = lv_content ). + +********************************************************************** +* STEP 11: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +ENDMETHOD. + + + + METHOD create_content_types. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lv_xml_node_worksheet_pn ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_docprops_app. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_docprops_core. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD CREATE_RELATIONSHIPS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_calcchain. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_calcchain TYPE string VALUE 'calcChain', + lc_xml_node_c TYPE string VALUE 'c', + " Node attributes + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_i TYPE string VALUE 'i', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string, + lv_value_i TYPE string, + lv_sheets_count TYPE i. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create xl/calcChain.xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node calcChain + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_calcchain + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + ADD 1 TO lv_sheets_count. + MOVE lv_sheets_count TO lv_value_i. + SHIFT lv_value_i RIGHT DELETING TRAILING space. + SHIFT lv_value_i LEFT DELETING LEADING space. + LOOP AT lo_worksheet->sheet_content ASSIGNING <ls_sheet_content> WHERE cell_formula IS NOT INITIAL. + " formula chain node + lo_element = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_i + value = lv_value_i ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_relationships. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + lc_xml_node_rid_calcchain_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml', + lc_xml_node_rid_calcchain_tg TYPE string VALUE 'calcChain.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 1 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_calcchain_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_calcchain_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_sharedstrings. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + + METHOD create_xl_sheet. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional. + + DATA: lv_value TYPE string, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + lv_value = io_worksheet->defaultrowheight. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + lo_element_root->append_child( lo_element ). " sheetFormatPr node + + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = '1:1' ). " <******************************* + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + IF ls_style_mapping-cell_format IS INITIAL. " to avoid errors if no style has been created + IF <ls_sheet_content>-cell_formula IS INITIAL. + ls_style_mapping-cell_format = 'S'. + ELSE. + ls_style_mapping-cell_format = 'F'. + ENDIF. + ENDIF. + " is a shared string and is not a formula + IF ls_style_mapping-cell_format EQ 'S'. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = 's' ). + ENDIF. + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ENDIF. + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF ls_style_mapping-cell_format EQ 'S'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_sheet_rels. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + lc_xml_node_rid_print_id TYPE string VALUE 'rId1', + " Node type + lc_xml_node_rid_print_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', + " Node target + lc_xml_node_rid_print_tg TYPE string VALUE '../printerSettings/printerSettings1.bin'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rid_print_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_print_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_print_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_styles. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + ls_format TYPE zexcel_number_format, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_format = lo_style->number_format->get_structure( ). + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + + IF ls_format IS INITIAL. + ls_cellxfs-numfmtid = 0. " number format + ELSE. + ls_cellxfs-numfmtid = ls_format. " number format + ENDIF. + ls_cellxfs-xfid = 0. + + IF ls_format IS NOT INITIAL. + ls_cellxfs-applynumberformat = 1. + ls_styles_mapping-cell_format = 'I'. + ELSE. + ls_cellxfs-applynumberformat = 0. + ls_styles_mapping-cell_format = 'S'. + ENDIF. + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + " Collect color + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = 'TableStyleMedium9' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = 'PivotStyleLight16' ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_theme. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +ENDMETHOD. + + + + METHOD create_xl_workbook. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + METHOD flag2bool. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +ENDMETHOD. + + + + + METHOD get_shared_string_index. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +ENDMETHOD. + + + + class ZCL_EXCEL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! +public section. + + constants C_XLS type ZEXCEL_FORMAT value 'XLS'. "#EC NOTEXT + constants C_XLSX type ZEXCEL_FORMAT value 'XLSX'. "#EC NOTEXT + data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . + data SECURITY type ref to ZCL_EXCEL_SECURITY . + + methods ADD_NEW_DRAWING + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_STYLE + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods ADD_NEW_WORKSHEET + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods CONSTRUCTOR . + methods GET_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_DRAWINGS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_NAME + returning + value(EP_NAME) type ZEXCEL_WORKSHEETS_NAME . + methods GET_WORKSHEETS_SIZE + returning + value(EP_SIZE) type I . + methods SAVE_AS + importing + !IP_FORMAT type ZEXCEL_FORMAT + returning + value(EP_FILE) type XSTRING . + *"* protected components of class ZABAP_EXCEL +*"* do not include other source files here!!! +protected 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 . + data STYLES type ref to ZCL_EXCEL_STYLES . + data WORKSHEETS type ref to ZCL_EXCEL_WORKSHEETS . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + METHOD add_new_drawing. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_title = ip_title. + drawings->add( eo_drawing ). +ENDMETHOD. + + + + method ADD_NEW_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Create default style + CREATE OBJECT eo_style. + styles->add( eo_style ). + +endmethod. + + + + + METHOD add_new_worksheet. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_title = ip_title. + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style TYPE REF TO zcl_excel_style. + +* Inizialize instance objects + CREATE OBJECT properties. + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings. + + 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. + + + + method GET_ACTIVE_WORKSHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + +endmethod. + + + + METHOD GET_DRAWINGS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->drawings->get_iterator( ). +ENDMETHOD. + + + + METHOD GET_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->styles->get_iterator( ). +ENDMETHOD. + + + + METHOD get_worksheets_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->worksheets->get_iterator( ). +ENDMETHOD. + + + + METHOD GET_WORKSHEETS_NAME. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_name = me->worksheets->name. + +ENDMETHOD. + + + + METHOD get_worksheets_size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = me->worksheets->size( ). + +ENDMETHOD. + + + + + METHOD save_as. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lo_excel_writer_2007 TYPE REF TO zcl_excel_writer_2007. + +* Determine the output engine to use + CASE ip_format. + WHEN me->c_xlsx. " XLSX for Office 2007 + CREATE OBJECT lo_excel_writer_2007 EXPORTING io_excel = me. + ep_file = lo_excel_writer_2007->create( ). + WHEN OTHERS. + ENDCASE. + +ENDMETHOD. + + + + class ZCL_EXCEL_COMMON definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +public section. + + class-methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + class-methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +private section. + + class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + METHOD convert_column2alpha. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +ENDMETHOD. + + + + + METHOD convert_column2int. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( zcl_excel_common=>c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( zcl_excel_common=>c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - zcl_excel_common=>c_excel_col_module. + ENDIF. + +ENDMETHOD. + + + + class ZCL_EXCEL_DRAWING definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + data X_REFERENCES type CHAR1 . + data Y_REFERENCES type CHAR1 . + data GRAPH_TYPE type ZEXCEL_GRAPH_TYPE . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +private section. + + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + constants C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT + + methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + METHOD CONSTRUCTOR. + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +ENDMETHOD. + + + + + METHOD CONVERT_COLUMN2ALPHA. + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +ENDMETHOD. + + + + + METHOD CONVERT_COLUMN2INT. + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( me->c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( me->c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - me->c_excel_col_module. + ENDIF. + +ENDMETHOD. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + class ZCL_EXCEL_DRAWINGS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +private section. + + data DRAWINGS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD add. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->add( ip_drawing ). +ENDMETHOD. + + + METHOD clear. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->clear( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT drawings. + +ENDMETHOD. + + + + + METHOD get. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_drawing ?= drawings->if_object_collection~get( lv_index ). +ENDMETHOD. + + + + METHOD get_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= drawings->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = drawings->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->remove( ip_drawing ). +ENDMETHOD. + + + + METHOD size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = drawings->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_PROPERTIES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +public section. + + data CREATOR type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data LASTMODIFIEDBY type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data CREATED type TIMESTAMPL . + data MODIFIED type TIMESTAMPL . + data TITLE type ZEXCEL_TITLE value 'Untitled Spreadsheet'. "#EC NOTEXT . + data SUBJECT type ZEXCEL_SUBJECT . + data DESCRIPTION type ZEXCEL_DESCRIPTION . + data KEYWORDS type ZEXCEL_KEYWORDS . + data CATEGORY type ZEXCEL_CATEGORY . + data COMPANY type ZEXCEL_COMPANY value 'Microsoft Corporation'. "#EC NOTEXT . + data APPLICATION type ZEXCEL_APPLICATION value 'Microsoft Excel'. "#EC NOTEXT . + data DOCSECURITY type ZEXCEL_DOCSECURITY value '0'. "#EC NOTEXT . + data SCALECROP type ZEXCEL_SCALECROP value ''. "#EC NOTEXT . + data LINKSUPTODATE type FLAG . + data SHAREDDOC type FLAG . + data HYPERLINKSCHANGED type FLAG . + data APPVERSION type ZEXCEL_APPVERSION value '12.0000'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_PROPERTIES +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + METHOD CONSTRUCTOR. + + DATA: lv_timestamp TYPE timestampl. + + GET TIME STAMP FIELD lv_timestamp. + created = lv_timestamp. + modified = lv_timestamp. + +ENDMETHOD. + + + + class ZCL_EXCEL_RANGE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +public section. + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + method CONSTRUCTOR. +endmethod. + + + + class ZCL_EXCEL_RANGES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! +private section. + + data RANGES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD ADD. + ranges->add( ip_range ). +ENDMETHOD. + + + METHOD CLEAR. + ranges->clear( ). +ENDMETHOD. + + + method CONSTRUCTOR. +endmethod. + + + + + METHOD GET. + eo_range ?= ranges->if_object_collection~get( ip_index ). +ENDMETHOD. + + + + METHOD GET_ITERATOR. + eo_iterator ?= ranges->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD IS_EMPTY. + is_empty = ranges->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD REMOVE. + ranges->remove( ip_range ). +ENDMETHOD. + + + + METHOD SIZE. + ep_size = ranges->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_SECURITY definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SECURITY +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data LOCKREVISION type FLAG . + data LOCKSTRUCTURE type FLAG . + data LOCKWINDOWS type FLAG . + data REVISIONSPASSWORD type ZEXCEL_REVISIONSPASSWORD . + data WORKBOOKPASSWORD type ZEXCEL_WORKBOOKPASSWORD . + + methods CONSTRUCTOR . + methods IS_SECURITY_ENABLED + returning + value(EP_SECURITY_ENABLED) type FLAG . + *"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + method CONSTRUCTOR. +endmethod. + + + + METHOD IS_SECURITY_ENABLED. + IF lockrevision EQ abap_true OR lockstructure EQ abap_true OR lockwindows EQ abap_true. + ep_security_enabled = abap_true. + ENDIF. +ENDMETHOD. + + + + class ZCL_EXCEL_SHEET_SETUP definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants C_PAPERSIZE_LETTER type ZEXCEL_SHEET_PAPER_SIZE value 1. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 2. "#EC NOTEXT + constants C_PAPERSIZE_TABLOID type ZEXCEL_SHEET_PAPER_SIZE value 3. "#EC NOTEXT + constants C_PAPERSIZE_LEDGER type ZEXCEL_SHEET_PAPER_SIZE value 4. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL type ZEXCEL_SHEET_PAPER_SIZE value 5. "#EC NOTEXT + constants C_PAPERSIZE_STATEMENT type ZEXCEL_SHEET_PAPER_SIZE value 6. "#EC NOTEXT + constants C_PAPERSIZE_EXECUTIVE type ZEXCEL_SHEET_PAPER_SIZE value 7. "#EC NOTEXT + constants C_PAPERSIZE_A3 type ZEXCEL_SHEET_PAPER_SIZE value 8. "#EC NOTEXT + constants C_PAPERSIZE_A4 type ZEXCEL_SHEET_PAPER_SIZE value 9. "#EC NOTEXT + constants C_PAPERSIZE_A4_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 10. "#EC NOTEXT + constants C_PAPERSIZE_A5 type ZEXCEL_SHEET_PAPER_SIZE value 11. "#EC NOTEXT + constants C_PAPERSIZE_B4 type ZEXCEL_SHEET_PAPER_SIZE value 12. "#EC NOTEXT + constants C_PAPERSIZE_B5 type ZEXCEL_SHEET_PAPER_SIZE value 13. "#EC NOTEXT + constants C_PAPERSIZE_FOLIO type ZEXCEL_SHEET_PAPER_SIZE value 14. "#EC NOTEXT + constants C_PAPERSIZE_QUARTO type ZEXCEL_SHEET_PAPER_SIZE value 15. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_1 type ZEXCEL_SHEET_PAPER_SIZE value 16. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_2 type ZEXCEL_SHEET_PAPER_SIZE value 17. "#EC NOTEXT + constants C_PAPERSIZE_NOTE type ZEXCEL_SHEET_PAPER_SIZE value 18. "#EC NOTEXT + constants C_PAPERSIZE_NO9_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 19. "#EC NOTEXT + constants C_PAPERSIZE_NO10_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 20. "#EC NOTEXT + constants C_PAPERSIZE_NO11_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 21. "#EC NOTEXT + constants C_PAPERSIZE_NO12_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 22. "#EC NOTEXT + constants C_PAPERSIZE_NO14_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 23. "#EC NOTEXT + constants C_PAPERSIZE_C type ZEXCEL_SHEET_PAPER_SIZE value 24. "#EC NOTEXT + constants C_PAPERSIZE_D type ZEXCEL_SHEET_PAPER_SIZE value 25. "#EC NOTEXT + constants C_PAPERSIZE_E type ZEXCEL_SHEET_PAPER_SIZE value 26. "#EC NOTEXT + constants C_PAPERSIZE_DL_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 27. "#EC NOTEXT + constants C_PAPERSIZE_C5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 28. "#EC NOTEXT + constants C_PAPERSIZE_C3_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 29. "#EC NOTEXT + constants C_PAPERSIZE_C4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 30. "#EC NOTEXT + constants C_PAPERSIZE_C6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 31. "#EC NOTEXT + constants C_PAPERSIZE_C65_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 32. "#EC NOTEXT + constants C_PAPERSIZE_B4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 33. "#EC NOTEXT + constants C_PAPERSIZE_B5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 34. "#EC NOTEXT + constants C_PAPERSIZE_B6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 35. "#EC NOTEXT + constants C_PAPERSIZE_ITALY_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 36. "#EC NOTEXT + constants C_PAPERSIZE_MONARCH_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 37. "#EC NOTEXT + constants C_PAPERSIZE_6_3_4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 38. "#EC NOTEXT + constants C_PAPERSIZE_US_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 39. "#EC NOTEXT + constants C_PAPERSIZE_DE_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 40. "#EC NOTEXT + constants C_PAPERSIZE_DE_LEG_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 41. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B4 type ZEXCEL_SHEET_PAPER_SIZE value 42. "#EC NOTEXT + constants C_PAPERSIZE_JPN_DBL_POSTCARD type ZEXCEL_SHEET_PAPER_SIZE value 43. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_1 type ZEXCEL_SHEET_PAPER_SIZE value 44. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_2 type ZEXCEL_SHEET_PAPER_SIZE value 45. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_3 type ZEXCEL_SHEET_PAPER_SIZE value 46. "#EC NOTEXT + constants C_PAPERSIZE_INVITE_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 47. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 48. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 49. "#EC NOTEXT + constants C_PAPERSIZE_TABL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 50. "#EC NOTEXT + constants C_PAPERSIZE_A4_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 51. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 52. "#EC NOTEXT + constants C_PAPERSIZE_A4_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 53. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 54. "#EC NOTEXT + constants C_PAPERSIZE_SUPERA_A4_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 55. "#EC NOTEXT + constants C_PAPERSIZE_SUPERB_A3_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 56. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 57. "#EC NOTEXT + constants C_PAPERSIZE_A4_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 58. "#EC NOTEXT + constants C_PAPERSIZE_A5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 59. "#EC NOTEXT + constants C_PAPERSIZE_JIS_B5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 60. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 61. "#EC NOTEXT + constants C_PAPERSIZE_A5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 62. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 63. "#EC NOTEXT + constants C_PAPERSIZE_A2_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 64. "#EC NOTEXT + constants C_PAPERSIZE_A3_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 65. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 66. "#EC NOTEXT + constants C_ORIENTATION_DEFAULT type ZEXCEL_SHEET_ORIENATATION value 'default'. "#EC NOTEXT + constants C_ORIENTATION_LANDSCAPE type ZEXCEL_SHEET_ORIENATATION value 'landscape'. "#EC NOTEXT + constants C_ORIENTATION_PORTRAIT type ZEXCEL_SHEET_ORIENATATION value 'portrait'. "#EC NOTEXT + data ORIENTATION type ZEXCEL_SHEET_ORIENATATION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + orientation = me->c_orientation_default. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +public section. + + data FONT type ref to ZCL_EXCEL_STYLE_FONT . + data FILL type ref to ZCL_EXCEL_STYLE_FILL . + data BORDERS type ref to ZCL_EXCEL_STYLE_BORDERS . + data NUMBER_FORMAT type ref to ZCL_EXCEL_STYLE_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_CELL_STYLE . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +private section. + + data ALIGNMENT type ref to ZCL_EXCEL_STYLE_ALIGNMENT . + data PROTECTION type ref to ZCL_EXCEL_STYLE_PROTECTION . + data GUID type ZEXCEL_CELL_STYLE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT font. + CREATE OBJECT fill. + CREATE OBJECT borders. + CREATE OBJECT alignment. + CREATE OBJECT number_format. + CREATE OBJECT protection. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + +ENDMETHOD. + + + + METHOD get_guid. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods SIZE + returning + value(EP_SIZE) type I . + methods REGISTER_NEW_STYLE + importing + !IO_STYLE type ref to ZCL_EXCEL_STYLE + returning + value(EP_STYLE_CODE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +private section. + + data STYLES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD add. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->add( ip_style ). +ENDMETHOD. + + + METHOD clear. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->clear( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT styles. +ENDMETHOD. + + + + + METHOD get. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_style ?= styles->if_object_collection~get( ip_index ). +ENDMETHOD. + + + + METHOD get_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= styles->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = styles->if_object_collection~is_empty( ). +ENDMETHOD. + + + + + METHOD register_new_style. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->add( io_style ). + ep_style_code = me->size( ) - 1. "style count starts from 0 +ENDMETHOD. + + + + METHOD remove. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->remove( ip_style ). +ENDMETHOD. + + + + METHOD size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = styles->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_STYLES_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_STYLE_CONDITIONAL) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data STYLES_CONDITIONAL type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD add. + styles_conditional->add( ip_style_conditional ). +ENDMETHOD. + + + METHOD clear. + styles_conditional->clear( ). +ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT styles_conditional. + +ENDMETHOD. + + + + + METHOD get. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_style_conditional ?= styles_conditional->if_object_collection~get( lv_index ). +ENDMETHOD. + + + + METHOD get_iterator. + eo_iterator ?= styles_conditional->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. + is_empty = styles_conditional->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. + styles_conditional->remove( ip_style_conditional ). +ENDMETHOD. + + + + METHOD size. + ep_size = styles_conditional->if_object_collection~size( ). +ENDMETHOD. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + class ZCL_EXCEL_STYLE_ALIGNMENT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data HORIZONTAL type ZEXCEL_ALIGNMENT . + data VERTICAL type ZEXCEL_ALIGNMENT . + data TEXTROTATION type ZEXCEL_TEXT_ROTATION value 0. "#EC NOTEXT . + data WRAPTEXT type FLAG . + data SHRINKTOFIT type FLAG . + data INDENT type ZEXCEL_INDENT value 0. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +private section. + + constants C_HORIZONTAL_GENERAL type ZEXCEL_ALIGNMENT value 'general'. "#EC NOTEXT + constants C_HORIZONTAL_LEFT type ZEXCEL_ALIGNMENT value 'left'. "#EC NOTEXT + constants C_HORIZONTAL_RIGHT type ZEXCEL_ALIGNMENT value 'right'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER_CONTINUOUS type ZEXCEL_ALIGNMENT value 'centerContinuous'. "#EC NOTEXT + constants C_HORIZONTAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + constants C_VERTICAL_BOTTOM type ZEXCEL_ALIGNMENT value 'bottom'. "#EC NOTEXT + constants C_VERTICAL_TOP type ZEXCEL_ALIGNMENT value 'top'. "#EC NOTEXT + constants C_VERTICAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_VERTICAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + METHOD constructor. + horizontal = me->c_horizontal_general. + vertical = me->c_vertical_bottom. + wrapText = abap_false. + shrinkToFit = abap_false. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_BORDER definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +public section. + + data BORDER_STYLE type ZEXCEL_BORDER . + data BORDER_COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_BORDER_NONE type ZEXCEL_BORDER value 'none'. "#EC NOTEXT . + class-data C_BORDER_DASHDOT type ZEXCEL_BORDER value 'dashDot'. "#EC NOTEXT . + class-data C_BORDER_DASHDOTDOT type ZEXCEL_BORDER value 'dashDotDot'. "#EC NOTEXT . + class-data C_BORDER_DASHED type ZEXCEL_BORDER value 'dashed'. "#EC NOTEXT . + class-data C_BORDER_DOTTED type ZEXCEL_BORDER value 'dotted'. "#EC NOTEXT . + class-data C_BORDER_DOUBLE type ZEXCEL_BORDER value 'double'. "#EC NOTEXT . + class-data C_BORDER_HAIR type ZEXCEL_BORDER value 'hair'. "#EC NOTEXT . + class-data C_BORDER_MEDIUM type ZEXCEL_BORDER value 'medium'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOT type ZEXCEL_BORDER value 'mediumDashDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOTDOT type ZEXCEL_BORDER value 'mediumDashDotDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHED type ZEXCEL_BORDER value 'mediumDashed'. "#EC NOTEXT . + class-data C_BORDER_SLANTDASHDOT type ZEXCEL_BORDER value 'slantDashDot'. "#EC NOTEXT . + class-data C_BORDER_THICK type ZEXCEL_BORDER value 'thick'. "#EC NOTEXT . + class-data C_BORDER_THIN type ZEXCEL_BORDER value 'thin'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + METHOD constructor. + border_style = zcl_excel_style_border=>c_border_none. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_BORDERS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +public section. + + data LEFT type ref to ZCL_EXCEL_STYLE_BORDER . + data RIGHT type ref to ZCL_EXCEL_STYLE_BORDER . + data TOP type ref to ZCL_EXCEL_STYLE_BORDER . + data DOWN type ref to ZCL_EXCEL_STYLE_BORDER . + data DIAGONAL type ref to ZCL_EXCEL_STYLE_BORDER . + data ALLBORDERS type ref to ZCL_EXCEL_STYLE_BORDER . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_BORDER . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +private section. + + constants C_DIAGONAL_NONE type ZEXCEL_DIAGONAL value 0. "#EC NOTEXT + constants C_DIAGONAL_UP type ZEXCEL_DIAGONAL value 1. "#EC NOTEXT + constants C_DIAGONAL_DOWN type ZEXCEL_DIAGONAL value 2. "#EC NOTEXT + constants C_DIAGONAL_BOTH type ZEXCEL_DIAGONAL value 3. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method CONSTRUCTOR. +endmethod. + + + + METHOD get_structure. + +* Check if all borders is set otherwise check single border + IF me->allborders IS BOUND. + es_fill-left_color = me->allborders->border_color. + es_fill-left_style = me->allborders->border_style. + es_fill-right_color = me->allborders->border_color. + es_fill-right_style = me->allborders->border_style. + es_fill-top_color = me->allborders->border_color. + es_fill-top_style = me->allborders->border_style. + es_fill-bottom_color = me->allborders->border_color. + es_fill-bottom_style = me->allborders->border_style. + ELSE. + IF me->left IS BOUND. + es_fill-left_color = me->left->border_color. + es_fill-left_style = me->left->border_style. + ENDIF. + IF me->right IS BOUND. + es_fill-right_color = me->right->border_color. + es_fill-right_style = me->right->border_style. + ENDIF. + IF me->top IS BOUND. + es_fill-top_color = me->top->border_color. + es_fill-top_style = me->top->border_style. + ENDIF. + IF me->down IS BOUND. + es_fill-bottom_color = me->down->border_color. + es_fill-bottom_style = me->down->border_style. + ENDIF. + ENDIF. + +* Check if diagonal is set + IF me->diagonal IS BOUND. + es_fill-diagonal_color = me->diagonal->border_color. + es_fill-diagonal_style = me->diagonal->border_style. + ENDIF. + +ENDMETHOD. "get_structure + + + + class ZCL_EXCEL_STYLE_COLOR definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +public section. + + class-data C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT . + class-data C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT . + class-data C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT . + class-data C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT . + class-data C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT . + class-data C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT . + class-data C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT . + class-data C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT . + class-data C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT . + class-data C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT . + class-data C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT . + + methods CONSTRUCTOR . + class-methods CREATE_NEW_ARGB + importing + !IP_RED type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_GREEN type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_BLU type ZEXCEL_STYLE_COLOR_COMPONENT + returning + value(EP_COLOR_ARGB) type ZEXCEL_STYLE_COLOR_ARGB . + *"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +private section. + + class-data C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +endmethod. + + + + + + + METHOD create_new_argb. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CONCATENATE zcl_excel_style_color=>c_alpha ip_red ip_green ip_blu INTO ep_color_argb. + +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +public section. + + class-data C_ICONSET_3ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '3Arrows'. "#EC NOTEXT . + class-data C_ICONSET_3ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '3ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_3FLAGS type ZEXCEL_CONDITION_RULE_ICONSET value '3Flags'. "#EC NOTEXT . + class-data C_ICONSET_3SIGNS type ZEXCEL_CONDITION_RULE_ICONSET value '3Signs'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols2'. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value ''. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3TrafficLights2'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '4Arrows'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '4ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_4RATING type ZEXCEL_CONDITION_RULE_ICONSET value '4Rating'. "#EC NOTEXT . + class-data C_ICONSET_4REDTOBLACK type ZEXCEL_CONDITION_RULE_ICONSET value '4RedToBlack'. "#EC NOTEXT . + class-data C_ICONSET_4TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value '4TrafficLights'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '5Arrows'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '5ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_5QUARTERS type ZEXCEL_CONDITION_RULE_ICONSET value '5Quarters'. "#EC NOTEXT . + class-data C_ICONSET_5RATING type ZEXCEL_CONDITION_RULE_ICONSET value '5Rating'. "#EC NOTEXT . + class-data C_OPERATOR_BEGINSWITH type ZEXCEL_CONDITION_OPERATOR value 'beginsWith'. "#EC NOTEXT . + class-data C_OPERATOR_BETWEEN type ZEXCEL_CONDITION_OPERATOR value 'between'. "#EC NOTEXT . + class-data C_OPERATOR_CONTAINSTEXT type ZEXCEL_CONDITION_OPERATOR value 'containsText'. "#EC NOTEXT . + class-data C_OPERATOR_ENDSWITH type ZEXCEL_CONDITION_OPERATOR value 'endsWith'. "#EC NOTEXT . + class-data C_OPERATOR_EQUAL type ZEXCEL_CONDITION_OPERATOR value 'equal'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHAN type ZEXCEL_CONDITION_OPERATOR value 'greaterThan'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'greaterThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHAN type ZEXCEL_CONDITION_OPERATOR value 'lessThan'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'lessThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_NONE type ZEXCEL_CONDITION_OPERATOR value ''. "#EC NOTEXT . + class-data C_OPERATOR_NOTCONTAINS type ZEXCEL_CONDITION_OPERATOR value 'notContains'. "#EC NOTEXT . + class-data C_OPERATOR_NOTEQUAL type ZEXCEL_CONDITION_OPERATOR value 'notEqual'. "#EC NOTEXT . + class-data C_RULE_CELLIS type ZEXCEL_CONDITION_RULE value 'cellIs'. "#EC NOTEXT . + class-data C_RULE_CONTAINSTEXT type ZEXCEL_CONDITION_RULE value 'containsText'. "#EC NOTEXT . + class-data C_RULE_EXPRESSION type ZEXCEL_CONDITION_RULE value 'expression'. "#EC NOTEXT . + class-data C_RULE_ICONSET type ZEXCEL_CONDITION_RULE value 'iconSet'. "#EC NOTEXT . + class-data C_RULE_NONE type ZEXCEL_CONDITION_RULE value 'none'. "#EC NOTEXT . + data FORMULA type ZEXCEL_STYLE_FORMULA . + data ICONSET type ZEXCEL_CONDITION_RULE_ICONSET . + data OPERATOR type ZEXCEL_CONDITION_OPERATOR . + data PRIORITY type ZEXCEL_STYLE_PRIORITY value 1. "#EC NOTEXT . + data RULE type ZEXCEL_CONDITION_RULE . + + methods CONSTRUCTOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods SET_RANGE + importing + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data START_CELL type ZEXCEL_S_CELL_DATA . + data STOP_CELL type ZEXCEL_S_CELL_DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + rule = me->c_rule_none. + operator = me->c_operator_none. +* inizialize dimension range + stop_cell-cell_row = 1. + stop_cell-cell_column = 1. + start_cell-cell_row = 1. + start_cell-cell_column = 1. +ENDMETHOD. + + + + METHOD get_dimension_range. + IF stop_cell EQ start_cell. "only one cell + ep_dimension_range = start_cell-cell_coords. + ELSE. + CONCATENATE start_cell-cell_coords ':' stop_cell-cell_coords INTO ep_dimension_range. + ENDIF. +ENDMETHOD. + + + + + + + METHOD set_range. + DATA: lv_column TYPE zexcel_cell_column, + lv_row_alpha TYPE string. + + lv_column = zcl_excel_common=>convert_column2int( ip_stop_column ). + stop_cell-cell_row = 1. + stop_cell-cell_column = lv_column. + lv_row_alpha = ip_stop_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_stop_column lv_row_alpha INTO stop_cell-cell_coords. + + lv_column = zcl_excel_common=>convert_column2int( ip_start_column ). + start_cell-cell_row = 1. + start_cell-cell_column = lv_column. + lv_row_alpha = ip_start_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_start_column lv_row_alpha INTO start_cell-cell_coords. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_FILL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +public section. + + class-data C_FILL_NONE type ZEXCEL_FILL_TYPE value 'none'. "#EC NOTEXT . + class-data C_FILL_SOLID type ZEXCEL_FILL_TYPE value 'solid'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_LINEAR type ZEXCEL_FILL_TYPE value 'linear'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_PATH type ZEXCEL_FILL_TYPE value 'path'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKDOWN type ZEXCEL_FILL_TYPE value 'darkDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRAY type ZEXCEL_FILL_TYPE value 'darkGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRID type ZEXCEL_FILL_TYPE value 'darkGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKHORIZONTAL type ZEXCEL_FILL_TYPE value 'darkHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKTRELLIS type ZEXCEL_FILL_TYPE value 'darkTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKUP type ZEXCEL_FILL_TYPE value 'darkUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKVERTICAL type ZEXCEL_FILL_TYPE value 'darkVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY0625 type ZEXCEL_FILL_TYPE value 'gray0625'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY125 type ZEXCEL_FILL_TYPE value 'gray125'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTDOWN type ZEXCEL_FILL_TYPE value 'lightDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRAY type ZEXCEL_FILL_TYPE value 'lightGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRID type ZEXCEL_FILL_TYPE value 'lightGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTHORIZONTAL type ZEXCEL_FILL_TYPE value 'lightHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTTRELLIS type ZEXCEL_FILL_TYPE value 'lightTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTUP type ZEXCEL_FILL_TYPE value 'lightUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTVERTICAL type ZEXCEL_FILL_TYPE value 'lightVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_MEDIUMGRAY type ZEXCEL_FILL_TYPE value 'mediumGray'. "#EC NOTEXT . + data FILLTYPE type ZEXCEL_FILL_TYPE . + data ROTATION type ZEXCEL_ROTATION . + data FGCOLOR type ZEXCEL_STYLE_COLOR_ARGB . + data BGCOLOR type ZEXCEL_STYLE_COLOR_ARGB value '64'. "#EC NOTEXT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_FILL . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + filltype = zcl_excel_style_fill=>c_fill_none. + rotation = 0. +ENDMETHOD. + + + + METHOD get_structure. + es_fill-rotation = me->rotation. + es_fill-filltype = me->filltype. + es_fill-fgColor = me->fgColor. + es_fill-bgColor = me->bgColor. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_FONT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data BOLD type FLAG . + data COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_SCHEME_MAJOR type ZEXCEL_STYLE_FONT_SCHEME value 'major'. "#EC NOTEXT . + class-data C_SCHEME_MINOR type ZEXCEL_STYLE_FONT_SCHEME value 'minor'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLE type CHAR20 value 'double'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLEACCOUNTING type CHAR20 value 'doubleAccounting'. "#EC NOTEXT . + class-data C_UNDERLINE_NONE type CHAR20 value 'none'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLE type CHAR20 value 'single'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLEACCOUNTING type CHAR20 value 'singleAccounting'. "#EC NOTEXT . + data FAMILY type INT1 value 2. "#EC NOTEXT . + data ITALIC type FLAG . + data NAME type CHAR255 value 'Calibri'. "#EC NOTEXT . + data SCHEME type ZEXCEL_STYLE_FONT_SCHEME . + data SIZE type INT1 value 11. "#EC NOTEXT . + data STRIKETHROUGH type FLAG . + data UNDERLINE type FLAG . + data UNDERLINE_MODE type CHAR20 . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FONT) type ZEXCEL_S_STYLE_FONT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->color = zcl_excel_style_color=>c_black. + me->scheme = zcl_excel_style_font=>c_scheme_minor. + me->underline_mode = zcl_excel_style_font=>c_underline_single. +ENDMETHOD. + + + + METHOD get_structure. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + es_font-bold = me->bold. + es_font-italic = me->italic. + es_font-underline = me->underline. + es_font-underline_mode = me->underline_mode. + es_font-strikethrough = me->strikethrough. + es_font-size = me->size. + es_font-color = me->color. + es_font-name = me->name. + es_font-family = me->family. + es_font-scheme = me->scheme. + +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_NUMBER_FORMAT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +public section. + + class-data C_FORMAT_NUMBER type ZEXCEL_NUMBER_FORMAT value '0'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_00 type ZEXCEL_NUMBER_FORMAT value '0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP1 type ZEXCEL_NUMBER_FORMAT value '#,##0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP2 type ZEXCEL_NUMBER_FORMAT value '#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE type ZEXCEL_NUMBER_FORMAT value '0%'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE_00 type ZEXCEL_NUMBER_FORMAT value '0.00%'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD2 type ZEXCEL_NUMBER_FORMAT value 'yyyy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD type ZEXCEL_NUMBER_FORMAT value 'yy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DDMMYYYY type ZEXCEL_NUMBER_FORMAT value 'dd/mm/yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYSLASH type ZEXCEL_NUMBER_FORMAT value 'd/m/y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m'. "#EC NOTEXT . + class-data C_FORMAT_DATE_MYMINUS type ZEXCEL_NUMBER_FORMAT value 'm-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX14 type ZEXCEL_NUMBER_FORMAT value 'mm-dd-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX15 type ZEXCEL_NUMBER_FORMAT value 'd-mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX16 type ZEXCEL_NUMBER_FORMAT value 'd-mmm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX17 type ZEXCEL_NUMBER_FORMAT value 'mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX22 type ZEXCEL_NUMBER_FORMAT value 'm/d/yy h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DATETIME type ZEXCEL_NUMBER_FORMAT value 'd/m/y h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME1 type ZEXCEL_NUMBER_FORMAT value 'h:mm AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME2 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME3 type ZEXCEL_NUMBER_FORMAT value 'h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME4 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME5 type ZEXCEL_NUMBER_FORMAT value 'mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME6 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME7 type ZEXCEL_NUMBER_FORMAT value 'i:s.S'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME8 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss@'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDDSLASH type ZEXCEL_NUMBER_FORMAT value 'yy/mm/dd@'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD_SIMPLE type ZEXCEL_NUMBER_FORMAT value '"$"#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD type ZEXCEL_NUMBER_FORMAT value '$#,##0_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_EUR_SIMPLE type ZEXCEL_NUMBER_FORMAT value '[$EUR ]#,##0.00_-'. "#EC NOTEXT . + data FORMAT_CODE type ZEXCEL_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(EP_NUMBER_FORMAT) type ZEXCEL_NUMBER_FORMAT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +private section. + + class-data C_FORMAT_GENERAL type ZEXCEL_NUMBER_FORMAT value ''. "#EC NOTEXT . + class-data C_FORMAT_TEXT type ZEXCEL_NUMBER_FORMAT value '@'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + format_code = me->c_format_general. +ENDMETHOD. + + + + METHOD get_structure. + ep_number_format = me->format_code. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE_PROTECTION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +public section. + + constants C_PROTECTION_INHERIT type ZEXCEL_PROTECTION value 'inherit'. "#EC NOTEXT + constants C_PROTECTION_PROTECTED type ZEXCEL_PROTECTION value 'protected'. "#EC NOTEXT + constants C_PROTECTION_UNPROTECTED type ZEXCEL_PROTECTION value 'unprotected'. "#EC NOTEXT + data LOCKED type ZEXCEL_PROTECTION . + data HIDDEN type ZEXCEL_PROTECTION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + METHOD constructor. + locked = me->c_protection_inherit. + hidden = me->c_protection_inherit. +ENDMETHOD. + + + + class ZCL_EXCEL_WORKSHEET definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + class-data C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT . + class-data C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT . + class-data C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT . + class-data C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT . + data DEFAULTROWHEIGHT type INT1 value 15. "#EC NOTEXT . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHEET_STATE type ZEXCEL_SHEET_STATE . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING . + methods GET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + methods SET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type ZEXCEL_CELL_VALUE + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional . + methods SET_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING optional + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . + methods ADD_NEW_CONDITIONAL_STYLE + returning + value(EO_CONDITIONAL_STYLE) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_COND_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CONDITIONAL_STYLES type ref to ZCL_EXCEL_STYLES_CONDITIONAL . + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + + methods UPDATE_DIMENSION_RANGE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + METHOD add_new_conditional_style. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT eo_conditional_style. + conditional_styles->add( eo_conditional_style ). +ENDMETHOD. + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + sheet_state = me->c_sheet_state_visible. + + CREATE OBJECT sheet_setup. + CREATE OBJECT conditional_styles. + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +ENDMETHOD. + + + + METHOD get_active_cell. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_active_column TYPE zexcel_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = zcl_excel_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + +ENDMETHOD. + + + + + + + METHOD get_cell. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = ip_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. +ENDMETHOD. + + + + method GET_COND_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->conditional_styles->get_iterator( ). +endmethod. + + + + METHOD get_dimension_range. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + ep_dimension_range = upper_cell-cell_coords. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + +ENDMETHOD. + + + + method GET_GUID. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. + +endmethod. + + + + + + + + METHOD set_cell. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = ZCL_EXCEL_COMMON=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_value = ip_value. + <fs_sheet_content>-cell_formula = ip_formula. + <fs_sheet_content>-cell_style = ip_style. + ELSE. + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column. + ls_sheet_content-cell_value = ip_value. + ls_sheet_content-cell_formula = ip_formula. + ls_sheet_content-cell_style = ip_style. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content. + SORT sheet_content BY cell_row cell_column. +* me->update_dimension_range( ). + + ENDIF. + +ENDMETHOD. + + + + + + + + + METHOD set_table. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, + lr_data TYPE REF TO data, + ls_newline TYPE REF TO data, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + lv_row_header TYPE zexcel_cell_row VALUE '2', + lv_col_header TYPE zexcel_cell_column_alpha VALUE 'B', + lv_row_int TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lv_cell_value TYPE zexcel_cell_value. + + + FIELD-SYMBOLS: <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY, + <fs_dfies> TYPE dfies, + <fs_cell_value> TYPE zexcel_cell_value. + + lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). + lv_row_int = ip_top_left_row. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + +* It is better to loop column by column + LOOP AT lt_dfies ASSIGNING <fs_dfies>. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + " First of all write column header + lv_cell_value = <fs_dfies>-scrtext_m. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_hdr_style ). + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <fs_dfies>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + MOVE <fs_fldval> TO lv_cell_value. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_body_style ). + ADD 1 TO lv_row_int. + ENDLOOP. + lv_row_int = ip_top_left_row. + ADD 1 TO lv_column_int. + ENDLOOP. + +ENDMETHOD. + + + METHOD update_dimension_range. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: ls_sheet_content TYPE zexcel_s_cell_data, + lt_sheet_content TYPE zexcel_t_cell_data_unsorted, + lv_row_alpha TYPE string, + lv_column_alpha TYPE zexcel_cell_column_alpha. + +* update dimension range + lt_sheet_content = sheet_content. + "upper left corner + SORT lt_sheet_content BY cell_row. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = upper_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( upper_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO upper_cell-cell_coords. + + "bottom right corner + SORT lt_sheet_content BY cell_row DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = lower_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lower_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. + +ENDMETHOD. + + + + class ZCL_EXCEL_WORKSHEETS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +public section. + + data ACTIVE_WORKSHEET type ZEXCEL_ACTIVE_WORKSHEET value 1. "#EC NOTEXT . + data NAME type ZEXCEL_WORKSHEETS_NAME value 'Worksheets'. "#EC NOTEXT . + + methods ADD + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +private section. + + data WORKSHEETS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + METHOD ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->add( ip_worksheet ). +ENDMETHOD. + + + METHOD clear. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->clear( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT worksheets. + +ENDMETHOD. + + + + + METHOD get. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_worksheet ?= worksheets->if_object_collection~get( lv_index ). +ENDMETHOD. + + + + METHOD get_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= worksheets->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = worksheets->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->remove( ip_worksheet ). +ENDMETHOD. + + + + METHOD size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = worksheets->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + methods CONSTRUCTOR + importing + !IO_EXCEL type ref to ZCL_EXCEL . + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_CALCCHAIN type STRING value 'xl/calcChain.xml'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_CALCCHAIN + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->excel = io_excel. +ENDMETHOD. + + + + METHOD create. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sharedStrings.xml to zip + lv_content = me->create_xl_calcchain( ). + lo_zip->add( name = me->c_xl_calcchain + content = lv_content ). + +********************************************************************** +* STEP 11: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +ENDMETHOD. + + + + METHOD create_content_types. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lv_xml_node_worksheet_pn ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_docprops_app. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_docprops_core. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD CREATE_RELATIONSHIPS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_calcchain. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_calcchain TYPE string VALUE 'calcChain', + lc_xml_node_c TYPE string VALUE 'c', + " Node attributes + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_i TYPE string VALUE 'i', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string, + lv_value_i TYPE string, + lv_sheets_count TYPE i. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create xl/calcChain.xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node calcChain + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_calcchain + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + ADD 1 TO lv_sheets_count. + MOVE lv_sheets_count TO lv_value_i. + SHIFT lv_value_i RIGHT DELETING TRAILING space. + SHIFT lv_value_i LEFT DELETING LEADING space. + LOOP AT lo_worksheet->sheet_content ASSIGNING <ls_sheet_content> WHERE cell_formula IS NOT INITIAL. + " formula chain node + lo_element = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_i + value = lv_value_i ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_relationships. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + lc_xml_node_rid_calcchain_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml', + lc_xml_node_rid_calcchain_tg TYPE string VALUE 'calcChain.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 1 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_calcchain_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_calcchain_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_sharedstrings. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + + METHOD create_xl_sheet. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional. + + DATA: lv_value TYPE string, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + lv_value = io_worksheet->defaultrowheight. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + lo_element_root->append_child( lo_element ). " sheetFormatPr node + + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = '1:1' ). " <******************************* + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + IF ls_style_mapping-cell_format IS INITIAL. " to avoid errors if no style has been created + IF <ls_sheet_content>-cell_formula IS INITIAL. + ls_style_mapping-cell_format = 'S'. + ELSE. + ls_style_mapping-cell_format = 'F'. + ENDIF. + ENDIF. + " is a shared string and is not a formula + IF ls_style_mapping-cell_format EQ 'S'. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = 's' ). + ENDIF. + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ENDIF. + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF ls_style_mapping-cell_format EQ 'S'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_sheet_rels. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + lc_xml_node_rid_print_id TYPE string VALUE 'rId1', + " Node type + lc_xml_node_rid_print_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', + " Node target + lc_xml_node_rid_print_tg TYPE string VALUE '../printerSettings/printerSettings1.bin'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rid_print_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_print_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_print_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_styles. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + ls_format TYPE zexcel_number_format, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_format = lo_style->number_format->get_structure( ). + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + + IF ls_format IS INITIAL. + ls_cellxfs-numfmtid = 0. " number format + ELSE. + ls_cellxfs-numfmtid = ls_format. " number format + ENDIF. + ls_cellxfs-xfid = 0. + + IF ls_format IS NOT INITIAL. + ls_cellxfs-applynumberformat = 1. + ls_styles_mapping-cell_format = 'I'. + ELSE. + ls_cellxfs-applynumberformat = 0. + ls_styles_mapping-cell_format = 'S'. + ENDIF. + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + " Collect color + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = 'TableStyleMedium9' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = 'PivotStyleLight16' ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + METHOD create_xl_theme. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +ENDMETHOD. + + + + METHOD create_xl_workbook. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + METHOD flag2bool. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +ENDMETHOD. + + + + + METHOD get_shared_string_index. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +ENDMETHOD. + + + + class ZCL_EXCEL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! +public section. + + constants C_XLS type ZEXCEL_FORMAT value 'XLS'. "#EC NOTEXT + constants C_XLSX type ZEXCEL_FORMAT value 'XLSX'. "#EC NOTEXT + data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . + data SECURITY type ref to ZCL_EXCEL_SECURITY . + + methods ADD_NEW_DRAWING + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_STYLE + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods ADD_NEW_WORKSHEET + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods CONSTRUCTOR . + methods GET_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_DRAWINGS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_NAME + returning + value(EP_NAME) type ZEXCEL_WORKSHEETS_NAME . + methods GET_WORKSHEETS_SIZE + returning + value(EP_SIZE) type I . + methods SAVE_AS + importing + !IP_FORMAT type ZEXCEL_FORMAT + returning + value(EP_FILE) type XSTRING . + *"* protected components of class ZABAP_EXCEL +*"* do not include other source files here!!! +protected 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 . + data STYLES type ref to ZCL_EXCEL_STYLES . + data WORKSHEETS type ref to ZCL_EXCEL_WORKSHEETS . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + METHOD add_new_drawing. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_title = ip_title. + drawings->add( eo_drawing ). +ENDMETHOD. + + + + method ADD_NEW_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Create default style + CREATE OBJECT eo_style. + styles->add( eo_style ). + +endmethod. + + + + + METHOD add_new_worksheet. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_title = ip_title. + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style TYPE REF TO zcl_excel_style. + +* Inizialize instance objects + CREATE OBJECT properties. + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings. + + 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. + + + + method GET_ACTIVE_WORKSHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + +endmethod. + + + + METHOD GET_DRAWINGS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->drawings->get_iterator( ). +ENDMETHOD. + + + + METHOD GET_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->styles->get_iterator( ). +ENDMETHOD. + + + + METHOD get_worksheets_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->worksheets->get_iterator( ). +ENDMETHOD. + + + + METHOD GET_WORKSHEETS_NAME. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_name = me->worksheets->name. + +ENDMETHOD. + + + + METHOD get_worksheets_size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = me->worksheets->size( ). + +ENDMETHOD. + + + + + METHOD save_as. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lo_excel_writer_2007 TYPE REF TO zcl_excel_writer_2007. + +* Determine the output engine to use + CASE ip_format. + WHEN me->c_xlsx. " XLSX for Office 2007 + CREATE OBJECT lo_excel_writer_2007 EXPORTING io_excel = me. + ep_file = lo_excel_writer_2007->create( ). + WHEN OTHERS. + ENDCASE. + +ENDMETHOD. + + + + class ZCL_EXCEL_COMMON definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +public section. + + class-methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + class-methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +private section. + + class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + METHOD convert_column2alpha. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +ENDMETHOD. + + + + + METHOD convert_column2int. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( zcl_excel_common=>c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( zcl_excel_common=>c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - zcl_excel_common=>c_excel_col_module. + ENDIF. + +ENDMETHOD. + + + + class ZCL_EXCEL_DRAWING definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + data X_REFERENCES type CHAR1 . + data Y_REFERENCES type CHAR1 . + data GRAPH_TYPE type ZEXCEL_GRAPH_TYPE . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +private section. + + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + constants C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT + + methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + METHOD CONSTRUCTOR. + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +ENDMETHOD. + + + + + METHOD CONVERT_COLUMN2ALPHA. + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +ENDMETHOD. + + + + + METHOD CONVERT_COLUMN2INT. + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( me->c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( me->c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - me->c_excel_col_module. + ENDIF. + +ENDMETHOD. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + class ZCL_EXCEL_DRAWINGS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +private section. + + data DRAWINGS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD add. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->add( ip_drawing ). +ENDMETHOD. + + + METHOD clear. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->clear( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT drawings. + +ENDMETHOD. + + + + + METHOD get. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_drawing ?= drawings->if_object_collection~get( lv_index ). +ENDMETHOD. + + + + METHOD get_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= drawings->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = drawings->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->remove( ip_drawing ). +ENDMETHOD. + + + + METHOD size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = drawings->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_PROPERTIES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +public section. + + data CREATOR type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data LASTMODIFIEDBY type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data CREATED type TIMESTAMPL . + data MODIFIED type TIMESTAMPL . + data TITLE type ZEXCEL_TITLE value 'Untitled Spreadsheet'. "#EC NOTEXT . + data SUBJECT type ZEXCEL_SUBJECT . + data DESCRIPTION type ZEXCEL_DESCRIPTION . + data KEYWORDS type ZEXCEL_KEYWORDS . + data CATEGORY type ZEXCEL_CATEGORY . + data COMPANY type ZEXCEL_COMPANY value 'Microsoft Corporation'. "#EC NOTEXT . + data APPLICATION type ZEXCEL_APPLICATION value 'Microsoft Excel'. "#EC NOTEXT . + data DOCSECURITY type ZEXCEL_DOCSECURITY value '0'. "#EC NOTEXT . + data SCALECROP type ZEXCEL_SCALECROP value ''. "#EC NOTEXT . + data LINKSUPTODATE type FLAG . + data SHAREDDOC type FLAG . + data HYPERLINKSCHANGED type FLAG . + data APPVERSION type ZEXCEL_APPVERSION value '12.0000'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_PROPERTIES +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + METHOD CONSTRUCTOR. + + DATA: lv_timestamp TYPE timestampl. + + GET TIME STAMP FIELD lv_timestamp. + created = lv_timestamp. + modified = lv_timestamp. + +ENDMETHOD. + + + + class ZCL_EXCEL_RANGE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +public section. + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + method CONSTRUCTOR. +endmethod. + + + + class ZCL_EXCEL_RANGES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! +private section. + + data RANGES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD ADD. + ranges->add( ip_range ). +ENDMETHOD. + + + METHOD CLEAR. + ranges->clear( ). +ENDMETHOD. + + + method CONSTRUCTOR. +endmethod. + + + + + METHOD GET. + eo_range ?= ranges->if_object_collection~get( ip_index ). +ENDMETHOD. + + + + METHOD GET_ITERATOR. + eo_iterator ?= ranges->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD IS_EMPTY. + is_empty = ranges->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD REMOVE. + ranges->remove( ip_range ). +ENDMETHOD. + + + + METHOD SIZE. + ep_size = ranges->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_SECURITY definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SECURITY +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data LOCKREVISION type FLAG . + data LOCKSTRUCTURE type FLAG . + data LOCKWINDOWS type FLAG . + data REVISIONSPASSWORD type ZEXCEL_REVISIONSPASSWORD . + data WORKBOOKPASSWORD type ZEXCEL_WORKBOOKPASSWORD . + + methods CONSTRUCTOR . + methods IS_SECURITY_ENABLED + returning + value(EP_SECURITY_ENABLED) type FLAG . + *"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + method CONSTRUCTOR. +endmethod. + + + + METHOD IS_SECURITY_ENABLED. + IF lockrevision EQ abap_true OR lockstructure EQ abap_true OR lockwindows EQ abap_true. + ep_security_enabled = abap_true. + ENDIF. +ENDMETHOD. + + + + class ZCL_EXCEL_SHEET_SETUP definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants C_PAPERSIZE_LETTER type ZEXCEL_SHEET_PAPER_SIZE value 1. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 2. "#EC NOTEXT + constants C_PAPERSIZE_TABLOID type ZEXCEL_SHEET_PAPER_SIZE value 3. "#EC NOTEXT + constants C_PAPERSIZE_LEDGER type ZEXCEL_SHEET_PAPER_SIZE value 4. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL type ZEXCEL_SHEET_PAPER_SIZE value 5. "#EC NOTEXT + constants C_PAPERSIZE_STATEMENT type ZEXCEL_SHEET_PAPER_SIZE value 6. "#EC NOTEXT + constants C_PAPERSIZE_EXECUTIVE type ZEXCEL_SHEET_PAPER_SIZE value 7. "#EC NOTEXT + constants C_PAPERSIZE_A3 type ZEXCEL_SHEET_PAPER_SIZE value 8. "#EC NOTEXT + constants C_PAPERSIZE_A4 type ZEXCEL_SHEET_PAPER_SIZE value 9. "#EC NOTEXT + constants C_PAPERSIZE_A4_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 10. "#EC NOTEXT + constants C_PAPERSIZE_A5 type ZEXCEL_SHEET_PAPER_SIZE value 11. "#EC NOTEXT + constants C_PAPERSIZE_B4 type ZEXCEL_SHEET_PAPER_SIZE value 12. "#EC NOTEXT + constants C_PAPERSIZE_B5 type ZEXCEL_SHEET_PAPER_SIZE value 13. "#EC NOTEXT + constants C_PAPERSIZE_FOLIO type ZEXCEL_SHEET_PAPER_SIZE value 14. "#EC NOTEXT + constants C_PAPERSIZE_QUARTO type ZEXCEL_SHEET_PAPER_SIZE value 15. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_1 type ZEXCEL_SHEET_PAPER_SIZE value 16. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_2 type ZEXCEL_SHEET_PAPER_SIZE value 17. "#EC NOTEXT + constants C_PAPERSIZE_NOTE type ZEXCEL_SHEET_PAPER_SIZE value 18. "#EC NOTEXT + constants C_PAPERSIZE_NO9_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 19. "#EC NOTEXT + constants C_PAPERSIZE_NO10_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 20. "#EC NOTEXT + constants C_PAPERSIZE_NO11_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 21. "#EC NOTEXT + constants C_PAPERSIZE_NO12_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 22. "#EC NOTEXT + constants C_PAPERSIZE_NO14_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 23. "#EC NOTEXT + constants C_PAPERSIZE_C type ZEXCEL_SHEET_PAPER_SIZE value 24. "#EC NOTEXT + constants C_PAPERSIZE_D type ZEXCEL_SHEET_PAPER_SIZE value 25. "#EC NOTEXT + constants C_PAPERSIZE_E type ZEXCEL_SHEET_PAPER_SIZE value 26. "#EC NOTEXT + constants C_PAPERSIZE_DL_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 27. "#EC NOTEXT + constants C_PAPERSIZE_C5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 28. "#EC NOTEXT + constants C_PAPERSIZE_C3_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 29. "#EC NOTEXT + constants C_PAPERSIZE_C4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 30. "#EC NOTEXT + constants C_PAPERSIZE_C6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 31. "#EC NOTEXT + constants C_PAPERSIZE_C65_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 32. "#EC NOTEXT + constants C_PAPERSIZE_B4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 33. "#EC NOTEXT + constants C_PAPERSIZE_B5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 34. "#EC NOTEXT + constants C_PAPERSIZE_B6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 35. "#EC NOTEXT + constants C_PAPERSIZE_ITALY_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 36. "#EC NOTEXT + constants C_PAPERSIZE_MONARCH_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 37. "#EC NOTEXT + constants C_PAPERSIZE_6_3_4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 38. "#EC NOTEXT + constants C_PAPERSIZE_US_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 39. "#EC NOTEXT + constants C_PAPERSIZE_DE_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 40. "#EC NOTEXT + constants C_PAPERSIZE_DE_LEG_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 41. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B4 type ZEXCEL_SHEET_PAPER_SIZE value 42. "#EC NOTEXT + constants C_PAPERSIZE_JPN_DBL_POSTCARD type ZEXCEL_SHEET_PAPER_SIZE value 43. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_1 type ZEXCEL_SHEET_PAPER_SIZE value 44. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_2 type ZEXCEL_SHEET_PAPER_SIZE value 45. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_3 type ZEXCEL_SHEET_PAPER_SIZE value 46. "#EC NOTEXT + constants C_PAPERSIZE_INVITE_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 47. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 48. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 49. "#EC NOTEXT + constants C_PAPERSIZE_TABL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 50. "#EC NOTEXT + constants C_PAPERSIZE_A4_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 51. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 52. "#EC NOTEXT + constants C_PAPERSIZE_A4_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 53. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 54. "#EC NOTEXT + constants C_PAPERSIZE_SUPERA_A4_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 55. "#EC NOTEXT + constants C_PAPERSIZE_SUPERB_A3_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 56. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 57. "#EC NOTEXT + constants C_PAPERSIZE_A4_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 58. "#EC NOTEXT + constants C_PAPERSIZE_A5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 59. "#EC NOTEXT + constants C_PAPERSIZE_JIS_B5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 60. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 61. "#EC NOTEXT + constants C_PAPERSIZE_A5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 62. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 63. "#EC NOTEXT + constants C_PAPERSIZE_A2_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 64. "#EC NOTEXT + constants C_PAPERSIZE_A3_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 65. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 66. "#EC NOTEXT + constants C_ORIENTATION_DEFAULT type ZEXCEL_SHEET_ORIENATATION value 'default'. "#EC NOTEXT + constants C_ORIENTATION_LANDSCAPE type ZEXCEL_SHEET_ORIENATATION value 'landscape'. "#EC NOTEXT + constants C_ORIENTATION_PORTRAIT type ZEXCEL_SHEET_ORIENATATION value 'portrait'. "#EC NOTEXT + data ORIENTATION type ZEXCEL_SHEET_ORIENATATION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + orientation = me->c_orientation_default. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +public section. + + data FONT type ref to ZCL_EXCEL_STYLE_FONT . + data FILL type ref to ZCL_EXCEL_STYLE_FILL . + data BORDERS type ref to ZCL_EXCEL_STYLE_BORDERS . + data NUMBER_FORMAT type ref to ZCL_EXCEL_STYLE_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_CELL_STYLE . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +private section. + + data ALIGNMENT type ref to ZCL_EXCEL_STYLE_ALIGNMENT . + data PROTECTION type ref to ZCL_EXCEL_STYLE_PROTECTION . + data GUID type ZEXCEL_CELL_STYLE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT font. + CREATE OBJECT fill. + CREATE OBJECT borders. + CREATE OBJECT alignment. + CREATE OBJECT number_format. + CREATE OBJECT protection. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + +ENDMETHOD. + + + + METHOD get_guid. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods SIZE + returning + value(EP_SIZE) type I . + methods REGISTER_NEW_STYLE + importing + !IO_STYLE type ref to ZCL_EXCEL_STYLE + returning + value(EP_STYLE_CODE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +private section. + + data STYLES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD add. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->add( ip_style ). +ENDMETHOD. + + + METHOD clear. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->clear( ). +ENDMETHOD. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT styles. +ENDMETHOD. + + + + + METHOD get. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_style ?= styles->if_object_collection~get( ip_index ). +ENDMETHOD. + + + + METHOD get_iterator. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= styles->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = styles->if_object_collection~is_empty( ). +ENDMETHOD. + + + + + METHOD register_new_style. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->add( io_style ). + ep_style_code = me->size( ) - 1. "style count starts from 0 +ENDMETHOD. + + + + METHOD remove. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->remove( ip_style ). +ENDMETHOD. + + + + METHOD size. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = styles->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_STYLES_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_STYLE_CONDITIONAL) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data STYLES_CONDITIONAL type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + METHOD add. + styles_conditional->add( ip_style_conditional ). +ENDMETHOD. + + + METHOD clear. + styles_conditional->clear( ). +ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT styles_conditional. + +ENDMETHOD. + + + + + METHOD get. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_style_conditional ?= styles_conditional->if_object_collection~get( lv_index ). +ENDMETHOD. + + + + METHOD get_iterator. + eo_iterator ?= styles_conditional->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. + is_empty = styles_conditional->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. + styles_conditional->remove( ip_style_conditional ). +ENDMETHOD. + + + + METHOD size. + ep_size = styles_conditional->if_object_collection~size( ). +ENDMETHOD. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel1. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HelloWorld.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel2. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_bold TYPE REF TO zcl_excel_style, + lo_style_underline TYPE REF TO zcl_excel_style, + lo_style_filled TYPE REF TO zcl_excel_style, + lo_style_border TYPE REF TO zcl_excel_style, + lo_style_button TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_bold_guid TYPE zexcel_cell_style, + lv_style_underline_guid TYPE zexcel_cell_style, + lv_style_filled_guid TYPE zexcel_cell_style, + lv_style_border_guid TYPE zexcel_cell_style, + lv_style_button_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +CREATE OBJECT lo_border_light. +lo_border_light->border_color = zcl_excel_style_color=>c_gray. +lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. +" Create a bold / italic style +lo_style_bold = lo_excel->add_new_style( ). +lo_style_bold->font->bold = abap_true. +lo_style_bold->font->italic = abap_true. +lo_style_bold->font->color = zcl_excel_style_color=>c_red. +lv_style_bold_guid = lo_style_bold->get_guid( ). +" Create an underline double style +lo_style_underline = lo_excel->add_new_style( ). +lo_style_underline->font->underline = abap_true. +lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double. +lv_style_underline_guid = lo_style_underline->get_guid( ). +" Create filled style +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lv_style_filled_guid = lo_style_filled->get_guid( ). +" Create border with button effects +lo_style_button = lo_excel->add_new_style( ). +lo_style_button->borders->right = lo_border_dark. +lo_style_button->borders->down = lo_border_dark. +lo_style_button->borders->left = lo_border_light. +lo_style_button->borders->top = lo_border_light. +lv_style_button_guid = lo_style_button->get_guid( ). +"Create style with border +lo_style_border = lo_excel->add_new_style( ). +lo_style_border->borders->allborders = lo_border_dark. +lv_style_border_guid = lo_style_border->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Styles'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Styles.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel3. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_header TYPE REF TO zcl_excel_style, + lo_style_body TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_header_guid TYPE zexcel_cell_style, + lv_style_body_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +" Create filled style +lo_style_header = lo_excel->add_new_style( ). +lo_style_header->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_header->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lo_style_header->borders->allborders = lo_border_dark. +lv_style_header_guid = lo_style_header->get_guid( ). +"Create style with border +lo_style_body = lo_excel->add_new_style( ). +lo_style_body->borders->allborders = lo_border_dark. +lv_style_body_guid = lo_style_body->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. +lo_worksheet->set_table( ip_table = lt_test + ip_hdr_style = lv_style_header_guid + ip_body_style = lv_style_body_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTab.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel4. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ). + +lo_worksheet = lo_excel->add_new_worksheet( ). +lo_worksheet->title = 'Sheet2'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ). + + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Sheets.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel5. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '100' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '1000' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '150' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '500' ip_style = lv_style_number_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\CondFormatting.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel6. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '100' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '1000' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '150' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '500' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = '1760' ip_formula = 'SUM(C4:C8)' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Formula.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel7. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 5 + ip_stop_column = 'B' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 5 + ip_stop_column = 'C' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3flags. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 5 + ip_stop_column = 'D' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'C_ICONSET_3FLAGS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 5 + ip_stop_column = 'E' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'C_ICONSET_3TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 5 + ip_stop_column = 'F' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'C_ICONSET_3TRAFFICLIGHTS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'F' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'F' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'F' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'F' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'G' + ip_start_row = 5 + ip_stop_column = 'G' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = 'C_ICONSET_3SIGNS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'G' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'G' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'G' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'G' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'G' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'H' + ip_start_row = 5 + ip_stop_column = 'H' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'H' ip_value = 'C_ICONSET_3SYMBOLS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'H' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'H' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'H' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'H' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'H' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'I' + ip_start_row = 5 + ip_stop_column = 'I' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'I' ip_value = 'C_ICONSET_3SYMBOLS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'I' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'I' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'I' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'I' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'I' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 12 + ip_stop_column = 'B' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = 'C_ICONSET_4ARROWS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 12 + ip_stop_column = 'C' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'C' ip_value = 'C_ICONSET_4ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 12 + ip_stop_column = 'D' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'D' ip_value = 'C_ICONSET_4REDTOBLACK' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 12 + ip_stop_column = 'E' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'E' ip_value = 'C_ICONSET_4RATING' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 12 + ip_stop_column = 'F' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'F' ip_value = 'C_ICONSET_4TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'F' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'F' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'F' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'F' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 19 + ip_stop_column = 'B' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'B' ip_value = 'C_ICONSET_5ARROWS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 19 + ip_stop_column = 'C' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'C' ip_value = 'C_ICONSET_5ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 19 + ip_stop_column = 'D' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'D' ip_value = 'C_ICONSET_5RATING' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5quarters. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 19 + ip_stop_column = 'E' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Iconset.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/NUGG_ABAP2XLSX_V_1_1.nugg b/build/NUGG_ABAP2XLSX_V_1_1.nugg new file mode 100644 index 0000000..ab41aae --- /dev/null +++ b/build/NUGG_ABAP2XLSX_V_1_1.nugg @@ -0,0 +1,8789 @@ + + + + class ZCL_EXCEL_STYLES_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_STYLE_CONDITIONAL) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data STYLES_CONDITIONAL type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + styles_conditional->add( ip_style_conditional ). +endmethod. + + + method CLEAR. + styles_conditional->clear( ). +endmethod. + + + method CONSTRUCTOR. + + CREATE OBJECT styles_conditional. + +endmethod. + + + + + method GET. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_style_conditional ?= styles_conditional->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= styles_conditional->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = styles_conditional->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + styles_conditional->remove( ip_style_conditional ). +endmethod. + + + + method SIZE. + ep_size = styles_conditional->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_STYLE_ALIGNMENT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data HORIZONTAL type ZEXCEL_ALIGNMENT . + data VERTICAL type ZEXCEL_ALIGNMENT . + data TEXTROTATION type ZEXCEL_TEXT_ROTATION value 0. "#EC NOTEXT . + data WRAPTEXT type FLAG . + data SHRINKTOFIT type FLAG . + data INDENT type ZEXCEL_INDENT value 0. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +private section. + + constants C_HORIZONTAL_GENERAL type ZEXCEL_ALIGNMENT value 'general'. "#EC NOTEXT + constants C_HORIZONTAL_LEFT type ZEXCEL_ALIGNMENT value 'left'. "#EC NOTEXT + constants C_HORIZONTAL_RIGHT type ZEXCEL_ALIGNMENT value 'right'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER_CONTINUOUS type ZEXCEL_ALIGNMENT value 'centerContinuous'. "#EC NOTEXT + constants C_HORIZONTAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + constants C_VERTICAL_BOTTOM type ZEXCEL_ALIGNMENT value 'bottom'. "#EC NOTEXT + constants C_VERTICAL_TOP type ZEXCEL_ALIGNMENT value 'top'. "#EC NOTEXT + constants C_VERTICAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_VERTICAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + horizontal = me->c_horizontal_general. + vertical = me->c_vertical_bottom. + wrapText = abap_false. + shrinkToFit = abap_false. +endmethod. + + + + class ZCL_EXCEL_STYLE_BORDER definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +public section. + + data BORDER_STYLE type ZEXCEL_BORDER . + data BORDER_COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_BORDER_NONE type ZEXCEL_BORDER value 'none'. "#EC NOTEXT . + class-data C_BORDER_DASHDOT type ZEXCEL_BORDER value 'dashDot'. "#EC NOTEXT . + class-data C_BORDER_DASHDOTDOT type ZEXCEL_BORDER value 'dashDotDot'. "#EC NOTEXT . + class-data C_BORDER_DASHED type ZEXCEL_BORDER value 'dashed'. "#EC NOTEXT . + class-data C_BORDER_DOTTED type ZEXCEL_BORDER value 'dotted'. "#EC NOTEXT . + class-data C_BORDER_DOUBLE type ZEXCEL_BORDER value 'double'. "#EC NOTEXT . + class-data C_BORDER_HAIR type ZEXCEL_BORDER value 'hair'. "#EC NOTEXT . + class-data C_BORDER_MEDIUM type ZEXCEL_BORDER value 'medium'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOT type ZEXCEL_BORDER value 'mediumDashDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOTDOT type ZEXCEL_BORDER value 'mediumDashDotDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHED type ZEXCEL_BORDER value 'mediumDashed'. "#EC NOTEXT . + class-data C_BORDER_SLANTDASHDOT type ZEXCEL_BORDER value 'slantDashDot'. "#EC NOTEXT . + class-data C_BORDER_THICK type ZEXCEL_BORDER value 'thick'. "#EC NOTEXT . + class-data C_BORDER_THIN type ZEXCEL_BORDER value 'thin'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + border_style = zcl_excel_style_border=>c_border_none. +endmethod. + + + + class ZCL_EXCEL_STYLE_BORDERS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +public section. + + data LEFT type ref to ZCL_EXCEL_STYLE_BORDER . + data RIGHT type ref to ZCL_EXCEL_STYLE_BORDER . + data TOP type ref to ZCL_EXCEL_STYLE_BORDER . + data DOWN type ref to ZCL_EXCEL_STYLE_BORDER . + data DIAGONAL type ref to ZCL_EXCEL_STYLE_BORDER . + data ALLBORDERS type ref to ZCL_EXCEL_STYLE_BORDER . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_BORDER . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +private section. + + constants C_DIAGONAL_NONE type ZEXCEL_DIAGONAL value 0. "#EC NOTEXT + constants C_DIAGONAL_UP type ZEXCEL_DIAGONAL value 1. "#EC NOTEXT + constants C_DIAGONAL_DOWN type ZEXCEL_DIAGONAL value 2. "#EC NOTEXT + constants C_DIAGONAL_BOTH type ZEXCEL_DIAGONAL value 3. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method CONSTRUCTOR. +endmethod. + + + + method GET_STRUCTURE. + +* Check if all borders is set otherwise check single border + IF me->allborders IS BOUND. + es_fill-left_color = me->allborders->border_color. + es_fill-left_style = me->allborders->border_style. + es_fill-right_color = me->allborders->border_color. + es_fill-right_style = me->allborders->border_style. + es_fill-top_color = me->allborders->border_color. + es_fill-top_style = me->allborders->border_style. + es_fill-bottom_color = me->allborders->border_color. + es_fill-bottom_style = me->allborders->border_style. + ELSE. + IF me->left IS BOUND. + es_fill-left_color = me->left->border_color. + es_fill-left_style = me->left->border_style. + ENDIF. + IF me->right IS BOUND. + es_fill-right_color = me->right->border_color. + es_fill-right_style = me->right->border_style. + ENDIF. + IF me->top IS BOUND. + es_fill-top_color = me->top->border_color. + es_fill-top_style = me->top->border_style. + ENDIF. + IF me->down IS BOUND. + es_fill-bottom_color = me->down->border_color. + es_fill-bottom_style = me->down->border_style. + ENDIF. + ENDIF. + +* Check if diagonal is set + IF me->diagonal IS BOUND. + es_fill-diagonal_color = me->diagonal->border_color. + es_fill-diagonal_style = me->diagonal->border_style. + ENDIF. + +endmethod. + + + + class ZCL_EXCEL_STYLE_COLOR definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +public section. + + class-data C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT . + class-data C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT . + class-data C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT . + class-data C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT . + class-data C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT . + class-data C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT . + class-data C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT . + class-data C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT . + class-data C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT . + class-data C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT . + class-data C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT . + + methods CONSTRUCTOR . + class-methods CREATE_NEW_ARGB + importing + !IP_RED type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_GREEN type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_BLU type ZEXCEL_STYLE_COLOR_COMPONENT + returning + value(EP_COLOR_ARGB) type ZEXCEL_STYLE_COLOR_ARGB . + *"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +private section. + + class-data C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +endmethod. + + + + + + + method CREATE_NEW_ARGB. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CONCATENATE zcl_excel_style_color=>c_alpha ip_red ip_green ip_blu INTO ep_color_argb. + +endmethod. + + + + class ZCL_EXCEL_STYLE_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +public section. + + class-data C_ICONSET_3ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '3Arrows'. "#EC NOTEXT . + class-data C_ICONSET_3ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '3ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_3FLAGS type ZEXCEL_CONDITION_RULE_ICONSET value '3Flags'. "#EC NOTEXT . + class-data C_ICONSET_3SIGNS type ZEXCEL_CONDITION_RULE_ICONSET value '3Signs'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols2'. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value ''. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3TrafficLights2'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '4Arrows'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '4ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_4RATING type ZEXCEL_CONDITION_RULE_ICONSET value '4Rating'. "#EC NOTEXT . + class-data C_ICONSET_4REDTOBLACK type ZEXCEL_CONDITION_RULE_ICONSET value '4RedToBlack'. "#EC NOTEXT . + class-data C_ICONSET_4TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value '4TrafficLights'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '5Arrows'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '5ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_5QUARTERS type ZEXCEL_CONDITION_RULE_ICONSET value '5Quarters'. "#EC NOTEXT . + class-data C_ICONSET_5RATING type ZEXCEL_CONDITION_RULE_ICONSET value '5Rating'. "#EC NOTEXT . + class-data C_OPERATOR_BEGINSWITH type ZEXCEL_CONDITION_OPERATOR value 'beginsWith'. "#EC NOTEXT . + class-data C_OPERATOR_BETWEEN type ZEXCEL_CONDITION_OPERATOR value 'between'. "#EC NOTEXT . + class-data C_OPERATOR_CONTAINSTEXT type ZEXCEL_CONDITION_OPERATOR value 'containsText'. "#EC NOTEXT . + class-data C_OPERATOR_ENDSWITH type ZEXCEL_CONDITION_OPERATOR value 'endsWith'. "#EC NOTEXT . + class-data C_OPERATOR_EQUAL type ZEXCEL_CONDITION_OPERATOR value 'equal'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHAN type ZEXCEL_CONDITION_OPERATOR value 'greaterThan'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'greaterThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHAN type ZEXCEL_CONDITION_OPERATOR value 'lessThan'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'lessThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_NONE type ZEXCEL_CONDITION_OPERATOR value ''. "#EC NOTEXT . + class-data C_OPERATOR_NOTCONTAINS type ZEXCEL_CONDITION_OPERATOR value 'notContains'. "#EC NOTEXT . + class-data C_OPERATOR_NOTEQUAL type ZEXCEL_CONDITION_OPERATOR value 'notEqual'. "#EC NOTEXT . + class-data C_RULE_CELLIS type ZEXCEL_CONDITION_RULE value 'cellIs'. "#EC NOTEXT . + class-data C_RULE_CONTAINSTEXT type ZEXCEL_CONDITION_RULE value 'containsText'. "#EC NOTEXT . + class-data C_RULE_EXPRESSION type ZEXCEL_CONDITION_RULE value 'expression'. "#EC NOTEXT . + class-data C_RULE_ICONSET type ZEXCEL_CONDITION_RULE value 'iconSet'. "#EC NOTEXT . + class-data C_RULE_NONE type ZEXCEL_CONDITION_RULE value 'none'. "#EC NOTEXT . + data FORMULA type ZEXCEL_STYLE_FORMULA . + data ICONSET type ZEXCEL_CONDITION_RULE_ICONSET . + data OPERATOR type ZEXCEL_CONDITION_OPERATOR . + data PRIORITY type ZEXCEL_STYLE_PRIORITY value 1. "#EC NOTEXT . + data RULE type ZEXCEL_CONDITION_RULE . + + methods CONSTRUCTOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods SET_RANGE + importing + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data START_CELL type ZEXCEL_S_CELL_DATA . + data STOP_CELL type ZEXCEL_S_CELL_DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + rule = me->c_rule_none. + operator = me->c_operator_none. +* inizialize dimension range + stop_cell-cell_row = 1. + stop_cell-cell_column = 1. + start_cell-cell_row = 1. + start_cell-cell_column = 1. +endmethod. + + + + method GET_DIMENSION_RANGE. + IF stop_cell EQ start_cell. "only one cell + ep_dimension_range = start_cell-cell_coords. + ELSE. + CONCATENATE start_cell-cell_coords ':' stop_cell-cell_coords INTO ep_dimension_range. + ENDIF. +endmethod. + + + + + + + method SET_RANGE. + DATA: lv_column TYPE zexcel_cell_column, + lv_row_alpha TYPE string. + + lv_column = zcl_excel_common=>convert_column2int( ip_stop_column ). + stop_cell-cell_row = 1. + stop_cell-cell_column = lv_column. + lv_row_alpha = ip_stop_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_stop_column lv_row_alpha INTO stop_cell-cell_coords. + + lv_column = zcl_excel_common=>convert_column2int( ip_start_column ). + start_cell-cell_row = 1. + start_cell-cell_column = lv_column. + lv_row_alpha = ip_start_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_start_column lv_row_alpha INTO start_cell-cell_coords. +endmethod. + + + + class ZCL_EXCEL_STYLE_FILL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +public section. + + class-data C_FILL_NONE type ZEXCEL_FILL_TYPE value 'none'. "#EC NOTEXT . + class-data C_FILL_SOLID type ZEXCEL_FILL_TYPE value 'solid'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_LINEAR type ZEXCEL_FILL_TYPE value 'linear'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_PATH type ZEXCEL_FILL_TYPE value 'path'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKDOWN type ZEXCEL_FILL_TYPE value 'darkDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRAY type ZEXCEL_FILL_TYPE value 'darkGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRID type ZEXCEL_FILL_TYPE value 'darkGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKHORIZONTAL type ZEXCEL_FILL_TYPE value 'darkHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKTRELLIS type ZEXCEL_FILL_TYPE value 'darkTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKUP type ZEXCEL_FILL_TYPE value 'darkUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKVERTICAL type ZEXCEL_FILL_TYPE value 'darkVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY0625 type ZEXCEL_FILL_TYPE value 'gray0625'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY125 type ZEXCEL_FILL_TYPE value 'gray125'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTDOWN type ZEXCEL_FILL_TYPE value 'lightDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRAY type ZEXCEL_FILL_TYPE value 'lightGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRID type ZEXCEL_FILL_TYPE value 'lightGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTHORIZONTAL type ZEXCEL_FILL_TYPE value 'lightHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTTRELLIS type ZEXCEL_FILL_TYPE value 'lightTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTUP type ZEXCEL_FILL_TYPE value 'lightUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTVERTICAL type ZEXCEL_FILL_TYPE value 'lightVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_MEDIUMGRAY type ZEXCEL_FILL_TYPE value 'mediumGray'. "#EC NOTEXT . + data FILLTYPE type ZEXCEL_FILL_TYPE . + data ROTATION type ZEXCEL_ROTATION . + data FGCOLOR type ZEXCEL_STYLE_COLOR_ARGB . + data BGCOLOR type ZEXCEL_STYLE_COLOR_ARGB value '64'. "#EC NOTEXT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_FILL . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + filltype = zcl_excel_style_fill=>c_fill_none. + rotation = 0. +endmethod. + + + + method GET_STRUCTURE. + es_fill-rotation = me->rotation. + es_fill-filltype = me->filltype. + es_fill-fgColor = me->fgColor. + es_fill-bgColor = me->bgColor. +endmethod. + + + + class ZCL_EXCEL_STYLE_FONT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data BOLD type FLAG . + data COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_SCHEME_MAJOR type ZEXCEL_STYLE_FONT_SCHEME value 'major'. "#EC NOTEXT . + class-data C_SCHEME_MINOR type ZEXCEL_STYLE_FONT_SCHEME value 'minor'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLE type CHAR20 value 'double'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLEACCOUNTING type CHAR20 value 'doubleAccounting'. "#EC NOTEXT . + class-data C_UNDERLINE_NONE type CHAR20 value 'none'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLE type CHAR20 value 'single'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLEACCOUNTING type CHAR20 value 'singleAccounting'. "#EC NOTEXT . + data FAMILY type INT1 value 2. "#EC NOTEXT . + data ITALIC type FLAG . + data NAME type CHAR255 value 'Calibri'. "#EC NOTEXT . + data SCHEME type ZEXCEL_STYLE_FONT_SCHEME . + data SIZE type INT1 value 11. "#EC NOTEXT . + data STRIKETHROUGH type FLAG . + data UNDERLINE type FLAG . + data UNDERLINE_MODE type CHAR20 . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FONT) type ZEXCEL_S_STYLE_FONT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->color = zcl_excel_style_color=>c_black. + me->scheme = zcl_excel_style_font=>c_scheme_minor. + me->underline_mode = zcl_excel_style_font=>c_underline_single. +endmethod. + + + + method GET_STRUCTURE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + es_font-bold = me->bold. + es_font-italic = me->italic. + es_font-underline = me->underline. + es_font-underline_mode = me->underline_mode. + es_font-strikethrough = me->strikethrough. + es_font-size = me->size. + es_font-color = me->color. + es_font-name = me->name. + es_font-family = me->family. + es_font-scheme = me->scheme. + +endmethod. + + + + class ZCL_EXCEL_STYLE_NUMBER_FORMAT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +public section. + + class-data C_FORMAT_NUMBER type ZEXCEL_NUMBER_FORMAT value '0'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_00 type ZEXCEL_NUMBER_FORMAT value '0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP1 type ZEXCEL_NUMBER_FORMAT value '#,##0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP2 type ZEXCEL_NUMBER_FORMAT value '#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE type ZEXCEL_NUMBER_FORMAT value '0%'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE_00 type ZEXCEL_NUMBER_FORMAT value '0.00%'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD2 type ZEXCEL_NUMBER_FORMAT value 'yyyy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD type ZEXCEL_NUMBER_FORMAT value 'yy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DDMMYYYY type ZEXCEL_NUMBER_FORMAT value 'dd/mm/yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYSLASH type ZEXCEL_NUMBER_FORMAT value 'd/m/y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m'. "#EC NOTEXT . + class-data C_FORMAT_DATE_MYMINUS type ZEXCEL_NUMBER_FORMAT value 'm-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX14 type ZEXCEL_NUMBER_FORMAT value 'mm-dd-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX15 type ZEXCEL_NUMBER_FORMAT value 'd-mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX16 type ZEXCEL_NUMBER_FORMAT value 'd-mmm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX17 type ZEXCEL_NUMBER_FORMAT value 'mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX22 type ZEXCEL_NUMBER_FORMAT value 'm/d/yy h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DATETIME type ZEXCEL_NUMBER_FORMAT value 'd/m/y h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME1 type ZEXCEL_NUMBER_FORMAT value 'h:mm AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME2 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME3 type ZEXCEL_NUMBER_FORMAT value 'h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME4 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME5 type ZEXCEL_NUMBER_FORMAT value 'mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME6 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME7 type ZEXCEL_NUMBER_FORMAT value 'i:s.S'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME8 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss@'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDDSLASH type ZEXCEL_NUMBER_FORMAT value 'yy/mm/dd@'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD_SIMPLE type ZEXCEL_NUMBER_FORMAT value '"$"#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD type ZEXCEL_NUMBER_FORMAT value '$#,##0_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_EUR_SIMPLE type ZEXCEL_NUMBER_FORMAT value '[$EUR ]#,##0.00_-'. "#EC NOTEXT . + data FORMAT_CODE type ZEXCEL_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(EP_NUMBER_FORMAT) type ZEXCEL_NUMBER_FORMAT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +private section. + + class-data C_FORMAT_GENERAL type ZEXCEL_NUMBER_FORMAT value ''. "#EC NOTEXT . + class-data C_FORMAT_TEXT type ZEXCEL_NUMBER_FORMAT value '@'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + format_code = me->c_format_general. +endmethod. + + + + method GET_STRUCTURE. + ep_number_format = me->format_code. +endmethod. + + + + class ZCL_EXCEL_STYLE_PROTECTION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +public section. + + constants C_PROTECTION_INHERIT type ZEXCEL_PROTECTION value 'inherit'. "#EC NOTEXT + constants C_PROTECTION_PROTECTED type ZEXCEL_PROTECTION value 'protected'. "#EC NOTEXT + constants C_PROTECTION_UNPROTECTED type ZEXCEL_PROTECTION value 'unprotected'. "#EC NOTEXT + data LOCKED type ZEXCEL_PROTECTION . + data HIDDEN type ZEXCEL_PROTECTION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + method CONSTRUCTOR. + locked = me->c_protection_inherit. + hidden = me->c_protection_inherit. +endmethod. + + + + class ZCL_EXCEL_WORKSHEET definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + class-data C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT . + class-data C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT . + class-data C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT . + class-data C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT . + data DEFAULTROWHEIGHT type INT1 value 15. "#EC NOTEXT . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHEET_STATE type ZEXCEL_SHEET_STATE . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + + methods ADD_NEW_CONDITIONAL_STYLE + returning + value(EO_CONDITIONAL_STYLE) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods ADD_NEW_DATA_VALIDATION + returning + value(EO_DATA_VALIDATION) type ref to ZCL_EXCEL_DATA_VALIDATION . + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING . + methods GET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC . + methods GET_COND_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods GET_GUID + returning + value(EP_GUID) type OLTPGUID16 . + methods SET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type ZEXCEL_CELL_VALUE + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional . + methods SET_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING optional + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . + methods GET_DATA_VALIDATIONS_SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CONDITIONAL_STYLES type ref to ZCL_EXCEL_STYLES_CONDITIONAL . + data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . + data GUID type OLTPGUID16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + + methods UPDATE_DIMENSION_RANGE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + method ADD_NEW_CONDITIONAL_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT eo_conditional_style. + conditional_styles->add( eo_conditional_style ). +endmethod. + + + + method ADD_NEW_DATA_VALIDATION. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT eo_data_validation. + data_validations->add( eo_data_validation ). +endmethod. + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + sheet_state = me->c_sheet_state_visible. + + CREATE OBJECT sheet_setup. + CREATE OBJECT conditional_styles. + CREATE OBJECT data_validations. + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +ENDMETHOD. + + + + method GET_ACTIVE_CELL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_active_column TYPE zexcel_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = zcl_excel_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + +endmethod. + + + + + + + method GET_CELL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = ip_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. +endmethod. + + + + method GET_COND_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->conditional_styles->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->data_validations->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_SIZE. + ep_size = me->data_validations->size( ). +endmethod. + + + + method GET_DIMENSION_RANGE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + ep_dimension_range = upper_cell-cell_coords. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + +endmethod. + + + + method GET_GUID. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. + +endmethod. + + + + + + + + method SET_CELL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = ZCL_EXCEL_COMMON=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_value = ip_value. + <fs_sheet_content>-cell_formula = ip_formula. + <fs_sheet_content>-cell_style = ip_style. + ELSE. + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column. + ls_sheet_content-cell_value = ip_value. + ls_sheet_content-cell_formula = ip_formula. + ls_sheet_content-cell_style = ip_style. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content. + SORT sheet_content BY cell_row cell_column. +* me->update_dimension_range( ). + + ENDIF. + +endmethod. + + + + + + + + + method SET_TABLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, + lr_data TYPE REF TO data, + ls_newline TYPE REF TO data, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + lv_row_header TYPE zexcel_cell_row VALUE '2', + lv_col_header TYPE zexcel_cell_column_alpha VALUE 'B', + lv_row_int TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lv_cell_value TYPE zexcel_cell_value. + + + FIELD-SYMBOLS: <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY, + <fs_dfies> TYPE dfies, + <fs_cell_value> TYPE zexcel_cell_value. + + lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). + lv_row_int = ip_top_left_row. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + +* It is better to loop column by column + LOOP AT lt_dfies ASSIGNING <fs_dfies>. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + " First of all write column header + lv_cell_value = <fs_dfies>-scrtext_m. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_hdr_style ). + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <fs_dfies>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + MOVE <fs_fldval> TO lv_cell_value. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_body_style ). + ADD 1 TO lv_row_int. + ENDLOOP. + lv_row_int = ip_top_left_row. + ADD 1 TO lv_column_int. + ENDLOOP. + +endmethod. + + + method UPDATE_DIMENSION_RANGE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: ls_sheet_content TYPE zexcel_s_cell_data, + lt_sheet_content TYPE zexcel_t_cell_data_unsorted, + lv_row_alpha TYPE string, + lv_column_alpha TYPE zexcel_cell_column_alpha. + +* update dimension range + lt_sheet_content = sheet_content. + "upper left corner + SORT lt_sheet_content BY cell_row. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = upper_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( upper_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO upper_cell-cell_coords. + + "bottom right corner + SORT lt_sheet_content BY cell_row DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = lower_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lower_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. + +endmethod. + + + + class ZCL_EXCEL_WORKSHEETS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +public section. + + data ACTIVE_WORKSHEET type ZEXCEL_ACTIVE_WORKSHEET value 1. "#EC NOTEXT . + data NAME type ZEXCEL_WORKSHEETS_NAME value 'Worksheets'. "#EC NOTEXT . + + methods ADD + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +private section. + + data WORKSHEETS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + method ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->add( ip_worksheet ). +endmethod. + + + method CLEAR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->clear( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT worksheets. + +endmethod. + + + + + method GET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_worksheet ?= worksheets->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= worksheets->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = worksheets->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->remove( ip_worksheet ). +endmethod. + + + + method SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = worksheets->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + methods CONSTRUCTOR + importing + !IO_EXCEL type ref to ZCL_EXCEL . + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_CALCCHAIN type STRING value 'xl/calcChain.xml'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_CALCCHAIN + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->excel = io_excel. +endmethod. + + + + method CREATE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sharedStrings.xml to zip + lv_content = me->create_xl_calcchain( ). + lo_zip->add( name = me->c_xl_calcchain + content = lv_content ). + +********************************************************************** +* STEP 11: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +endmethod. + + + + method CREATE_CONTENT_TYPES. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lv_xml_node_worksheet_pn ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_APP. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_CORE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_RELATIONSHIPS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_CALCCHAIN. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_calcchain TYPE string VALUE 'calcChain', + lc_xml_node_c TYPE string VALUE 'c', + " Node attributes + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_i TYPE string VALUE 'i', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string, + lv_value_i TYPE string, + lv_sheets_count TYPE i. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create xl/calcChain.xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node calcChain + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_calcchain + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + ADD 1 TO lv_sheets_count. + MOVE lv_sheets_count TO lv_value_i. + SHIFT lv_value_i RIGHT DELETING TRAILING space. + SHIFT lv_value_i LEFT DELETING LEADING space. + LOOP AT lo_worksheet->sheet_content ASSIGNING <ls_sheet_content> WHERE cell_formula IS NOT INITIAL. + " formula chain node + lo_element = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_i + value = lv_value_i ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_RELATIONSHIPS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + lc_xml_node_rid_calcchain_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml', + lc_xml_node_rid_calcchain_tg TYPE string VALUE 'calcChain.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 1 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_calcchain_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_calcchain_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_SHAREDSTRINGS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + + METHOD create_xl_sheet. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + lc_xml_node_datavalidations TYPE string VALUE 'dataValidations', + lc_xml_node_datavalidation TYPE string VALUE 'dataValidation', + lc_xml_node_formula1 TYPE string VALUE 'formula1', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + lc_xml_attr_allowblank TYPE string VALUE 'allowBlank', + lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage', + lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_data_validation TYPE REF TO zcl_excel_data_validation. + + DATA: lv_value TYPE string, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + lv_cell_row_s TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + lv_value = io_worksheet->defaultrowheight. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + lo_element_root->append_child( lo_element ). " sheetFormatPr node + + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = '1:1' ). " <******************************* + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + IF ls_style_mapping-cell_format IS INITIAL. " to avoid errors if no style has been created + IF <ls_sheet_content>-cell_formula IS INITIAL. + ls_style_mapping-cell_format = 'S'. + ELSE. + ls_style_mapping-cell_format = 'F'. + ENDIF. + ENDIF. + " is a shared string and is not a formula + IF ls_style_mapping-cell_format EQ 'S'. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = 's' ). + ENDIF. + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ENDIF. + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF ls_style_mapping-cell_format EQ 'S'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + + + IF io_worksheet->get_data_validations_size( ) GT 0. + " dataValidations node + lo_element = lo_document->create_simple_element( name = lc_xml_node_datavalidations + parent = lo_document ). + " Conditional formatting node + lo_iterator = io_worksheet->get_data_validations_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_data_validation ?= lo_iterator->get_next( ). + " dataValidation node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_datavalidation + parent = lo_document ). + lv_value = lo_data_validation->type. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + IF lo_data_validation->allowblank EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_allowblank + value = lv_value ). + IF lo_data_validation->showinputmessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showinputmessage + value = lv_value ). + IF lo_data_validation->showerrormessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showerrormessage + value = lv_value ). + lv_cell_row_s = lo_data_validation->cell_row. + SHIFT lv_cell_row_s RIGHT DELETING TRAILING space. + SHIFT lv_cell_row_s LEFT DELETING LEADING space. + CONCATENATE lo_data_validation->cell_column lv_cell_row_s INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + " formula1 node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula1 + parent = lo_document ). + lv_value = lo_data_validation->value. + lo_element_3->set_value( lv_value ). + + lo_element_2->append_child( lo_element_3 ). " formula1 node + + lo_element->append_child( lo_element_2 ). " dataValidation node + ENDWHILE. + lo_element_root->append_child( lo_element ). " dataValidations node + ENDIF. + + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + method CREATE_XL_SHEET_RELS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + lc_xml_node_rid_print_id TYPE string VALUE 'rId1', + " Node type + lc_xml_node_rid_print_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', + " Node target + lc_xml_node_rid_print_tg TYPE string VALUE '../printerSettings/printerSettings1.bin'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rid_print_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_print_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_print_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_STYLES. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + ls_format TYPE zexcel_number_format, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_format = lo_style->number_format->get_structure( ). + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + + IF ls_format IS INITIAL. + ls_cellxfs-numfmtid = 0. " number format + ELSE. + ls_cellxfs-numfmtid = ls_format. " number format + ENDIF. + ls_cellxfs-xfid = 0. + + IF ls_format IS NOT INITIAL. + ls_cellxfs-applynumberformat = 1. + ls_styles_mapping-cell_format = 'I'. + ELSE. + ls_cellxfs-applynumberformat = 0. + ls_styles_mapping-cell_format = 'S'. + ENDIF. + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + " Collect color + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = 'TableStyleMedium9' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = 'PivotStyleLight16' ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_THEME. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +endmethod. + + + + METHOD create_xl_workbook. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + lc_xml_node_definednames TYPE string VALUE 'definedNames', + lc_xml_node_definedname TYPE string VALUE 'definedName', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + + " ranges node + lo_element = lo_document->create_simple_element( name = lc_xml_node_definedNames + parent = lo_document ). + lo_iterator = excel->get_ranges_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " range node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_definedName + parent = lo_document ). + lo_range ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_range->name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lv_value = lo_range->get_value( ). + lo_sub_element->set_value( lv_value ). + lo_element->append_child( lo_sub_element ). " range node + ENDWHILE. + lo_element_root->append_child( lo_element )." ranges node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + method FLAG2BOOL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +endmethod. + + + + + method GET_SHARED_STRING_INDEX. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +endmethod. + + + + class ZCL_EXCEL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! +public section. + + constants C_XLS type ZEXCEL_FORMAT value 'XLS'. "#EC NOTEXT + constants C_XLSX type ZEXCEL_FORMAT value 'XLSX'. "#EC NOTEXT + data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . + data SECURITY type ref to ZCL_EXCEL_SECURITY . + + methods ADD_NEW_DRAWING + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_RANGE + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods ADD_NEW_STYLE + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods ADD_NEW_WORKSHEET + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods CONSTRUCTOR . + methods GET_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_DRAWINGS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_RANGES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_NAME + returning + value(EP_NAME) type ZEXCEL_WORKSHEETS_NAME . + methods GET_WORKSHEETS_SIZE + returning + value(EP_SIZE) type I . + methods SAVE_AS + importing + !IP_FORMAT type ZEXCEL_FORMAT + returning + value(EP_FILE) type XSTRING . + *"* protected components of class ZABAP_EXCEL +*"* do not include other source files here!!! +protected 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 . + data STYLES type ref to ZCL_EXCEL_STYLES . + data WORKSHEETS type ref to ZCL_EXCEL_WORKSHEETS . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method ADD_NEW_DRAWING. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_title = ip_title. + drawings->add( eo_drawing ). +endmethod. + + + + method ADD_NEW_RANGE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Create default blank range + CREATE OBJECT eo_range. + ranges->add( eo_range ). +endmethod. + + + + method ADD_NEW_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Create default style + CREATE OBJECT eo_style. + styles->add( eo_style ). + +endmethod. + + + + + method ADD_NEW_WORKSHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_title = ip_title. + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style TYPE REF TO zcl_excel_style. + +* Inizialize instance objects + CREATE OBJECT properties. + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings. + + 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. + + + + method GET_ACTIVE_WORKSHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + +endmethod. + + + + method GET_DRAWINGS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->drawings->get_iterator( ). +endmethod. + + + + method GET_RANGES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->ranges->get_iterator( ). +endmethod. + + + + method GET_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->styles->get_iterator( ). +endmethod. + + + + method GET_WORKSHEETS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->worksheets->get_iterator( ). +endmethod. + + + + method GET_WORKSHEETS_NAME. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_name = me->worksheets->name. + +endmethod. + + + + method GET_WORKSHEETS_SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = me->worksheets->size( ). + +endmethod. + + + + + method SAVE_AS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lo_excel_writer_2007 TYPE REF TO zcl_excel_writer_2007. + +* Determine the output engine to use + CASE ip_format. + WHEN me->c_xlsx. " XLSX for Office 2007 + CREATE OBJECT lo_excel_writer_2007 EXPORTING io_excel = me. + ep_file = lo_excel_writer_2007->create( ). + WHEN OTHERS. + ENDCASE. + +endmethod. + + + + class ZCL_EXCEL_COMMON definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +public section. + + class-methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + class-methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +private section. + + class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + method CONVERT_COLUMN2ALPHA. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +endmethod. + + + + + method CONVERT_COLUMN2INT. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( zcl_excel_common=>c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( zcl_excel_common=>c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - zcl_excel_common=>c_excel_col_module. + ENDIF. + +endmethod. + + + + class ZCL_EXCEL_DATA_VALIDATION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data ALLOWBLANK type FLAG value 'X'. "#EC NOTEXT . + data CELL_ROW type ZEXCEL_CELL_ROW . + class-data C_TYPE_LIST type ZEXCEL_DATA_VAL_TYPE value 'list'. "#EC NOTEXT . + data SHOWERRORMESSAGE type FLAG value 'X'. "#EC NOTEXT . + data SHOWINPUTMESSAGE type FLAG value 'X'. "#EC NOTEXT . + data TYPE type ZEXCEL_DATA_VAL_TYPE . + data VALUE type ZEXCEL_VALIDATION_FORMULA1 . + data CELL_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + METHOD constructor. + type = me->c_type_list. +* inizialize dimension range + cell_row = 1. + cell_column = 'A'. +ENDMETHOD. + + + + class ZCL_EXCEL_DATA_VALIDATIONS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + methods ADD + importing + !IP_DATA_VALIDATION type ref to ZCL_EXCEL_DATA_VALIDATION . + methods CLEAR . + methods CONSTRUCTOR . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DATA_VALIDATION type ref to ZCL_EXCEL_DATA_VALIDATION . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +private section. + + data DATA_VALIDATIONS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + METHOD add. + data_validations->add( ip_data_validation ). +ENDMETHOD. + + + METHOD clear. + data_validations->clear( ). +ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT data_validations. + +ENDMETHOD. + + + + METHOD get_iterator. + eo_iterator ?= data_validations->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. + is_empty = data_validations->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. + data_validations->remove( ip_data_validation ). +ENDMETHOD. + + + + METHOD size. + ep_size = data_validations->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_DRAWING definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + data X_REFERENCES type CHAR1 . + data Y_REFERENCES type CHAR1 . + data GRAPH_TYPE type ZEXCEL_GRAPH_TYPE . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +private section. + + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + constants C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT + + methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + method CONSTRUCTOR. + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +endmethod. + + + + + method CONVERT_COLUMN2ALPHA. + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +endmethod. + + + + + method CONVERT_COLUMN2INT. + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( me->c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( me->c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - me->c_excel_col_module. + ENDIF. + +endmethod. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + class ZCL_EXCEL_DRAWINGS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +private section. + + data DRAWINGS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->add( ip_drawing ). +endmethod. + + + method CLEAR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->clear( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT drawings. + +endmethod. + + + + + method GET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_drawing ?= drawings->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= drawings->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = drawings->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->remove( ip_drawing ). +endmethod. + + + + method SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = drawings->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_PROPERTIES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +public section. + + data CREATOR type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data LASTMODIFIEDBY type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data CREATED type TIMESTAMPL . + data MODIFIED type TIMESTAMPL . + data TITLE type ZEXCEL_TITLE value 'Untitled Spreadsheet'. "#EC NOTEXT . + data SUBJECT type ZEXCEL_SUBJECT . + data DESCRIPTION type ZEXCEL_DESCRIPTION . + data KEYWORDS type ZEXCEL_KEYWORDS . + data CATEGORY type ZEXCEL_CATEGORY . + data COMPANY type ZEXCEL_COMPANY value 'Microsoft Corporation'. "#EC NOTEXT . + data APPLICATION type ZEXCEL_APPLICATION value 'Microsoft Excel'. "#EC NOTEXT . + data DOCSECURITY type ZEXCEL_DOCSECURITY value '0'. "#EC NOTEXT . + data SCALECROP type ZEXCEL_SCALECROP value ''. "#EC NOTEXT . + data LINKSUPTODATE type FLAG . + data SHAREDDOC type FLAG . + data HYPERLINKSCHANGED type FLAG . + data APPVERSION type ZEXCEL_APPVERSION value '12.0000'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_PROPERTIES +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + + DATA: lv_timestamp TYPE timestampl. + + GET TIME STAMP FIELD lv_timestamp. + created = lv_timestamp. + modified = lv_timestamp. + +endmethod. + + + + class ZCL_EXCEL_RANGE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +public section. + + data NAME type ZEXCEL_RANGE_NAME . + data GUID type ZEXCEL_RANGE_GUID . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_RANGE_GUID . + methods SET_VALUE + importing + !IP_SHEET_NAME type ZEXCEL_SHEET_TITLE + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + methods GET_VALUE + returning + value(EP_VALUE) type ZEXCEL_RANGE_VALUE . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +private section. + + data VALUE type ZEXCEL_RANGE_VALUE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + method CONSTRUCTOR. +endmethod. + + + + METHOD get_guid. + + ep_guid = me->guid. + +ENDMETHOD. + + + + METHOD get_value. + + ep_value = me->value. + +ENDMETHOD. + + + + + + + + METHOD set_value. + DATA: lv_start_row_c TYPE char7, + lv_stop_row_c TYPE char7. + lv_stop_row_c = ip_stop_row. + SHIFT lv_stop_row_c RIGHT DELETING TRAILING space. + SHIFT lv_stop_row_c LEFT DELETING LEADING space. + lv_start_row_c = ip_start_row. + SHIFT lv_start_row_c RIGHT DELETING TRAILING space. + SHIFT lv_start_row_c LEFT DELETING LEADING space. + CONCATENATE ip_sheet_name '!$' ip_start_column '$' lv_start_row_c ':$' ip_stop_column '$' lv_stop_row_c INTO me->value. +ENDMETHOD. + + + + class ZCL_EXCEL_RANGES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! +private section. + + data RANGES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + ranges->add( ip_range ). +endmethod. + + + method CLEAR. + ranges->clear( ). +endmethod. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT ranges. + +ENDMETHOD. + + + + + method GET. + eo_range ?= ranges->if_object_collection~get( ip_index ). +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= ranges->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = ranges->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + ranges->remove( ip_range ). +endmethod. + + + + method SIZE. + ep_size = ranges->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_SECURITY definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SECURITY +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data LOCKREVISION type FLAG . + data LOCKSTRUCTURE type FLAG . + data LOCKWINDOWS type FLAG . + data REVISIONSPASSWORD type ZEXCEL_REVISIONSPASSWORD . + data WORKBOOKPASSWORD type ZEXCEL_WORKBOOKPASSWORD . + + methods CONSTRUCTOR . + methods IS_SECURITY_ENABLED + returning + value(EP_SECURITY_ENABLED) type FLAG . + *"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + method CONSTRUCTOR. +endmethod. + + + + method IS_SECURITY_ENABLED. + IF lockrevision EQ abap_true OR lockstructure EQ abap_true OR lockwindows EQ abap_true. + ep_security_enabled = abap_true. + ENDIF. +endmethod. + + + + class ZCL_EXCEL_SHEET_SETUP definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants C_PAPERSIZE_LETTER type ZEXCEL_SHEET_PAPER_SIZE value 1. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 2. "#EC NOTEXT + constants C_PAPERSIZE_TABLOID type ZEXCEL_SHEET_PAPER_SIZE value 3. "#EC NOTEXT + constants C_PAPERSIZE_LEDGER type ZEXCEL_SHEET_PAPER_SIZE value 4. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL type ZEXCEL_SHEET_PAPER_SIZE value 5. "#EC NOTEXT + constants C_PAPERSIZE_STATEMENT type ZEXCEL_SHEET_PAPER_SIZE value 6. "#EC NOTEXT + constants C_PAPERSIZE_EXECUTIVE type ZEXCEL_SHEET_PAPER_SIZE value 7. "#EC NOTEXT + constants C_PAPERSIZE_A3 type ZEXCEL_SHEET_PAPER_SIZE value 8. "#EC NOTEXT + constants C_PAPERSIZE_A4 type ZEXCEL_SHEET_PAPER_SIZE value 9. "#EC NOTEXT + constants C_PAPERSIZE_A4_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 10. "#EC NOTEXT + constants C_PAPERSIZE_A5 type ZEXCEL_SHEET_PAPER_SIZE value 11. "#EC NOTEXT + constants C_PAPERSIZE_B4 type ZEXCEL_SHEET_PAPER_SIZE value 12. "#EC NOTEXT + constants C_PAPERSIZE_B5 type ZEXCEL_SHEET_PAPER_SIZE value 13. "#EC NOTEXT + constants C_PAPERSIZE_FOLIO type ZEXCEL_SHEET_PAPER_SIZE value 14. "#EC NOTEXT + constants C_PAPERSIZE_QUARTO type ZEXCEL_SHEET_PAPER_SIZE value 15. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_1 type ZEXCEL_SHEET_PAPER_SIZE value 16. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_2 type ZEXCEL_SHEET_PAPER_SIZE value 17. "#EC NOTEXT + constants C_PAPERSIZE_NOTE type ZEXCEL_SHEET_PAPER_SIZE value 18. "#EC NOTEXT + constants C_PAPERSIZE_NO9_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 19. "#EC NOTEXT + constants C_PAPERSIZE_NO10_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 20. "#EC NOTEXT + constants C_PAPERSIZE_NO11_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 21. "#EC NOTEXT + constants C_PAPERSIZE_NO12_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 22. "#EC NOTEXT + constants C_PAPERSIZE_NO14_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 23. "#EC NOTEXT + constants C_PAPERSIZE_C type ZEXCEL_SHEET_PAPER_SIZE value 24. "#EC NOTEXT + constants C_PAPERSIZE_D type ZEXCEL_SHEET_PAPER_SIZE value 25. "#EC NOTEXT + constants C_PAPERSIZE_E type ZEXCEL_SHEET_PAPER_SIZE value 26. "#EC NOTEXT + constants C_PAPERSIZE_DL_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 27. "#EC NOTEXT + constants C_PAPERSIZE_C5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 28. "#EC NOTEXT + constants C_PAPERSIZE_C3_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 29. "#EC NOTEXT + constants C_PAPERSIZE_C4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 30. "#EC NOTEXT + constants C_PAPERSIZE_C6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 31. "#EC NOTEXT + constants C_PAPERSIZE_C65_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 32. "#EC NOTEXT + constants C_PAPERSIZE_B4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 33. "#EC NOTEXT + constants C_PAPERSIZE_B5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 34. "#EC NOTEXT + constants C_PAPERSIZE_B6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 35. "#EC NOTEXT + constants C_PAPERSIZE_ITALY_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 36. "#EC NOTEXT + constants C_PAPERSIZE_MONARCH_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 37. "#EC NOTEXT + constants C_PAPERSIZE_6_3_4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 38. "#EC NOTEXT + constants C_PAPERSIZE_US_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 39. "#EC NOTEXT + constants C_PAPERSIZE_DE_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 40. "#EC NOTEXT + constants C_PAPERSIZE_DE_LEG_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 41. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B4 type ZEXCEL_SHEET_PAPER_SIZE value 42. "#EC NOTEXT + constants C_PAPERSIZE_JPN_DBL_POSTCARD type ZEXCEL_SHEET_PAPER_SIZE value 43. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_1 type ZEXCEL_SHEET_PAPER_SIZE value 44. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_2 type ZEXCEL_SHEET_PAPER_SIZE value 45. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_3 type ZEXCEL_SHEET_PAPER_SIZE value 46. "#EC NOTEXT + constants C_PAPERSIZE_INVITE_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 47. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 48. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 49. "#EC NOTEXT + constants C_PAPERSIZE_TABL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 50. "#EC NOTEXT + constants C_PAPERSIZE_A4_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 51. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 52. "#EC NOTEXT + constants C_PAPERSIZE_A4_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 53. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 54. "#EC NOTEXT + constants C_PAPERSIZE_SUPERA_A4_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 55. "#EC NOTEXT + constants C_PAPERSIZE_SUPERB_A3_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 56. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 57. "#EC NOTEXT + constants C_PAPERSIZE_A4_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 58. "#EC NOTEXT + constants C_PAPERSIZE_A5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 59. "#EC NOTEXT + constants C_PAPERSIZE_JIS_B5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 60. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 61. "#EC NOTEXT + constants C_PAPERSIZE_A5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 62. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 63. "#EC NOTEXT + constants C_PAPERSIZE_A2_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 64. "#EC NOTEXT + constants C_PAPERSIZE_A3_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 65. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 66. "#EC NOTEXT + constants C_ORIENTATION_DEFAULT type ZEXCEL_SHEET_ORIENATATION value 'default'. "#EC NOTEXT + constants C_ORIENTATION_LANDSCAPE type ZEXCEL_SHEET_ORIENATATION value 'landscape'. "#EC NOTEXT + constants C_ORIENTATION_PORTRAIT type ZEXCEL_SHEET_ORIENATATION value 'portrait'. "#EC NOTEXT + data ORIENTATION type ZEXCEL_SHEET_ORIENATATION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + orientation = me->c_orientation_default. +endmethod. + + + + class ZCL_EXCEL_STYLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +public section. + + data FONT type ref to ZCL_EXCEL_STYLE_FONT . + data FILL type ref to ZCL_EXCEL_STYLE_FILL . + data BORDERS type ref to ZCL_EXCEL_STYLE_BORDERS . + data NUMBER_FORMAT type ref to ZCL_EXCEL_STYLE_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_CELL_STYLE . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +private section. + + data ALIGNMENT type ref to ZCL_EXCEL_STYLE_ALIGNMENT . + data PROTECTION type ref to ZCL_EXCEL_STYLE_PROTECTION . + data GUID type ZEXCEL_CELL_STYLE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT font. + CREATE OBJECT fill. + CREATE OBJECT borders. + CREATE OBJECT alignment. + CREATE OBJECT number_format. + CREATE OBJECT protection. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + +endmethod. + + + + method GET_GUID. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. +endmethod. + + + + class ZCL_EXCEL_STYLES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods SIZE + returning + value(EP_SIZE) type I . + methods REGISTER_NEW_STYLE + importing + !IO_STYLE type ref to ZCL_EXCEL_STYLE + returning + value(EP_STYLE_CODE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +private section. + + data STYLES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->add( ip_style ). +endmethod. + + + method CLEAR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->clear( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT styles. +endmethod. + + + + + method GET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_style ?= styles->if_object_collection~get( ip_index ). +endmethod. + + + + method GET_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= styles->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = styles->if_object_collection~is_empty( ). +endmethod. + + + + + method REGISTER_NEW_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->add( io_style ). + ep_style_code = me->size( ) - 1. "style count starts from 0 +endmethod. + + + + method REMOVE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->remove( ip_style ). +endmethod. + + + + method SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = styles->if_object_collection~size( ). +endmethod. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel9. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + +lo_data_validation = lo_worksheet->add_new_data_validation( ). +lo_data_validation->value = lo_range->name. +lo_data_validation->cell_row = 4. +lo_data_validation->cell_column = 'A'. + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Select a value' ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\DataValidation.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel8. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Range.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel7. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 5 + ip_stop_column = 'B' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 5 + ip_stop_column = 'C' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3flags. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 5 + ip_stop_column = 'D' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'C_ICONSET_3FLAGS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 5 + ip_stop_column = 'E' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'C_ICONSET_3TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 5 + ip_stop_column = 'F' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'C_ICONSET_3TRAFFICLIGHTS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'F' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'F' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'F' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'F' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'G' + ip_start_row = 5 + ip_stop_column = 'G' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = 'C_ICONSET_3SIGNS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'G' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'G' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'G' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'G' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'G' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'H' + ip_start_row = 5 + ip_stop_column = 'H' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'H' ip_value = 'C_ICONSET_3SYMBOLS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'H' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'H' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'H' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'H' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'H' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'I' + ip_start_row = 5 + ip_stop_column = 'I' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'I' ip_value = 'C_ICONSET_3SYMBOLS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'I' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'I' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'I' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'I' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'I' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 12 + ip_stop_column = 'B' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = 'C_ICONSET_4ARROWS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 12 + ip_stop_column = 'C' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'C' ip_value = 'C_ICONSET_4ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 12 + ip_stop_column = 'D' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'D' ip_value = 'C_ICONSET_4REDTOBLACK' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 12 + ip_stop_column = 'E' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'E' ip_value = 'C_ICONSET_4RATING' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 12 + ip_stop_column = 'F' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'F' ip_value = 'C_ICONSET_4TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'F' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'F' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'F' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'F' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 19 + ip_stop_column = 'B' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'B' ip_value = 'C_ICONSET_5ARROWS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 19 + ip_stop_column = 'C' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'C' ip_value = 'C_ICONSET_5ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 19 + ip_stop_column = 'D' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'D' ip_value = 'C_ICONSET_5RATING' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5quarters. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 19 + ip_stop_column = 'E' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Iconset.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel6. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '100' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '1000' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '150' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '500' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = '1760' ip_formula = 'SUM(C4:C8)' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Formula.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel5. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '100' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '1000' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '150' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '500' ip_style = lv_style_number_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\CondFormatting.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel4. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ). + +lo_worksheet = lo_excel->add_new_worksheet( ). +lo_worksheet->title = 'Sheet2'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ). + + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Sheets.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel3. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_header TYPE REF TO zcl_excel_style, + lo_style_body TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_header_guid TYPE zexcel_cell_style, + lv_style_body_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +" Create filled style +lo_style_header = lo_excel->add_new_style( ). +lo_style_header->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_header->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lo_style_header->borders->allborders = lo_border_dark. +lv_style_header_guid = lo_style_header->get_guid( ). +"Create style with border +lo_style_body = lo_excel->add_new_style( ). +lo_style_body->borders->allborders = lo_border_dark. +lv_style_body_guid = lo_style_body->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. +lo_worksheet->set_table( ip_table = lt_test + ip_hdr_style = lv_style_header_guid + ip_body_style = lv_style_body_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTab.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel2. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_bold TYPE REF TO zcl_excel_style, + lo_style_underline TYPE REF TO zcl_excel_style, + lo_style_filled TYPE REF TO zcl_excel_style, + lo_style_border TYPE REF TO zcl_excel_style, + lo_style_button TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_bold_guid TYPE zexcel_cell_style, + lv_style_underline_guid TYPE zexcel_cell_style, + lv_style_filled_guid TYPE zexcel_cell_style, + lv_style_border_guid TYPE zexcel_cell_style, + lv_style_button_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +CREATE OBJECT lo_border_light. +lo_border_light->border_color = zcl_excel_style_color=>c_gray. +lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. +" Create a bold / italic style +lo_style_bold = lo_excel->add_new_style( ). +lo_style_bold->font->bold = abap_true. +lo_style_bold->font->italic = abap_true. +lo_style_bold->font->color = zcl_excel_style_color=>c_red. +lv_style_bold_guid = lo_style_bold->get_guid( ). +" Create an underline double style +lo_style_underline = lo_excel->add_new_style( ). +lo_style_underline->font->underline = abap_true. +lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double. +lv_style_underline_guid = lo_style_underline->get_guid( ). +" Create filled style +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lv_style_filled_guid = lo_style_filled->get_guid( ). +" Create border with button effects +lo_style_button = lo_excel->add_new_style( ). +lo_style_button->borders->right = lo_border_dark. +lo_style_button->borders->down = lo_border_dark. +lo_style_button->borders->left = lo_border_light. +lo_style_button->borders->top = lo_border_light. +lv_style_button_guid = lo_style_button->get_guid( ). +"Create style with border +lo_style_border = lo_excel->add_new_style( ). +lo_style_border->borders->allborders = lo_border_dark. +lv_style_border_guid = lo_style_border->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Styles'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Styles.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel1. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HelloWorld.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report Z_ZAKE_SVN +*& +*&---------------------------------------------------------------------* +*& Checkout / Checkin the ZAKE_SVN Project +*& +*&---------------------------------------------------------------------* + +REPORT zake_svn_a2x. + +CONSTANTS cl_svn TYPE seoclsname VALUE 'ZCL_ZAKE_SVN'. +CONSTANTS cl_tortoise_svn TYPE seoclsname VALUE 'ZCL_ZAKE_TORTOISE_SVN'. + +DATA package TYPE devclass. +DATA zake TYPE REF TO zake. + +DATA zake_objects TYPE scts_tadir. + +DATA files TYPE string_table. +DATA file LIKE LINE OF files. + +DATA zake_build TYPE string. +DATA zake_nuggetname TYPE string. + +DATA comment_str TYPE string. +DATA loclpath_str TYPE string. +DATA svnpath_str TYPE string. +DATA username_str TYPE string. +DATA password_str TYPE string. +DATA class TYPE seoclsname. + +DATA: ex TYPE REF TO zcx_saplink, + message TYPE string. + +SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE a. +PARAMETERS: + checkout TYPE flag RADIOBUTTON GROUP act, + update TYPE flag RADIOBUTTON GROUP act DEFAULT 'X', + checkin TYPE flag RADIOBUTTON GROUP act. +SELECTION-SCREEN END OF BLOCK a. + +SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE b. +PARAMETERS: + svn TYPE flag RADIOBUTTON GROUP cl, + tortoise TYPE flag RADIOBUTTON GROUP cl. +SELECTION-SCREEN END OF BLOCK b. + +SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE c. +PARAMETERS: + loclpath TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx' LOWER CASE OBLIGATORY, + zakebuil TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx\build\NUGG_ABAP2XLSX_V_1_0.nugg' LOWER CASE OBLIGATORY, + zakenugg TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx\nuggs\NUGG_ABAP2XLSX_V_1_0.nugg' LOWER CASE OBLIGATORY, + svnpath TYPE char512 DEFAULT 'https://abap2xlsx.googlecode.com/svn/trunk/abap2xlsx' LOWER CASE OBLIGATORY, + comment TYPE char512 DEFAULT '' LOWER CASE, + username TYPE char512 LOWER CASE, + password TYPE char512 LOWER CASE, + testrun TYPE flag DEFAULT 'X'. +SELECTION-SCREEN END OF BLOCK c. + +INITIALIZATION. + a = 'Action'. + b = 'Version Controll Program'. + c = 'Parameters'. + +START-OF-SELECTION. + + svnpath_str = svnpath. + loclpath_str = loclpath. + zake_build = zakebuil. + zake_nuggetname = zakenugg. + comment_str = comment. + + SELECT * INTO TABLE zake_objects FROM tadir WHERE devclass = 'ZABAP2XLSX'. + DELETE zake_objects WHERE object = 'DEVC'. + + TRY. + IF svn = 'X'. + class = cl_svn. + ELSE. + class = cl_tortoise_svn. + ENDIF. + + CREATE OBJECT zake + TYPE + (class) + EXPORTING + i_svnpath = svnpath_str + i_localpath = loclpath_str. + zake->set_testrun( testrun ). + + IF checkin = 'X'. + zake->set_package( 'ZA2X' ). + zake->set_checkin_objects( zake_objects ). + zake->create_slinkees( zake_nuggetname ). + " Build a complete package for download +* zake->set_package( 'ZA2X' ). +* zake->set_checkin_objects( zake_objects ). +* " Let's add the CMD Scripts to the complete package +* CONCATENATE loclpath 'bin/svn-script.cmd' INTO file. +* APPEND file TO files. +* CONCATENATE loclpath 'bin/tortoise-svn-script.cmd' INTO file. +* APPEND file TO files. +* zake->add_files_to_zip( files ). +* " We don't want that for the complete Package Slinkees are created +* " in the ZAKE folder +* zake->download_slinkees_to_lm = space. +* zake->download_nugget_to_lm = space. +* zake->create_slinkees( zake_nuggetname ). + IF testrun IS INITIAL. + zake->checkin( comment_str ). + ENDIF. + ELSE. + IF update = 'X'. + zake->update( ). + ELSE. + zake->checkout( ). + ENDIF. + " zake->install_slinkees_from_lm( testrun ). + zake->install_objects( zake_objects ). + ENDIF. + CATCH zcx_saplink INTO ex. + message = ex->msg. + WRITE: / 'An Error occured: ', message. + ENDTRY. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/NUGG_ABAP2XLSX_V_1_1.nugg.zip b/build/NUGG_ABAP2XLSX_V_1_1.nugg.zip new file mode 100644 index 0000000..4c5ca39 Binary files /dev/null and b/build/NUGG_ABAP2XLSX_V_1_1.nugg.zip differ diff --git a/nuggs/ABAP2XLSX_V_2_0.zip b/nuggs/ABAP2XLSX_V_2_0.zip new file mode 100644 index 0000000..f0560d2 Binary files /dev/null and b/nuggs/ABAP2XLSX_V_2_0.zip differ diff --git a/nuggs/NUGG_ABAP2XLSX_V_1_0.nugg b/nuggs/NUGG_ABAP2XLSX_V_1_0.nugg new file mode 100644 index 0000000..6029fad --- /dev/null +++ b/nuggs/NUGG_ABAP2XLSX_V_1_0.nugg @@ -0,0 +1,875 @@ + + + + class ZCL_EXCEL_WORKSHEET definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + class-data C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT . + class-data C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT . + class-data C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT . + class-data C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_CONTENT_MERGE type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHEET_STATE type ZEXCEL_SHEET_STATE . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + + methods ADD_NEW_CONDITIONAL_STYLE + returning + value(EO_CONDITIONAL_STYLE) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods ADD_NEW_DATA_VALIDATION + returning + value(EO_DATA_VALIDATION) type ref to ZCL_EXCEL_DATA_VALIDATION . + methods BIND_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IT_FIELD_CATALOG type ZEXCEL_T_FIELDCATALOG optional + !IS_TABLE_SETTINGS type ZEXCEL_S_TABLE_SETTINGS optional . + methods CONSTRUCTOR + importing + !IP_EXCEL type ref to ZCL_EXCEL + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods DELETE_MERGE . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING . + methods GET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC . + methods GET_COLUMN_DIMENSION + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(R_COLUMN_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods GET_COLUMN_DIMENSIONS + returning + value(R_COLUMN_DIMENSION) type ZEXCEL_T_WORKSHEET_COLUMNDIME . + methods GET_COND_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_SIZE + returning + value(EP_SIZE) type I . + methods GET_DEFAULT_COLUMN_DIMENSION + returning + value(R_COLUMN_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + methods GET_DEFAULT_ROW_DIMENSION + returning + value(R_ROW_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods GET_GUID + returning + value(EP_GUID) type OLTPGUID16 . + methods GET_HIGHEST_COLUMN + returning + value(R_HIGHEST_COLUMN) type ZEXCEL_CELL_COLUMN . + methods GET_HIGHEST_ROW + returning + value(R_HIGHEST_ROW) type INT4 . + methods GET_MERGE + returning + value(MERGE_RANGE) type STRING_TABLE . + methods GET_ROW_DIMENSION + importing + !IP_ROW type INT4 + returning + value(R_ROW_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . + methods GET_ROW_DIMENSIONS + returning + value(R_ROW_DIMENSION) type ZEXCEL_T_WORKSHEET_ROWDIMENSIO . + methods SET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type SIMPLE optional + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional . + methods SET_CELL_STYLE + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_STYLE type ZEXCEL_CELL_STYLE + raising + ZCX_EXCEL . + methods SET_MERGE + importing + !IP_COLUMN_START type ZEXCEL_CELL_COLUMN_ALPHA optional + !IP_COLUMN_END type ZEXCEL_CELL_COLUMN_ALPHA optional + !IP_ROW type ZEXCEL_CELL_ROW optional . + methods SET_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . + methods GET_TABLES_SIZE + returning + value(EP_SIZE) type I . + methods GET_TABLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + *"* protected components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CONDITIONAL_STYLES type ref to ZCL_EXCEL_STYLES_CONDITIONAL . + data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . + data GUID type OLTPGUID16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + data COLUMN_DIMENSIONS type ZEXCEL_T_WORKSHEET_COLUMNDIME . + data ROW_DIMENSIONS type ZEXCEL_T_WORKSHEET_ROWDIMENSIO . + data DEFAULT_COLUMN_DIMENSION type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + data DEFAULT_ROW_DIMENSION type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . + data EXCEL type ref to ZCL_EXCEL . + data TABLES type ref to CL_OBJECT_COLLECTION . + + methods UPDATE_DIMENSION_RANGE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + method ADD_NEW_CONDITIONAL_STYLE. + + CREATE OBJECT eo_conditional_style. + conditional_styles->add( eo_conditional_style ). +endmethod. + + + + method ADD_NEW_DATA_VALIDATION. + + CREATE OBJECT eo_data_validation. + data_validations->add( eo_data_validation ). +endmethod. + + + + + + METHOD bind_table. + + DATA: + lv_row_int TYPE zexcel_cell_row, + lv_first_row TYPE zexcel_cell_row, + lv_last_row TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lt_field_catalog TYPE zexcel_t_fieldcatalog, + lv_id TYPE i, + lv_rows TYPE i, + lv_formula TYPE string, + ls_settings TYPE zexcel_s_table_settings, + lo_table TYPE REF TO zcl_excel_table, + lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line, + lv_value TYPE string, + lv_syindex TYPE char3. + + CONSTANTS: + lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'B', + lc_top_left_row TYPE zexcel_cell_row VALUE '3'. + + FIELD-SYMBOLS: <ls_field_catalog> TYPE zexcel_s_fieldcatalog, + <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY. + + ls_settings = is_table_settings. + + IF ls_settings-top_left_column IS INITIAL. + ls_settings-top_left_column = lc_top_left_column. + ENDIF. + + IF ls_settings-table_style IS INITIAL. + ls_settings-table_style = zcl_excel_table=>builtinstyle_medium2. + ENDIF. + + IF ls_settings-top_left_row IS INITIAL. + ls_settings-top_left_row = lc_top_left_row. + ENDIF. + + IF it_field_catalog IS NOT SUPPLIED. + lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = ip_table ). + ELSE. + lt_field_catalog = it_field_catalog. + ENDIF. + + CREATE OBJECT lo_table. + lo_table->settings = ls_settings. + lo_table->set_data( ir_data = ip_table ). + lv_id = me->excel->get_next_table_id( ). + lo_table->set_id( iv_id = lv_id ). +* lo_table->fieldcat = lt_field_catalog[]. + + me->tables->add( lo_table ). + + lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ). + lv_row_int = ls_settings-top_left_row. + + " get the row number + DESCRIBE TABLE ip_table LINES lv_rows. + +* It is better to loop column by column (only visible column) + LOOP AT lt_field_catalog ASSIGNING <ls_field_catalog> WHERE dynpfld EQ abap_true. + + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + + " Due restrinction of new table object we cannot have two column with the same name + " Check if a column with the same name exists, if exists add a counter + lv_value = <ls_field_catalog>-scrtext_m. + WHILE 1 = 1. + READ TABLE lt_column_name_buffer TRANSPORTING NO FIELDS WITH KEY table_line = lv_value BINARY SEARCH. + IF sy-subrc <> 0. + <ls_field_catalog>-scrtext_m = lv_value. + INSERT lv_value INTO TABLE lt_column_name_buffer. + EXIT. + ELSE. + lv_syindex = sy-index. + CONCATENATE <ls_field_catalog>-scrtext_m lv_syindex INTO lv_value. + ENDIF. + ENDWHILE. + " First of all write column header + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_value ). + + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <ls_field_catalog>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = <fs_fldval> + ). + ADD 1 TO lv_row_int. + ENDLOOP. + + " totals + IF <ls_field_catalog>-totals_function IS NOT INITIAL. + lv_formula = lo_table->get_totals_formula( ip_column = <ls_field_catalog>-scrtext_m ip_function = <ls_field_catalog>-totals_function ). + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = lv_formula ). + ENDIF. + + lv_row_int = ls_settings-top_left_row. + ADD 1 TO lv_column_int. + + " conditional formatting + IF <ls_field_catalog>-cond_style IS NOT INITIAL. + lv_first_row = ls_settings-top_left_row + 1. " +1 to exclude header + lv_last_row = ls_settings-top_left_row + lv_rows. + <ls_field_catalog>-cond_style->set_range( ip_start_column = lv_column_alpha + ip_start_row = lv_first_row + ip_stop_column = lv_column_alpha + ip_stop_row = lv_last_row ). + ENDIF. + ENDLOOP. + + " Set field catalog + lo_table->fieldcat = lt_field_catalog[]. + +ENDMETHOD. + + + + + method CONSTRUCTOR. + + me->excel = ip_excel. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + sheet_state = me->c_sheet_state_visible. + + CREATE OBJECT sheet_setup. + CREATE OBJECT conditional_styles. + CREATE OBJECT data_validations. + CREATE OBJECT tables. + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +endmethod. + + + method DELETE_MERGE. + + DELETE sheet_content_merge INDEX 1. + DELETE sheet_content_merge INDEX 1. + +endmethod. + + + + method GET_ACTIVE_CELL. + + DATA: lv_active_column TYPE zexcel_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = zcl_excel_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + +endmethod. + + + + + + + method GET_CELL. + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = ip_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. +endmethod. + + + + + method GET_COLUMN_DIMENSION. + FIELD-SYMBOLS: <fs_column_dimension> LIKE LINE OF column_dimensions. + + READ TABLE me->column_dimensions ASSIGNING <fs_column_dimension> + WITH KEY column = ip_column. + + IF NOT <fs_column_dimension> IS ASSIGNED. + CREATE OBJECT r_column_dimension + EXPORTING + ip_index = ip_column. + APPEND INITIAL LINE TO me->column_dimensions ASSIGNING <fs_column_dimension>. + <fs_column_dimension>-column = ip_column. + <fs_column_dimension>-column_dimension = r_column_dimension. + ELSE. + r_column_dimension = <fs_column_dimension>-column_dimension. + ENDIF. + +endmethod. + + + + method GET_COLUMN_DIMENSIONS. + r_column_dimension[] = me->column_dimensions[]. +endmethod. + + + + method GET_COND_STYLES_ITERATOR. + + eo_iterator = me->conditional_styles->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_ITERATOR. + + eo_iterator = me->data_validations->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_SIZE. + ep_size = me->data_validations->size( ). +endmethod. + + + + method GET_DEFAULT_COLUMN_DIMENSION. + r_column_dimension = me->default_column_dimension. +endmethod. + + + + method GET_DEFAULT_ROW_DIMENSION. + r_row_dimension = me->default_row_dimension. +endmethod. + + + + method GET_DIMENSION_RANGE. + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + ep_dimension_range = upper_cell-cell_coords. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + +endmethod. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + method GET_HIGHEST_COLUMN. + me->update_dimension_range( ). + r_highest_column = me->lower_cell-cell_column. +endmethod. + + + + method GET_HIGHEST_ROW. + me->update_dimension_range( ). + r_highest_row = me->lower_cell-cell_row. +endmethod. + + + + method GET_MERGE. + + DATA: lv_column_start TYPE string, + lv_column_end TYPE string, + lv_row TYPE string, + lv_index TYPE sy-tabix, + ls_sheet_content TYPE zexcel_s_cell_data, + range_from TYPE string, + range_to TYPE string, + lv_merge_range TYPE string, + lv_count TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + DESCRIBE TABLE sheet_content_merge LINES lv_count. + + WHILE lv_count GT lv_index. +* LOOP AT sheet_content_merge ASSIGNING <fs_sheet_content>. + lv_index = lv_index + 1. + READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX lv_index. + lv_column_start = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). + lv_row = <fs_sheet_content>-cell_row. + SHIFT lv_column_start RIGHT DELETING TRAILING space. + SHIFT lv_column_start LEFT DELETING LEADING space. + SHIFT lv_row RIGHT DELETING TRAILING space. + SHIFT lv_row LEFT DELETING LEADING space. + CONCATENATE lv_column_start lv_row + INTO range_from. + + lv_index = lv_index + 1. + READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX lv_index. + lv_column_end = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). + SHIFT lv_column_end RIGHT DELETING TRAILING space. + SHIFT lv_column_end LEFT DELETING LEADING space. + CONCATENATE lv_column_end lv_row + INTO range_to. + + CONCATENATE range_from range_to INTO lv_merge_range + SEPARATED BY ':'. + APPEND lv_merge_range TO merge_range. + ENDWHILE. +* ENDLOOP. + +* READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX 1. +* IF sy-subrc EQ 0 AND <fs_sheet_content> IS ASSIGNED. +* lv_column_start = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). +* lv_row = <fs_sheet_content>-cell_row. +* SHIFT lv_column_start RIGHT DELETING TRAILING space. +* SHIFT lv_column_start LEFT DELETING LEADING space. +* SHIFT lv_row RIGHT DELETING TRAILING space. +* SHIFT lv_row LEFT DELETING LEADING space. +* CONCATENATE lv_column_start lv_row +* INTO range_from. +* ENDIF. +* READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX 2. +* IF sy-subrc EQ 0 AND <fs_sheet_content> IS ASSIGNED. +* lv_column_end = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). +* SHIFT lv_column_end RIGHT DELETING TRAILING space. +* SHIFT lv_column_end LEFT DELETING LEADING space. +* CONCATENATE lv_column_end lv_row +* INTO range_to. +* ENDIF. + +* IF range_from NE space AND range_to NE space. +* CONCATENATE range_from range_to INTO ep_merge_range +* SEPARATED BY ':'. +* ENDIF. + +endmethod. + + + + + method GET_ROW_DIMENSION. + FIELD-SYMBOLS: <fs_row_dimension> LIKE LINE OF row_dimensions. + + READ TABLE me->row_dimensions ASSIGNING <fs_row_dimension> + WITH KEY row = ip_row. + + IF NOT <fs_row_dimension> IS ASSIGNED. + CREATE OBJECT r_row_dimension + EXPORTING + ip_index = ip_row. + APPEND INITIAL LINE TO me->row_dimensions ASSIGNING <fs_row_dimension>. + <fs_row_dimension>-row = ip_row. + <fs_row_dimension>-row_dimension = r_row_dimension. + ELSE. + r_row_dimension = <fs_row_dimension>-row_dimension. + ENDIF. + +endmethod. + + + + method GET_ROW_DIMENSIONS. + r_row_dimension[] = me->row_dimensions[]. +endmethod. + + + + method GET_TABLES_ITERATOR. + eo_iterator = tables->get_iterator( ). +endmethod. + + + + method GET_TABLES_SIZE. + ep_size = tables->size( ). +endmethod. + + + + + + + + method SET_CELL. + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string, + lv_value TYPE zexcel_cell_value, + lv_data_type TYPE zexcel_cell_data_type, + lv_value_type TYPE abap_typekind, + lo_style TYPE REF TO zcl_excel_style, + lv_style_guid TYPE zexcel_cell_style. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + IF ip_value IS NOT SUPPLIED AND ip_formula IS NOT SUPPLIED. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Pleas provide the vaue or formula'. + ENDIF. + + lv_style_guid = ip_style. + + IF ip_value IS SUPPLIED. + DESCRIBE FIELD ip_value TYPE lv_value_type. + CASE lv_value_type. + WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2 OR + cl_abap_typedescr=>typekind_float OR cl_abap_typedescr=>typekind_packed. + lv_value = zcl_excel_common=>number_to_excel_string( ip_value = ip_value ). + + WHEN cl_abap_typedescr=>typekind_char OR cl_abap_typedescr=>typekind_string OR cl_abap_typedescr=>typekind_num. + lv_value = ip_value. + lv_data_type = 's'. + + WHEN cl_abap_typedescr=>typekind_date. + lv_value = zcl_excel_common=>date_to_excel_string( ip_value = ip_value ). + + IF ip_style IS NOT SUPPLIED. "get default date format for user in case parameter is initial + lo_style = excel->add_new_style( ). + cl_abap_datfm=>get_date_format_des( IMPORTING ex_dateformat = lo_style->number_format->format_code ). + lv_style_guid = lo_style->get_guid( ). + ENDIF. + + WHEN cl_abap_typedescr=>typekind_time. + lv_value = zcl_excel_common=>time_to_excel_string( ip_value = ip_value ). + + IF ip_style IS NOT SUPPLIED. "get default time format for user in case parameter is initial + lo_style = excel->add_new_style( ). + lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_date_time6. + lv_style_guid = lo_style->get_guid( ). + ENDIF. + + WHEN OTHERS. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Invalid data type of input value'. + ENDCASE. + ENDIF. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_value = lv_value. + <fs_sheet_content>-cell_formula = ip_formula. + <fs_sheet_content>-cell_style = lv_style_guid. + <fs_sheet_content>-data_type = lv_data_type. + ELSE. + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column. + ls_sheet_content-cell_value = lv_value. + ls_sheet_content-cell_formula = ip_formula. + ls_sheet_content-cell_style = lv_style_guid. + ls_sheet_content-data_type = lv_data_type. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content. + SORT sheet_content BY cell_row cell_column. + " me->update_dimension_range( ). + + ENDIF. + +endmethod. + + + + + + + method SET_CELL_STYLE. + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string, + lo_style TYPE REF TO zcl_excel_style, + lv_style_guid TYPE zexcel_cell_style. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_style_guid = ip_style. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_style = lv_style_guid. + ELSE. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'No Data in this cell'. + ENDIF. + +endmethod. + + + + + + method SET_MERGE. + + DATA: lv_column_start TYPE zexcel_cell_column, + lv_column_end TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column_start = zcl_excel_common=>convert_column2int( ip_column_start ). + lv_column_end = zcl_excel_common=>convert_column2int( ip_column_end ). + + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column_start. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column_start lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content_merge. + + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column_end. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column_end lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content_merge. + +endmethod. + + + + + + + + + method SET_TABLE. + + DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, + lr_data TYPE REF TO data, + ls_newline TYPE REF TO data, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + lv_row_header TYPE zexcel_cell_row VALUE '2', + lv_col_header TYPE zexcel_cell_column_alpha VALUE 'B', + lv_row_int TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lv_cell_value TYPE zexcel_cell_value. + + + FIELD-SYMBOLS: <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY, + <fs_dfies> TYPE dfies, + <fs_cell_value> TYPE zexcel_cell_value. + + lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). + lv_row_int = ip_top_left_row. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + +* It is better to loop column by column + LOOP AT lt_dfies ASSIGNING <fs_dfies>. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + " First of all write column header + lv_cell_value = <fs_dfies>-scrtext_m. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_hdr_style ). + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <fs_dfies>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + MOVE <fs_fldval> TO lv_cell_value. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_body_style ). + ADD 1 TO lv_row_int. + ENDLOOP. + lv_row_int = ip_top_left_row. + ADD 1 TO lv_column_int. + ENDLOOP. + +endmethod. + + + method UPDATE_DIMENSION_RANGE. + + DATA: ls_sheet_content TYPE zexcel_s_cell_data, + lt_sheet_content TYPE zexcel_t_cell_data_unsorted, + lv_row_alpha TYPE string, + lv_column_alpha TYPE zexcel_cell_column_alpha. + +* update dimension range + lt_sheet_content = sheet_content. + "upper left corner + SORT lt_sheet_content BY cell_row. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = upper_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( upper_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO upper_cell-cell_coords. + + "bottom right corner + SORT lt_sheet_content BY cell_row DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = lower_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lower_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. + +endmethod. + + + diff --git a/nuggs/NUGG_ABAP2XLSX_V_1_0.nugg.zip b/nuggs/NUGG_ABAP2XLSX_V_1_0.nugg.zip new file mode 100644 index 0000000..c9c763e Binary files /dev/null and b/nuggs/NUGG_ABAP2XLSX_V_1_0.nugg.zip differ diff --git a/nuggs/NUGG_ABAP2XLSX_V_1_1.nugg b/nuggs/NUGG_ABAP2XLSX_V_1_1.nugg new file mode 100644 index 0000000..c7240fb --- /dev/null +++ b/nuggs/NUGG_ABAP2XLSX_V_1_1.nugg @@ -0,0 +1,8789 @@ + + + + class ZCL_EXCEL_PROPERTIES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +public section. + + data CREATOR type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data LASTMODIFIEDBY type ZEXCEL_CREATOR value 'Unknown Creator'. "#EC NOTEXT . + data CREATED type TIMESTAMPL . + data MODIFIED type TIMESTAMPL . + data TITLE type ZEXCEL_TITLE value 'Untitled Spreadsheet'. "#EC NOTEXT . + data SUBJECT type ZEXCEL_SUBJECT . + data DESCRIPTION type ZEXCEL_DESCRIPTION . + data KEYWORDS type ZEXCEL_KEYWORDS . + data CATEGORY type ZEXCEL_CATEGORY . + data COMPANY type ZEXCEL_COMPANY value 'Microsoft Corporation'. "#EC NOTEXT . + data APPLICATION type ZEXCEL_APPLICATION value 'Microsoft Excel'. "#EC NOTEXT . + data DOCSECURITY type ZEXCEL_DOCSECURITY value '0'. "#EC NOTEXT . + data SCALECROP type ZEXCEL_SCALECROP value ''. "#EC NOTEXT . + data LINKSUPTODATE type FLAG . + data SHAREDDOC type FLAG . + data HYPERLINKSCHANGED type FLAG . + data APPVERSION type ZEXCEL_APPVERSION value '12.0000'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_PROPERTIES +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_PROPERTIES +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + + DATA: lv_timestamp TYPE timestampl. + + GET TIME STAMP FIELD lv_timestamp. + created = lv_timestamp. + modified = lv_timestamp. + +endmethod. + + + + class ZCL_EXCEL_STYLE_COLOR definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +public section. + + class-data C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT . + class-data C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT . + class-data C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT . + class-data C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT . + class-data C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT . + class-data C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT . + class-data C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT . + class-data C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT . + class-data C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT . + class-data C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT . + class-data C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT . + + methods CONSTRUCTOR . + class-methods CREATE_NEW_ARGB + importing + !IP_RED type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_GREEN type ZEXCEL_STYLE_COLOR_COMPONENT + !IP_BLU type ZEXCEL_STYLE_COLOR_COMPONENT + returning + value(EP_COLOR_ARGB) type ZEXCEL_STYLE_COLOR_ARGB . + *"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +private section. + + class-data C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +endmethod. + + + + + + + method CREATE_NEW_ARGB. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CONCATENATE zcl_excel_style_color=>c_alpha ip_red ip_green ip_blu INTO ep_color_argb. + +endmethod. + + + + class ZCL_EXCEL_DRAWINGS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +private section. + + data DRAWINGS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->add( ip_drawing ). +endmethod. + + + method CLEAR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->clear( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT drawings. + +endmethod. + + + + + method GET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_drawing ?= drawings->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= drawings->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = drawings->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + drawings->remove( ip_drawing ). +endmethod. + + + + method SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = drawings->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_DRAWING definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + data X_REFERENCES type CHAR1 . + data Y_REFERENCES type CHAR1 . + data GRAPH_TYPE type ZEXCEL_GRAPH_TYPE . + + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_GUID + returning + value(EP_GUID) type GUID_16 . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! +private section. + + data GUID type GUID_16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + constants C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT + + methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + method CONSTRUCTOR. + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +endmethod. + + + + + method CONVERT_COLUMN2ALPHA. + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +endmethod. + + + + + method CONVERT_COLUMN2INT. + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( me->c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( me->c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - me->c_excel_col_module. + ENDIF. + +endmethod. + + + + method GET_GUID. + + ep_guid = me->guid. + +endmethod. + + + + class ZCL_EXCEL_STYLES_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_STYLE_CONDITIONAL) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE_CONDITIONAL type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data STYLES_CONDITIONAL type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + styles_conditional->add( ip_style_conditional ). +endmethod. + + + method CLEAR. + styles_conditional->clear( ). +endmethod. + + + method CONSTRUCTOR. + + CREATE OBJECT styles_conditional. + +endmethod. + + + + + method GET. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_style_conditional ?= styles_conditional->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= styles_conditional->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = styles_conditional->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + styles_conditional->remove( ip_style_conditional ). +endmethod. + + + + method SIZE. + ep_size = styles_conditional->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_COMMON definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +public section. + + class-methods CONVERT_COLUMN2ALPHA + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . + class-methods CONVERT_COLUMN2INT + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + returning + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + *"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +private section. + + class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + method CONVERT_COLUMN2ALPHA. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, + lv_uccpi TYPE i, + lv_text TYPE sychar02, + lv_module TYPE int4, + lv_column TYPE zexcel_cell_column. + + lv_column = ip_column. + WHILE lv_column GT 0. + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + ENDWHILE. + +endmethod. + + + + + method CONVERT_COLUMN2INT. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_uccpi TYPE i, + lv_char TYPE c, + lv_column(2) TYPE c. + +* Calculate most significant letter + lv_char = ip_column+1(1). + IF lv_char IS NOT INITIAL. "To avoid the first 26 column that have only a char in first position + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + + ep_column = ep_column MOD ( zcl_excel_common=>c_excel_col_module ). + + lv_char = ip_column(1). + lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). + + lv_uccpi = ( lv_uccpi MOD ( zcl_excel_common=>c_excel_col_module ) ) * 26. + + ep_column = ep_column + lv_uccpi. + ELSE. + lv_char = ip_column(1). + ep_column = cl_abap_conv_out_ce=>uccpi( lv_char ). + ep_column = ep_column - zcl_excel_common=>c_excel_col_module. + ENDIF. + +endmethod. + + + + class ZCL_EXCEL_SECURITY definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SECURITY +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data LOCKREVISION type FLAG . + data LOCKSTRUCTURE type FLAG . + data LOCKWINDOWS type FLAG . + data REVISIONSPASSWORD type ZEXCEL_REVISIONSPASSWORD . + data WORKBOOKPASSWORD type ZEXCEL_WORKBOOKPASSWORD . + + methods CONSTRUCTOR . + methods IS_SECURITY_ENABLED + returning + value(EP_SECURITY_ENABLED) type FLAG . + *"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + method CONSTRUCTOR. +endmethod. + + + + method IS_SECURITY_ENABLED. + IF lockrevision EQ abap_true OR lockstructure EQ abap_true OR lockwindows EQ abap_true. + ep_security_enabled = abap_true. + ENDIF. +endmethod. + + + + class ZCL_EXCEL_WORKSHEETS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +public section. + + data ACTIVE_WORKSHEET type ZEXCEL_ACTIVE_WORKSHEET value 1. "#EC NOTEXT . + data NAME type ZEXCEL_WORKSHEETS_NAME value 'Worksheets'. "#EC NOTEXT . + + methods ADD + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type ZEXCEL_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +private section. + + data WORKSHEETS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + method ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->add( ip_worksheet ). +endmethod. + + + method CLEAR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->clear( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT worksheets. + +endmethod. + + + + + method GET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_worksheet ?= worksheets->if_object_collection~get( lv_index ). +endmethod. + + + + method GET_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= worksheets->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = worksheets->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + worksheets->remove( ip_worksheet ). +endmethod. + + + + method SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = worksheets->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_RANGES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_RANGE type ref to ZCL_EXCEL_RANGE . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! +private section. + + data RANGES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. + ranges->add( ip_range ). +endmethod. + + + method CLEAR. + ranges->clear( ). +endmethod. + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT ranges. + +ENDMETHOD. + + + + + method GET. + eo_range ?= ranges->if_object_collection~get( ip_index ). +endmethod. + + + + method GET_ITERATOR. + eo_iterator ?= ranges->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. + is_empty = ranges->if_object_collection~is_empty( ). +endmethod. + + + + method REMOVE. + ranges->remove( ip_range ). +endmethod. + + + + method SIZE. + ep_size = ranges->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_STYLES definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +public section. + + methods ADD + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_STYLE type ref to ZCL_EXCEL_STYLE . + methods SIZE + returning + value(EP_SIZE) type I . + methods REGISTER_NEW_STYLE + importing + !IO_STYLE type ref to ZCL_EXCEL_STYLE + returning + value(EP_STYLE_CODE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! +private section. + + data STYLES type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + method ADD. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->add( ip_style ). +endmethod. + + + method CLEAR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->clear( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT styles. +endmethod. + + + + + method GET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_style ?= styles->if_object_collection~get( ip_index ). +endmethod. + + + + method GET_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator ?= styles->if_object_collection~get_iterator( ). +endmethod. + + + + method IS_EMPTY. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + is_empty = styles->if_object_collection~is_empty( ). +endmethod. + + + + + method REGISTER_NEW_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->add( io_style ). + ep_style_code = me->size( ) - 1. "style count starts from 0 +endmethod. + + + + method REMOVE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + styles->remove( ip_style ). +endmethod. + + + + method SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = styles->if_object_collection~size( ). +endmethod. + + + + class ZCL_EXCEL_RANGE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +public section. + + data NAME type ZEXCEL_RANGE_NAME . + data GUID type ZEXCEL_RANGE_GUID . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_RANGE_GUID . + methods SET_VALUE + importing + !IP_SHEET_NAME type ZEXCEL_SHEET_TITLE + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + methods GET_VALUE + returning + value(EP_VALUE) type ZEXCEL_RANGE_VALUE . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! +private section. + + data VALUE type ZEXCEL_RANGE_VALUE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + method CONSTRUCTOR. +endmethod. + + + + METHOD get_guid. + + ep_guid = me->guid. + +ENDMETHOD. + + + + METHOD get_value. + + ep_value = me->value. + +ENDMETHOD. + + + + + + + + METHOD set_value. + DATA: lv_start_row_c TYPE char7, + lv_stop_row_c TYPE char7. + lv_stop_row_c = ip_stop_row. + SHIFT lv_stop_row_c RIGHT DELETING TRAILING space. + SHIFT lv_stop_row_c LEFT DELETING LEADING space. + lv_start_row_c = ip_start_row. + SHIFT lv_start_row_c RIGHT DELETING TRAILING space. + SHIFT lv_start_row_c LEFT DELETING LEADING space. + CONCATENATE ip_sheet_name '!$' ip_start_column '$' lv_start_row_c ':$' ip_stop_column '$' lv_stop_row_c INTO me->value. +ENDMETHOD. + + + + class ZCL_EXCEL_STYLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +public section. + + data FONT type ref to ZCL_EXCEL_STYLE_FONT . + data FILL type ref to ZCL_EXCEL_STYLE_FILL . + data BORDERS type ref to ZCL_EXCEL_STYLE_BORDERS . + data NUMBER_FORMAT type ref to ZCL_EXCEL_STYLE_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_GUID + returning + value(EP_GUID) type ZEXCEL_CELL_STYLE . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! +private section. + + data ALIGNMENT type ref to ZCL_EXCEL_STYLE_ALIGNMENT . + data PROTECTION type ref to ZCL_EXCEL_STYLE_PROTECTION . + data GUID type ZEXCEL_CELL_STYLE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT font. + CREATE OBJECT fill. + CREATE OBJECT borders. + CREATE OBJECT alignment. + CREATE OBJECT number_format. + CREATE OBJECT protection. + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + +endmethod. + + + + method GET_GUID. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. +endmethod. + + + + class ZCL_EXCEL_STYLE_BORDER definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +public section. + + data BORDER_STYLE type ZEXCEL_BORDER . + data BORDER_COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_BORDER_NONE type ZEXCEL_BORDER value 'none'. "#EC NOTEXT . + class-data C_BORDER_DASHDOT type ZEXCEL_BORDER value 'dashDot'. "#EC NOTEXT . + class-data C_BORDER_DASHDOTDOT type ZEXCEL_BORDER value 'dashDotDot'. "#EC NOTEXT . + class-data C_BORDER_DASHED type ZEXCEL_BORDER value 'dashed'. "#EC NOTEXT . + class-data C_BORDER_DOTTED type ZEXCEL_BORDER value 'dotted'. "#EC NOTEXT . + class-data C_BORDER_DOUBLE type ZEXCEL_BORDER value 'double'. "#EC NOTEXT . + class-data C_BORDER_HAIR type ZEXCEL_BORDER value 'hair'. "#EC NOTEXT . + class-data C_BORDER_MEDIUM type ZEXCEL_BORDER value 'medium'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOT type ZEXCEL_BORDER value 'mediumDashDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHDOTDOT type ZEXCEL_BORDER value 'mediumDashDotDot'. "#EC NOTEXT . + class-data C_BORDER_MEDIUMDASHED type ZEXCEL_BORDER value 'mediumDashed'. "#EC NOTEXT . + class-data C_BORDER_SLANTDASHDOT type ZEXCEL_BORDER value 'slantDashDot'. "#EC NOTEXT . + class-data C_BORDER_THICK type ZEXCEL_BORDER value 'thick'. "#EC NOTEXT . + class-data C_BORDER_THIN type ZEXCEL_BORDER value 'thin'. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + border_style = zcl_excel_style_border=>c_border_none. +endmethod. + + + + class ZCL_EXCEL_SHEET_SETUP definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants C_PAPERSIZE_LETTER type ZEXCEL_SHEET_PAPER_SIZE value 1. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 2. "#EC NOTEXT + constants C_PAPERSIZE_TABLOID type ZEXCEL_SHEET_PAPER_SIZE value 3. "#EC NOTEXT + constants C_PAPERSIZE_LEDGER type ZEXCEL_SHEET_PAPER_SIZE value 4. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL type ZEXCEL_SHEET_PAPER_SIZE value 5. "#EC NOTEXT + constants C_PAPERSIZE_STATEMENT type ZEXCEL_SHEET_PAPER_SIZE value 6. "#EC NOTEXT + constants C_PAPERSIZE_EXECUTIVE type ZEXCEL_SHEET_PAPER_SIZE value 7. "#EC NOTEXT + constants C_PAPERSIZE_A3 type ZEXCEL_SHEET_PAPER_SIZE value 8. "#EC NOTEXT + constants C_PAPERSIZE_A4 type ZEXCEL_SHEET_PAPER_SIZE value 9. "#EC NOTEXT + constants C_PAPERSIZE_A4_SMALL type ZEXCEL_SHEET_PAPER_SIZE value 10. "#EC NOTEXT + constants C_PAPERSIZE_A5 type ZEXCEL_SHEET_PAPER_SIZE value 11. "#EC NOTEXT + constants C_PAPERSIZE_B4 type ZEXCEL_SHEET_PAPER_SIZE value 12. "#EC NOTEXT + constants C_PAPERSIZE_B5 type ZEXCEL_SHEET_PAPER_SIZE value 13. "#EC NOTEXT + constants C_PAPERSIZE_FOLIO type ZEXCEL_SHEET_PAPER_SIZE value 14. "#EC NOTEXT + constants C_PAPERSIZE_QUARTO type ZEXCEL_SHEET_PAPER_SIZE value 15. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_1 type ZEXCEL_SHEET_PAPER_SIZE value 16. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_2 type ZEXCEL_SHEET_PAPER_SIZE value 17. "#EC NOTEXT + constants C_PAPERSIZE_NOTE type ZEXCEL_SHEET_PAPER_SIZE value 18. "#EC NOTEXT + constants C_PAPERSIZE_NO9_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 19. "#EC NOTEXT + constants C_PAPERSIZE_NO10_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 20. "#EC NOTEXT + constants C_PAPERSIZE_NO11_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 21. "#EC NOTEXT + constants C_PAPERSIZE_NO12_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 22. "#EC NOTEXT + constants C_PAPERSIZE_NO14_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 23. "#EC NOTEXT + constants C_PAPERSIZE_C type ZEXCEL_SHEET_PAPER_SIZE value 24. "#EC NOTEXT + constants C_PAPERSIZE_D type ZEXCEL_SHEET_PAPER_SIZE value 25. "#EC NOTEXT + constants C_PAPERSIZE_E type ZEXCEL_SHEET_PAPER_SIZE value 26. "#EC NOTEXT + constants C_PAPERSIZE_DL_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 27. "#EC NOTEXT + constants C_PAPERSIZE_C5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 28. "#EC NOTEXT + constants C_PAPERSIZE_C3_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 29. "#EC NOTEXT + constants C_PAPERSIZE_C4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 30. "#EC NOTEXT + constants C_PAPERSIZE_C6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 31. "#EC NOTEXT + constants C_PAPERSIZE_C65_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 32. "#EC NOTEXT + constants C_PAPERSIZE_B4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 33. "#EC NOTEXT + constants C_PAPERSIZE_B5_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 34. "#EC NOTEXT + constants C_PAPERSIZE_B6_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 35. "#EC NOTEXT + constants C_PAPERSIZE_ITALY_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 36. "#EC NOTEXT + constants C_PAPERSIZE_MONARCH_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 37. "#EC NOTEXT + constants C_PAPERSIZE_6_3_4_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 38. "#EC NOTEXT + constants C_PAPERSIZE_US_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 39. "#EC NOTEXT + constants C_PAPERSIZE_DE_STD_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 40. "#EC NOTEXT + constants C_PAPERSIZE_DE_LEG_FANFOLD type ZEXCEL_SHEET_PAPER_SIZE value 41. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B4 type ZEXCEL_SHEET_PAPER_SIZE value 42. "#EC NOTEXT + constants C_PAPERSIZE_JPN_DBL_POSTCARD type ZEXCEL_SHEET_PAPER_SIZE value 43. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_1 type ZEXCEL_SHEET_PAPER_SIZE value 44. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_2 type ZEXCEL_SHEET_PAPER_SIZE value 45. "#EC NOTEXT + constants C_PAPERSIZE_STANDARD_PAPER_3 type ZEXCEL_SHEET_PAPER_SIZE value 46. "#EC NOTEXT + constants C_PAPERSIZE_INVITE_ENVELOPE type ZEXCEL_SHEET_PAPER_SIZE value 47. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 48. "#EC NOTEXT + constants C_PAPERSIZE_LEGAL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 49. "#EC NOTEXT + constants C_PAPERSIZE_TABL_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 50. "#EC NOTEXT + constants C_PAPERSIZE_A4_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 51. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 52. "#EC NOTEXT + constants C_PAPERSIZE_A4_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 53. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_EXTV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 54. "#EC NOTEXT + constants C_PAPERSIZE_SUPERA_A4_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 55. "#EC NOTEXT + constants C_PAPERSIZE_SUPERB_A3_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 56. "#EC NOTEXT + constants C_PAPERSIZE_LETTER_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 57. "#EC NOTEXT + constants C_PAPERSIZE_A4_PLUS_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 58. "#EC NOTEXT + constants C_PAPERSIZE_A5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 59. "#EC NOTEXT + constants C_PAPERSIZE_JIS_B5_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 60. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 61. "#EC NOTEXT + constants C_PAPERSIZE_A5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 62. "#EC NOTEXT + constants C_PAPERSIZE_ISO_B5_EXTRA_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 63. "#EC NOTEXT + constants C_PAPERSIZE_A2_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 64. "#EC NOTEXT + constants C_PAPERSIZE_A3_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 65. "#EC NOTEXT + constants C_PAPERSIZE_A3_EXTRA_TV_PAPER type ZEXCEL_SHEET_PAPER_SIZE value 66. "#EC NOTEXT + constants C_ORIENTATION_DEFAULT type ZEXCEL_SHEET_ORIENATATION value 'default'. "#EC NOTEXT + constants C_ORIENTATION_LANDSCAPE type ZEXCEL_SHEET_ORIENATATION value 'landscape'. "#EC NOTEXT + constants C_ORIENTATION_PORTRAIT type ZEXCEL_SHEET_ORIENATATION value 'portrait'. "#EC NOTEXT + data ORIENTATION type ZEXCEL_SHEET_ORIENATATION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + orientation = me->c_orientation_default. +endmethod. + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + methods CONSTRUCTOR + importing + !IO_EXCEL type ref to ZCL_EXCEL . + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_CALCCHAIN type STRING value 'xl/calcChain.xml'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_CALCCHAIN + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->excel = io_excel. +endmethod. + + + + method CREATE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sharedStrings.xml to zip + lv_content = me->create_xl_calcchain( ). + lo_zip->add( name = me->c_xl_calcchain + content = lv_content ). + +********************************************************************** +* STEP 11: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +endmethod. + + + + method CREATE_CONTENT_TYPES. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lv_xml_node_worksheet_pn ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_APP. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_CORE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_RELATIONSHIPS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_CALCCHAIN. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_calcchain TYPE string VALUE 'calcChain', + lc_xml_node_c TYPE string VALUE 'c', + " Node attributes + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_i TYPE string VALUE 'i', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string, + lv_value_i TYPE string, + lv_sheets_count TYPE i. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create xl/calcChain.xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node calcChain + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_calcchain + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + ADD 1 TO lv_sheets_count. + MOVE lv_sheets_count TO lv_value_i. + SHIFT lv_value_i RIGHT DELETING TRAILING space. + SHIFT lv_value_i LEFT DELETING LEADING space. + LOOP AT lo_worksheet->sheet_content ASSIGNING <ls_sheet_content> WHERE cell_formula IS NOT INITIAL. + " formula chain node + lo_element = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_i + value = lv_value_i ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_RELATIONSHIPS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + lc_xml_node_rid_calcchain_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml', + lc_xml_node_rid_calcchain_tg TYPE string VALUE 'calcChain.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 1 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_calcchain_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_calcchain_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_SHAREDSTRINGS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + + METHOD create_xl_sheet. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + lc_xml_node_datavalidations TYPE string VALUE 'dataValidations', + lc_xml_node_datavalidation TYPE string VALUE 'dataValidation', + lc_xml_node_formula1 TYPE string VALUE 'formula1', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + lc_xml_attr_allowblank TYPE string VALUE 'allowBlank', + lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage', + lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_data_validation TYPE REF TO zcl_excel_data_validation. + + DATA: lv_value TYPE string, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + lv_cell_row_s TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + lv_value = io_worksheet->defaultrowheight. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + lo_element_root->append_child( lo_element ). " sheetFormatPr node + + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = '1:1' ). " <******************************* + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + IF ls_style_mapping-cell_format IS INITIAL. " to avoid errors if no style has been created + IF <ls_sheet_content>-cell_formula IS INITIAL. + ls_style_mapping-cell_format = 'S'. + ELSE. + ls_style_mapping-cell_format = 'F'. + ENDIF. + ENDIF. + " is a shared string and is not a formula + IF ls_style_mapping-cell_format EQ 'S'. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = 's' ). + ENDIF. + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ENDIF. + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF ls_style_mapping-cell_format EQ 'S'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + + + IF io_worksheet->get_data_validations_size( ) GT 0. + " dataValidations node + lo_element = lo_document->create_simple_element( name = lc_xml_node_datavalidations + parent = lo_document ). + " Conditional formatting node + lo_iterator = io_worksheet->get_data_validations_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_data_validation ?= lo_iterator->get_next( ). + " dataValidation node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_datavalidation + parent = lo_document ). + lv_value = lo_data_validation->type. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + IF lo_data_validation->allowblank EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_allowblank + value = lv_value ). + IF lo_data_validation->showinputmessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showinputmessage + value = lv_value ). + IF lo_data_validation->showerrormessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showerrormessage + value = lv_value ). + lv_cell_row_s = lo_data_validation->cell_row. + SHIFT lv_cell_row_s RIGHT DELETING TRAILING space. + SHIFT lv_cell_row_s LEFT DELETING LEADING space. + CONCATENATE lo_data_validation->cell_column lv_cell_row_s INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + " formula1 node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula1 + parent = lo_document ). + lv_value = lo_data_validation->value. + lo_element_3->set_value( lv_value ). + + lo_element_2->append_child( lo_element_3 ). " formula1 node + + lo_element->append_child( lo_element_2 ). " dataValidation node + ENDWHILE. + lo_element_root->append_child( lo_element ). " dataValidations node + ENDIF. + + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + method CREATE_XL_SHEET_RELS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + lc_xml_node_rid_print_id TYPE string VALUE 'rId1', + " Node type + lc_xml_node_rid_print_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', + " Node target + lc_xml_node_rid_print_tg TYPE string VALUE '../printerSettings/printerSettings1.bin'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rid_print_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_print_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_print_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_STYLES. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + ls_format TYPE zexcel_number_format, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_format = lo_style->number_format->get_structure( ). + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + + IF ls_format IS INITIAL. + ls_cellxfs-numfmtid = 0. " number format + ELSE. + ls_cellxfs-numfmtid = ls_format. " number format + ENDIF. + ls_cellxfs-xfid = 0. + + IF ls_format IS NOT INITIAL. + ls_cellxfs-applynumberformat = 1. + ls_styles_mapping-cell_format = 'I'. + ELSE. + ls_cellxfs-applynumberformat = 0. + ls_styles_mapping-cell_format = 'S'. + ENDIF. + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + " Collect color + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = 'TableStyleMedium9' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = 'PivotStyleLight16' ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_THEME. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +endmethod. + + + + METHOD create_xl_workbook. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + lc_xml_node_definednames TYPE string VALUE 'definedNames', + lc_xml_node_definedname TYPE string VALUE 'definedName', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + + " ranges node + lo_element = lo_document->create_simple_element( name = lc_xml_node_definedNames + parent = lo_document ). + lo_iterator = excel->get_ranges_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " range node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_definedName + parent = lo_document ). + lo_range ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_range->name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lv_value = lo_range->get_value( ). + lo_sub_element->set_value( lv_value ). + lo_element->append_child( lo_sub_element ). " range node + ENDWHILE. + lo_element_root->append_child( lo_element )." ranges node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + method FLAG2BOOL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +endmethod. + + + + + method GET_SHARED_STRING_INDEX. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +endmethod. + + + + class ZCL_EXCEL_DATA_VALIDATIONS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + methods ADD + importing + !IP_DATA_VALIDATION type ref to ZCL_EXCEL_DATA_VALIDATION . + methods CLEAR . + methods CONSTRUCTOR . + methods GET_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods IS_EMPTY + returning + value(IS_EMPTY) type FLAG . + methods REMOVE + importing + !IP_DATA_VALIDATION type ref to ZCL_EXCEL_DATA_VALIDATION . + methods SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! +private section. + + data DATA_VALIDATIONS type ref to CL_OBJECT_COLLECTION . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + METHOD add. + data_validations->add( ip_data_validation ). +ENDMETHOD. + + + METHOD clear. + data_validations->clear( ). +ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT data_validations. + +ENDMETHOD. + + + + METHOD get_iterator. + eo_iterator ?= data_validations->if_object_collection~get_iterator( ). +ENDMETHOD. + + + + METHOD is_empty. + is_empty = data_validations->if_object_collection~is_empty( ). +ENDMETHOD. + + + + METHOD remove. + data_validations->remove( ip_data_validation ). +ENDMETHOD. + + + + METHOD size. + ep_size = data_validations->if_object_collection~size( ). +ENDMETHOD. + + + + class ZCL_EXCEL_DATA_VALIDATION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data ALLOWBLANK type FLAG value 'X'. "#EC NOTEXT . + data CELL_ROW type ZEXCEL_CELL_ROW . + class-data C_TYPE_LIST type ZEXCEL_DATA_VAL_TYPE value 'list'. "#EC NOTEXT . + data SHOWERRORMESSAGE type FLAG value 'X'. "#EC NOTEXT . + data SHOWINPUTMESSAGE type FLAG value 'X'. "#EC NOTEXT . + data TYPE type ZEXCEL_DATA_VAL_TYPE . + data VALUE type ZEXCEL_VALIDATION_FORMULA1 . + data CELL_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + METHOD constructor. + type = me->c_type_list. +* inizialize dimension range + cell_row = 1. + cell_column = 'A'. +ENDMETHOD. + + + + class ZCL_EXCEL_WORKSHEET definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + class-data C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT . + class-data C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT . + class-data C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT . + class-data C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT . + class-data C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT . + data DEFAULTROWHEIGHT type INT1 value 15. "#EC NOTEXT . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHEET_STATE type ZEXCEL_SHEET_STATE . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . + + methods ADD_NEW_CONDITIONAL_STYLE + returning + value(EO_CONDITIONAL_STYLE) type ref to ZCL_EXCEL_STYLE_CONDITIONAL . + methods ADD_NEW_DATA_VALIDATION + returning + value(EO_DATA_VALIDATION) type ref to ZCL_EXCEL_DATA_VALIDATION . + methods CONSTRUCTOR + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING . + methods GET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC . + methods GET_COND_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods GET_GUID + returning + value(EP_GUID) type OLTPGUID16 . + methods SET_CELL + importing + !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type ZEXCEL_CELL_VALUE + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional . + methods SET_TABLE + importing + !IP_TABLE type STANDARD TABLE + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING optional + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . + methods GET_DATA_VALIDATIONS_SIZE + returning + value(EP_SIZE) type I . + *"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +private section. + + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CONDITIONAL_STYLES type ref to ZCL_EXCEL_STYLES_CONDITIONAL . + data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . + data GUID type OLTPGUID16 . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . + + methods UPDATE_DIMENSION_RANGE . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + method ADD_NEW_CONDITIONAL_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT eo_conditional_style. + conditional_styles->add( eo_conditional_style ). +endmethod. + + + + method ADD_NEW_DATA_VALIDATION. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CREATE OBJECT eo_data_validation. + data_validations->add( eo_data_validation ). +endmethod. + + + + METHOD constructor. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + CALL FUNCTION 'GUID_CREATE' + IMPORTING + ev_guid_16 = me->guid. + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + sheet_state = me->c_sheet_state_visible. + + CREATE OBJECT sheet_setup. + CREATE OBJECT conditional_styles. + CREATE OBJECT data_validations. + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. +ENDMETHOD. + + + + method GET_ACTIVE_CELL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_active_column TYPE zexcel_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = zcl_excel_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + +endmethod. + + + + + + + method GET_CELL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = zcl_excel_common=>convert_column2int( ip_column ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = ip_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. +endmethod. + + + + method GET_COND_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->conditional_styles->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->data_validations->get_iterator( ). +endmethod. + + + + method GET_DATA_VALIDATIONS_SIZE. + ep_size = me->data_validations->size( ). +endmethod. + + + + method GET_DIMENSION_RANGE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + ep_dimension_range = upper_cell-cell_coords. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + +endmethod. + + + + method GET_GUID. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_guid = me->guid. + +endmethod. + + + + + + + + method SET_CELL. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_column TYPE zexcel_cell_column, + ls_sheet_content TYPE zexcel_s_cell_data, + lv_row_alpha TYPE string. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data. + + lv_column = ZCL_EXCEL_COMMON=>convert_column2int( ip_column ). + + READ TABLE sheet_content ASSIGNING <fs_sheet_content> WITH KEY cell_row = ip_row + cell_column = lv_column. + + IF sy-subrc EQ 0. + <fs_sheet_content>-cell_value = ip_value. + <fs_sheet_content>-cell_formula = ip_formula. + <fs_sheet_content>-cell_style = ip_style. + ELSE. + ls_sheet_content-cell_row = ip_row. + ls_sheet_content-cell_column = lv_column. + ls_sheet_content-cell_value = ip_value. + ls_sheet_content-cell_formula = ip_formula. + ls_sheet_content-cell_style = ip_style. + lv_row_alpha = ip_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_column lv_row_alpha INTO ls_sheet_content-cell_coords. + APPEND ls_sheet_content TO sheet_content. + SORT sheet_content BY cell_row cell_column. +* me->update_dimension_range( ). + + ENDIF. + +endmethod. + + + + + + + + + method SET_TABLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, + lr_data TYPE REF TO data, + ls_newline TYPE REF TO data, + ls_header TYPE x030l, + lt_dfies TYPE ddfields, + lv_row_header TYPE zexcel_cell_row VALUE '2', + lv_col_header TYPE zexcel_cell_column_alpha VALUE 'B', + lv_row_int TYPE zexcel_cell_row, + lv_column_int TYPE zexcel_cell_column, + lv_column_alpha TYPE zexcel_cell_column_alpha, + lv_cell_value TYPE zexcel_cell_value. + + + FIELD-SYMBOLS: <fs_table_line> TYPE ANY, + <fs_fldval> TYPE ANY, + <fs_dfies> TYPE dfies, + <fs_cell_value> TYPE zexcel_cell_value. + + lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). + lv_row_int = ip_top_left_row. + + CREATE DATA lr_data LIKE LINE OF ip_table. + + lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + ls_header = lo_tabdescr->get_ddic_header( ). + + lt_dfies = lo_tabdescr->get_ddic_field_list( ). + +* It is better to loop column by column + LOOP AT lt_dfies ASSIGNING <fs_dfies>. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + " First of all write column header + lv_cell_value = <fs_dfies>-scrtext_m. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_hdr_style ). + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING <fs_table_line>. + ASSIGN COMPONENT <fs_dfies>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>. + MOVE <fs_fldval> TO lv_cell_value. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = lv_cell_value + ip_style = ip_body_style ). + ADD 1 TO lv_row_int. + ENDLOOP. + lv_row_int = ip_top_left_row. + ADD 1 TO lv_column_int. + ENDLOOP. + +endmethod. + + + method UPDATE_DIMENSION_RANGE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: ls_sheet_content TYPE zexcel_s_cell_data, + lt_sheet_content TYPE zexcel_t_cell_data_unsorted, + lv_row_alpha TYPE string, + lv_column_alpha TYPE zexcel_cell_column_alpha. + +* update dimension range + lt_sheet_content = sheet_content. + "upper left corner + SORT lt_sheet_content BY cell_row. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + upper_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = upper_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( upper_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO upper_cell-cell_coords. + + "bottom right corner + SORT lt_sheet_content BY cell_row DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_row = ls_sheet_content-cell_row. + SORT lt_sheet_content BY cell_column DESCENDING. + READ TABLE lt_sheet_content INDEX 1 INTO ls_sheet_content. + lower_cell-cell_column = ls_sheet_content-cell_column. + + lv_row_alpha = lower_cell-cell_row. + lv_column_alpha = zcl_excel_common=>convert_column2alpha( lower_cell-cell_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. + +endmethod. + + + + class ZCL_EXCEL_STYLE_ALIGNMENT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data HORIZONTAL type ZEXCEL_ALIGNMENT . + data VERTICAL type ZEXCEL_ALIGNMENT . + data TEXTROTATION type ZEXCEL_TEXT_ROTATION value 0. "#EC NOTEXT . + data WRAPTEXT type FLAG . + data SHRINKTOFIT type FLAG . + data INDENT type ZEXCEL_INDENT value 0. "#EC NOTEXT . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! +private section. + + constants C_HORIZONTAL_GENERAL type ZEXCEL_ALIGNMENT value 'general'. "#EC NOTEXT + constants C_HORIZONTAL_LEFT type ZEXCEL_ALIGNMENT value 'left'. "#EC NOTEXT + constants C_HORIZONTAL_RIGHT type ZEXCEL_ALIGNMENT value 'right'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_HORIZONTAL_CENTER_CONTINUOUS type ZEXCEL_ALIGNMENT value 'centerContinuous'. "#EC NOTEXT + constants C_HORIZONTAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + constants C_VERTICAL_BOTTOM type ZEXCEL_ALIGNMENT value 'bottom'. "#EC NOTEXT + constants C_VERTICAL_TOP type ZEXCEL_ALIGNMENT value 'top'. "#EC NOTEXT + constants C_VERTICAL_CENTER type ZEXCEL_ALIGNMENT value 'center'. "#EC NOTEXT + constants C_VERTICAL_JUSTIFY type ZEXCEL_ALIGNMENT value 'justify'. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + horizontal = me->c_horizontal_general. + vertical = me->c_vertical_bottom. + wrapText = abap_false. + shrinkToFit = abap_false. +endmethod. + + + + class ZCL_EXCEL_STYLE_BORDERS definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +public section. + + data LEFT type ref to ZCL_EXCEL_STYLE_BORDER . + data RIGHT type ref to ZCL_EXCEL_STYLE_BORDER . + data TOP type ref to ZCL_EXCEL_STYLE_BORDER . + data DOWN type ref to ZCL_EXCEL_STYLE_BORDER . + data DIAGONAL type ref to ZCL_EXCEL_STYLE_BORDER . + data ALLBORDERS type ref to ZCL_EXCEL_STYLE_BORDER . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_BORDER . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! +private section. + + constants C_DIAGONAL_NONE type ZEXCEL_DIAGONAL value 0. "#EC NOTEXT + constants C_DIAGONAL_UP type ZEXCEL_DIAGONAL value 1. "#EC NOTEXT + constants C_DIAGONAL_DOWN type ZEXCEL_DIAGONAL value 2. "#EC NOTEXT + constants C_DIAGONAL_BOTH type ZEXCEL_DIAGONAL value 3. "#EC NOTEXT + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method CONSTRUCTOR. +endmethod. + + + + method GET_STRUCTURE. + +* Check if all borders is set otherwise check single border + IF me->allborders IS BOUND. + es_fill-left_color = me->allborders->border_color. + es_fill-left_style = me->allborders->border_style. + es_fill-right_color = me->allborders->border_color. + es_fill-right_style = me->allborders->border_style. + es_fill-top_color = me->allborders->border_color. + es_fill-top_style = me->allborders->border_style. + es_fill-bottom_color = me->allborders->border_color. + es_fill-bottom_style = me->allborders->border_style. + ELSE. + IF me->left IS BOUND. + es_fill-left_color = me->left->border_color. + es_fill-left_style = me->left->border_style. + ENDIF. + IF me->right IS BOUND. + es_fill-right_color = me->right->border_color. + es_fill-right_style = me->right->border_style. + ENDIF. + IF me->top IS BOUND. + es_fill-top_color = me->top->border_color. + es_fill-top_style = me->top->border_style. + ENDIF. + IF me->down IS BOUND. + es_fill-bottom_color = me->down->border_color. + es_fill-bottom_style = me->down->border_style. + ENDIF. + ENDIF. + +* Check if diagonal is set + IF me->diagonal IS BOUND. + es_fill-diagonal_color = me->diagonal->border_color. + es_fill-diagonal_style = me->diagonal->border_style. + ENDIF. + +endmethod. + + + + class ZCL_EXCEL_STYLE_CONDITIONAL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +public section. + + class-data C_ICONSET_3ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '3Arrows'. "#EC NOTEXT . + class-data C_ICONSET_3ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '3ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_3FLAGS type ZEXCEL_CONDITION_RULE_ICONSET value '3Flags'. "#EC NOTEXT . + class-data C_ICONSET_3SIGNS type ZEXCEL_CONDITION_RULE_ICONSET value '3Signs'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols'. "#EC NOTEXT . + class-data C_ICONSET_3SYMBOLS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3Symbols2'. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value ''. "#EC NOTEXT . + class-data C_ICONSET_3TRAFFICLIGHTS2 type ZEXCEL_CONDITION_RULE_ICONSET value '3TrafficLights2'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '4Arrows'. "#EC NOTEXT . + class-data C_ICONSET_4ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '4ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_4RATING type ZEXCEL_CONDITION_RULE_ICONSET value '4Rating'. "#EC NOTEXT . + class-data C_ICONSET_4REDTOBLACK type ZEXCEL_CONDITION_RULE_ICONSET value '4RedToBlack'. "#EC NOTEXT . + class-data C_ICONSET_4TRAFFICLIGHTS type ZEXCEL_CONDITION_RULE_ICONSET value '4TrafficLights'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWS type ZEXCEL_CONDITION_RULE_ICONSET value '5Arrows'. "#EC NOTEXT . + class-data C_ICONSET_5ARROWSGRAY type ZEXCEL_CONDITION_RULE_ICONSET value '5ArrowsGray'. "#EC NOTEXT . + class-data C_ICONSET_5QUARTERS type ZEXCEL_CONDITION_RULE_ICONSET value '5Quarters'. "#EC NOTEXT . + class-data C_ICONSET_5RATING type ZEXCEL_CONDITION_RULE_ICONSET value '5Rating'. "#EC NOTEXT . + class-data C_OPERATOR_BEGINSWITH type ZEXCEL_CONDITION_OPERATOR value 'beginsWith'. "#EC NOTEXT . + class-data C_OPERATOR_BETWEEN type ZEXCEL_CONDITION_OPERATOR value 'between'. "#EC NOTEXT . + class-data C_OPERATOR_CONTAINSTEXT type ZEXCEL_CONDITION_OPERATOR value 'containsText'. "#EC NOTEXT . + class-data C_OPERATOR_ENDSWITH type ZEXCEL_CONDITION_OPERATOR value 'endsWith'. "#EC NOTEXT . + class-data C_OPERATOR_EQUAL type ZEXCEL_CONDITION_OPERATOR value 'equal'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHAN type ZEXCEL_CONDITION_OPERATOR value 'greaterThan'. "#EC NOTEXT . + class-data C_OPERATOR_GREATERTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'greaterThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHAN type ZEXCEL_CONDITION_OPERATOR value 'lessThan'. "#EC NOTEXT . + class-data C_OPERATOR_LESSTHANOREQUAL type ZEXCEL_CONDITION_OPERATOR value 'lessThanOrEqual'. "#EC NOTEXT . + class-data C_OPERATOR_NONE type ZEXCEL_CONDITION_OPERATOR value ''. "#EC NOTEXT . + class-data C_OPERATOR_NOTCONTAINS type ZEXCEL_CONDITION_OPERATOR value 'notContains'. "#EC NOTEXT . + class-data C_OPERATOR_NOTEQUAL type ZEXCEL_CONDITION_OPERATOR value 'notEqual'. "#EC NOTEXT . + class-data C_RULE_CELLIS type ZEXCEL_CONDITION_RULE value 'cellIs'. "#EC NOTEXT . + class-data C_RULE_CONTAINSTEXT type ZEXCEL_CONDITION_RULE value 'containsText'. "#EC NOTEXT . + class-data C_RULE_EXPRESSION type ZEXCEL_CONDITION_RULE value 'expression'. "#EC NOTEXT . + class-data C_RULE_ICONSET type ZEXCEL_CONDITION_RULE value 'iconSet'. "#EC NOTEXT . + class-data C_RULE_NONE type ZEXCEL_CONDITION_RULE value 'none'. "#EC NOTEXT . + data FORMULA type ZEXCEL_STYLE_FORMULA . + data ICONSET type ZEXCEL_CONDITION_RULE_ICONSET . + data OPERATOR type ZEXCEL_CONDITION_OPERATOR . + data PRIORITY type ZEXCEL_STYLE_PRIORITY value 1. "#EC NOTEXT . + data RULE type ZEXCEL_CONDITION_RULE . + + methods CONSTRUCTOR . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING . + methods SET_RANGE + importing + !IP_START_ROW type ZEXCEL_CELL_ROW + !IP_START_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_STOP_ROW type ZEXCEL_CELL_ROW + !IP_STOP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_CONDITIONAL +*"* do not include other source files here!!! +private section. + + data START_CELL type ZEXCEL_S_CELL_DATA . + data STOP_CELL type ZEXCEL_S_CELL_DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + rule = me->c_rule_none. + operator = me->c_operator_none. +* inizialize dimension range + stop_cell-cell_row = 1. + stop_cell-cell_column = 1. + start_cell-cell_row = 1. + start_cell-cell_column = 1. +endmethod. + + + + method GET_DIMENSION_RANGE. + IF stop_cell EQ start_cell. "only one cell + ep_dimension_range = start_cell-cell_coords. + ELSE. + CONCATENATE start_cell-cell_coords ':' stop_cell-cell_coords INTO ep_dimension_range. + ENDIF. +endmethod. + + + + + + + method SET_RANGE. + DATA: lv_column TYPE zexcel_cell_column, + lv_row_alpha TYPE string. + + lv_column = zcl_excel_common=>convert_column2int( ip_stop_column ). + stop_cell-cell_row = 1. + stop_cell-cell_column = lv_column. + lv_row_alpha = ip_stop_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_stop_column lv_row_alpha INTO stop_cell-cell_coords. + + lv_column = zcl_excel_common=>convert_column2int( ip_start_column ). + start_cell-cell_row = 1. + start_cell-cell_column = lv_column. + lv_row_alpha = ip_start_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE ip_start_column lv_row_alpha INTO start_cell-cell_coords. +endmethod. + + + + class ZCL_EXCEL_STYLE_FILL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +public section. + + class-data C_FILL_NONE type ZEXCEL_FILL_TYPE value 'none'. "#EC NOTEXT . + class-data C_FILL_SOLID type ZEXCEL_FILL_TYPE value 'solid'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_LINEAR type ZEXCEL_FILL_TYPE value 'linear'. "#EC NOTEXT . + class-data C_FILL_GRADIENT_PATH type ZEXCEL_FILL_TYPE value 'path'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKDOWN type ZEXCEL_FILL_TYPE value 'darkDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRAY type ZEXCEL_FILL_TYPE value 'darkGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKGRID type ZEXCEL_FILL_TYPE value 'darkGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKHORIZONTAL type ZEXCEL_FILL_TYPE value 'darkHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKTRELLIS type ZEXCEL_FILL_TYPE value 'darkTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKUP type ZEXCEL_FILL_TYPE value 'darkUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_DARKVERTICAL type ZEXCEL_FILL_TYPE value 'darkVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY0625 type ZEXCEL_FILL_TYPE value 'gray0625'. "#EC NOTEXT . + class-data C_FILL_PATTERN_GRAY125 type ZEXCEL_FILL_TYPE value 'gray125'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTDOWN type ZEXCEL_FILL_TYPE value 'lightDown'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRAY type ZEXCEL_FILL_TYPE value 'lightGray'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTGRID type ZEXCEL_FILL_TYPE value 'lightGrid'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTHORIZONTAL type ZEXCEL_FILL_TYPE value 'lightHorizontal'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTTRELLIS type ZEXCEL_FILL_TYPE value 'lightTrellis'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTUP type ZEXCEL_FILL_TYPE value 'lightUp'. "#EC NOTEXT . + class-data C_FILL_PATTERN_LIGHTVERTICAL type ZEXCEL_FILL_TYPE value 'lightVertical'. "#EC NOTEXT . + class-data C_FILL_PATTERN_MEDIUMGRAY type ZEXCEL_FILL_TYPE value 'mediumGray'. "#EC NOTEXT . + data FILLTYPE type ZEXCEL_FILL_TYPE . + data ROTATION type ZEXCEL_ROTATION . + data FGCOLOR type ZEXCEL_STYLE_COLOR_ARGB . + data BGCOLOR type ZEXCEL_STYLE_COLOR_ARGB value '64'. "#EC NOTEXT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FILL) type ZEXCEL_S_STYLE_FILL . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + filltype = zcl_excel_style_fill=>c_fill_none. + rotation = 0. +endmethod. + + + + method GET_STRUCTURE. + es_fill-rotation = me->rotation. + es_fill-filltype = me->filltype. + es_fill-fgColor = me->fgColor. + es_fill-bgColor = me->bgColor. +endmethod. + + + + class ZCL_EXCEL_STYLE_FONT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + data BOLD type FLAG . + data COLOR type ZEXCEL_STYLE_COLOR_ARGB . + class-data C_SCHEME_MAJOR type ZEXCEL_STYLE_FONT_SCHEME value 'major'. "#EC NOTEXT . + class-data C_SCHEME_MINOR type ZEXCEL_STYLE_FONT_SCHEME value 'minor'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLE type CHAR20 value 'double'. "#EC NOTEXT . + class-data C_UNDERLINE_DOUBLEACCOUNTING type CHAR20 value 'doubleAccounting'. "#EC NOTEXT . + class-data C_UNDERLINE_NONE type CHAR20 value 'none'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLE type CHAR20 value 'single'. "#EC NOTEXT . + class-data C_UNDERLINE_SINGLEACCOUNTING type CHAR20 value 'singleAccounting'. "#EC NOTEXT . + data FAMILY type INT1 value 2. "#EC NOTEXT . + data ITALIC type FLAG . + data NAME type CHAR255 value 'Calibri'. "#EC NOTEXT . + data SCHEME type ZEXCEL_STYLE_FONT_SCHEME . + data SIZE type INT1 value 11. "#EC NOTEXT . + data STRIKETHROUGH type FLAG . + data UNDERLINE type FLAG . + data UNDERLINE_MODE type CHAR20 . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(ES_FONT) type ZEXCEL_S_STYLE_FONT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + me->color = zcl_excel_style_color=>c_black. + me->scheme = zcl_excel_style_font=>c_scheme_minor. + me->underline_mode = zcl_excel_style_font=>c_underline_single. +endmethod. + + + + method GET_STRUCTURE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + es_font-bold = me->bold. + es_font-italic = me->italic. + es_font-underline = me->underline. + es_font-underline_mode = me->underline_mode. + es_font-strikethrough = me->strikethrough. + es_font-size = me->size. + es_font-color = me->color. + es_font-name = me->name. + es_font-family = me->family. + es_font-scheme = me->scheme. + +endmethod. + + + + class ZCL_EXCEL_STYLE_NUMBER_FORMAT definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +public section. + + class-data C_FORMAT_NUMBER type ZEXCEL_NUMBER_FORMAT value '0'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_00 type ZEXCEL_NUMBER_FORMAT value '0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP1 type ZEXCEL_NUMBER_FORMAT value '#,##0.00'. "#EC NOTEXT . + class-data C_FORMAT_NUMBER_COMMA_SEP2 type ZEXCEL_NUMBER_FORMAT value '#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE type ZEXCEL_NUMBER_FORMAT value '0%'. "#EC NOTEXT . + class-data C_FORMAT_PERCENTAGE_00 type ZEXCEL_NUMBER_FORMAT value '0.00%'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD2 type ZEXCEL_NUMBER_FORMAT value 'yyyy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDD type ZEXCEL_NUMBER_FORMAT value 'yy-mm-dd'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DDMMYYYY type ZEXCEL_NUMBER_FORMAT value 'dd/mm/yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYSLASH type ZEXCEL_NUMBER_FORMAT value 'd/m/y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMYMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DMMINUS type ZEXCEL_NUMBER_FORMAT value 'd-m'. "#EC NOTEXT . + class-data C_FORMAT_DATE_MYMINUS type ZEXCEL_NUMBER_FORMAT value 'm-y'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX14 type ZEXCEL_NUMBER_FORMAT value 'mm-dd-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX15 type ZEXCEL_NUMBER_FORMAT value 'd-mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX16 type ZEXCEL_NUMBER_FORMAT value 'd-mmm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX17 type ZEXCEL_NUMBER_FORMAT value 'mmm-yy'. "#EC NOTEXT . + class-data C_FORMAT_DATE_XLSX22 type ZEXCEL_NUMBER_FORMAT value 'm/d/yy h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_DATETIME type ZEXCEL_NUMBER_FORMAT value 'd/m/y h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME1 type ZEXCEL_NUMBER_FORMAT value 'h:mm AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME2 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss AM/PM'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME3 type ZEXCEL_NUMBER_FORMAT value 'h:mm'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME4 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME5 type ZEXCEL_NUMBER_FORMAT value 'mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME6 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME7 type ZEXCEL_NUMBER_FORMAT value 'i:s.S'. "#EC NOTEXT . + class-data C_FORMAT_DATE_TIME8 type ZEXCEL_NUMBER_FORMAT value 'h:mm:ss@'. "#EC NOTEXT . + class-data C_FORMAT_DATE_YYYYMMDDSLASH type ZEXCEL_NUMBER_FORMAT value 'yy/mm/dd@'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD_SIMPLE type ZEXCEL_NUMBER_FORMAT value '"$"#,##0.00_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_USD type ZEXCEL_NUMBER_FORMAT value '$#,##0_-'. "#EC NOTEXT . + class-data C_FORMAT_CURRENCY_EUR_SIMPLE type ZEXCEL_NUMBER_FORMAT value '[$EUR ]#,##0.00_-'. "#EC NOTEXT . + data FORMAT_CODE type ZEXCEL_NUMBER_FORMAT . + + methods CONSTRUCTOR . + methods GET_STRUCTURE + returning + value(EP_NUMBER_FORMAT) type ZEXCEL_NUMBER_FORMAT . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +private section. + + class-data C_FORMAT_GENERAL type ZEXCEL_NUMBER_FORMAT value ''. "#EC NOTEXT . + class-data C_FORMAT_TEXT type ZEXCEL_NUMBER_FORMAT value '@'. "#EC NOTEXT . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + format_code = me->c_format_general. +endmethod. + + + + method GET_STRUCTURE. + ep_number_format = me->format_code. +endmethod. + + + + class ZCL_EXCEL_STYLE_PROTECTION definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +public section. + + constants C_PROTECTION_INHERIT type ZEXCEL_PROTECTION value 'inherit'. "#EC NOTEXT + constants C_PROTECTION_PROTECTED type ZEXCEL_PROTECTION value 'protected'. "#EC NOTEXT + constants C_PROTECTION_UNPROTECTED type ZEXCEL_PROTECTION value 'unprotected'. "#EC NOTEXT + data LOCKED type ZEXCEL_PROTECTION . + data HIDDEN type ZEXCEL_PROTECTION . + + methods CONSTRUCTOR . + *"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! +private section. + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + method CONSTRUCTOR. + locked = me->c_protection_inherit. + hidden = me->c_protection_inherit. +endmethod. + + + + class ZCL_EXCEL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! +public section. + + constants C_XLS type ZEXCEL_FORMAT value 'XLS'. "#EC NOTEXT + constants C_XLSX type ZEXCEL_FORMAT value 'XLSX'. "#EC NOTEXT + data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . + data SECURITY type ref to ZCL_EXCEL_SECURITY . + + methods ADD_NEW_DRAWING + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_RANGE + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods ADD_NEW_STYLE + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods ADD_NEW_WORKSHEET + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods CONSTRUCTOR . + methods GET_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_DRAWINGS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_RANGES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_NAME + returning + value(EP_NAME) type ZEXCEL_WORKSHEETS_NAME . + methods GET_WORKSHEETS_SIZE + returning + value(EP_SIZE) type I . + methods SAVE_AS + importing + !IP_FORMAT type ZEXCEL_FORMAT + returning + value(EP_FILE) type XSTRING . + *"* protected components of class ZABAP_EXCEL +*"* do not include other source files here!!! +protected 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 . + data STYLES type ref to ZCL_EXCEL_STYLES . + data WORKSHEETS type ref to ZCL_EXCEL_WORKSHEETS . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + + + method ADD_NEW_DRAWING. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_title = ip_title. + drawings->add( eo_drawing ). +endmethod. + + + + method ADD_NEW_RANGE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Create default blank range + CREATE OBJECT eo_range. + ranges->add( eo_range ). +endmethod. + + + + method ADD_NEW_STYLE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +* Create default style + CREATE OBJECT eo_style. + styles->add( eo_style ). + +endmethod. + + + + + method ADD_NEW_WORKSHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_title = ip_title. + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). +endmethod. + + + method CONSTRUCTOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style TYPE REF TO zcl_excel_style. + +* Inizialize instance objects + CREATE OBJECT properties. + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings. + + 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. + + + + method GET_ACTIVE_WORKSHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + +endmethod. + + + + method GET_DRAWINGS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->drawings->get_iterator( ). +endmethod. + + + + method GET_RANGES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->ranges->get_iterator( ). +endmethod. + + + + method GET_STYLES_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->styles->get_iterator( ). +endmethod. + + + + method GET_WORKSHEETS_ITERATOR. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + eo_iterator = me->worksheets->get_iterator( ). +endmethod. + + + + method GET_WORKSHEETS_NAME. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_name = me->worksheets->name. + +endmethod. + + + + method GET_WORKSHEETS_SIZE. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + ep_size = me->worksheets->size( ). + +endmethod. + + + + + method SAVE_AS. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + + DATA lo_excel_writer_2007 TYPE REF TO zcl_excel_writer_2007. + +* Determine the output engine to use + CASE ip_format. + WHEN me->c_xlsx. " XLSX for Office 2007 + CREATE OBJECT lo_excel_writer_2007 EXPORTING io_excel = me. + ep_file = lo_excel_writer_2007->create( ). + WHEN OTHERS. + ENDCASE. + +endmethod. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel9. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + +lo_data_validation = lo_worksheet->add_new_data_validation( ). +lo_data_validation->value = lo_range->name. +lo_data_validation->cell_row = 4. +lo_data_validation->cell_column = 'A'. + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Select a value' ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\DataValidation.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel8. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Range.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report Z_ZAKE_SVN +*& +*&---------------------------------------------------------------------* +*& Checkout / Checkin the ZAKE_SVN Project +*& +*&---------------------------------------------------------------------* + +REPORT zake_svn_a2x. + +CONSTANTS cl_svn TYPE seoclsname VALUE 'ZCL_ZAKE_SVN'. +CONSTANTS cl_tortoise_svn TYPE seoclsname VALUE 'ZCL_ZAKE_TORTOISE_SVN'. + +DATA package TYPE devclass. +DATA zake TYPE REF TO zake. + +DATA zake_objects TYPE scts_tadir. + +DATA files TYPE string_table. +DATA file LIKE LINE OF files. + +DATA zake_build TYPE string. +DATA zake_nuggetname TYPE string. + +DATA comment_str TYPE string. +DATA loclpath_str TYPE string. +DATA svnpath_str TYPE string. +DATA username_str TYPE string. +DATA password_str TYPE string. +DATA class TYPE seoclsname. + +DATA: ex TYPE REF TO zcx_saplink, + message TYPE string. + +SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE a. +PARAMETERS: + checkout TYPE flag RADIOBUTTON GROUP act, + update TYPE flag RADIOBUTTON GROUP act DEFAULT 'X', + checkin TYPE flag RADIOBUTTON GROUP act. +SELECTION-SCREEN END OF BLOCK a. + +SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE b. +PARAMETERS: + svn TYPE flag RADIOBUTTON GROUP cl, + tortoise TYPE flag RADIOBUTTON GROUP cl. +SELECTION-SCREEN END OF BLOCK b. + +SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE c. +PARAMETERS: + loclpath TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx' LOWER CASE OBLIGATORY, + zakebuil TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx\build\NUGG_ABAP2XLSX_V_1_0.nugg' LOWER CASE OBLIGATORY, + zakenugg TYPE char512 DEFAULT 'C:\ZAKE_SVN\Projects\abap2xlsx\nuggs\NUGG_ABAP2XLSX_V_1_0.nugg' LOWER CASE OBLIGATORY, + svnpath TYPE char512 DEFAULT 'https://abap2xlsx.googlecode.com/svn/trunk/abap2xlsx' LOWER CASE OBLIGATORY, + comment TYPE char512 DEFAULT '' LOWER CASE, + username TYPE char512 LOWER CASE, + password TYPE char512 LOWER CASE, + testrun TYPE flag DEFAULT 'X'. +SELECTION-SCREEN END OF BLOCK c. + +INITIALIZATION. + a = 'Action'. + b = 'Version Controll Program'. + c = 'Parameters'. + +START-OF-SELECTION. + + svnpath_str = svnpath. + loclpath_str = loclpath. + zake_build = zakebuil. + zake_nuggetname = zakenugg. + comment_str = comment. + + SELECT * INTO TABLE zake_objects FROM tadir WHERE devclass = 'ZABAP2XLSX'. + DELETE zake_objects WHERE object = 'DEVC'. + + TRY. + IF svn = 'X'. + class = cl_svn. + ELSE. + class = cl_tortoise_svn. + ENDIF. + + CREATE OBJECT zake + TYPE + (class) + EXPORTING + i_svnpath = svnpath_str + i_localpath = loclpath_str. + zake->set_testrun( testrun ). + + IF checkin = 'X'. + zake->set_package( 'ZA2X' ). + zake->set_checkin_objects( zake_objects ). + zake->create_slinkees( zake_nuggetname ). + " Build a complete package for download +* zake->set_package( 'ZA2X' ). +* zake->set_checkin_objects( zake_objects ). +* " Let's add the CMD Scripts to the complete package +* CONCATENATE loclpath 'bin/svn-script.cmd' INTO file. +* APPEND file TO files. +* CONCATENATE loclpath 'bin/tortoise-svn-script.cmd' INTO file. +* APPEND file TO files. +* zake->add_files_to_zip( files ). +* " We don't want that for the complete Package Slinkees are created +* " in the ZAKE folder +* zake->download_slinkees_to_lm = space. +* zake->download_nugget_to_lm = space. +* zake->create_slinkees( zake_nuggetname ). + IF testrun IS INITIAL. + zake->checkin( comment_str ). + ENDIF. + ELSE. + IF update = 'X'. + zake->update( ). + ELSE. + zake->checkout( ). + ENDIF. + " zake->install_slinkees_from_lm( testrun ). + zake->install_objects( zake_objects ). + ENDIF. + CATCH zcx_saplink INTO ex. + message = ex->msg. + WRITE: / 'An Error occured: ', message. + ENDTRY. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel1. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HelloWorld.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel2. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_bold TYPE REF TO zcl_excel_style, + lo_style_underline TYPE REF TO zcl_excel_style, + lo_style_filled TYPE REF TO zcl_excel_style, + lo_style_border TYPE REF TO zcl_excel_style, + lo_style_button TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_bold_guid TYPE zexcel_cell_style, + lv_style_underline_guid TYPE zexcel_cell_style, + lv_style_filled_guid TYPE zexcel_cell_style, + lv_style_border_guid TYPE zexcel_cell_style, + lv_style_button_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +CREATE OBJECT lo_border_light. +lo_border_light->border_color = zcl_excel_style_color=>c_gray. +lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. +" Create a bold / italic style +lo_style_bold = lo_excel->add_new_style( ). +lo_style_bold->font->bold = abap_true. +lo_style_bold->font->italic = abap_true. +lo_style_bold->font->color = zcl_excel_style_color=>c_red. +lv_style_bold_guid = lo_style_bold->get_guid( ). +" Create an underline double style +lo_style_underline = lo_excel->add_new_style( ). +lo_style_underline->font->underline = abap_true. +lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double. +lv_style_underline_guid = lo_style_underline->get_guid( ). +" Create filled style +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lv_style_filled_guid = lo_style_filled->get_guid( ). +" Create border with button effects +lo_style_button = lo_excel->add_new_style( ). +lo_style_button->borders->right = lo_border_dark. +lo_style_button->borders->down = lo_border_dark. +lo_style_button->borders->left = lo_border_light. +lo_style_button->borders->top = lo_border_light. +lv_style_button_guid = lo_style_button->get_guid( ). +"Create style with border +lo_style_border = lo_excel->add_new_style( ). +lo_style_border->borders->allborders = lo_border_dark. +lv_style_border_guid = lo_style_border->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Styles'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Styles.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel3. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_header TYPE REF TO zcl_excel_style, + lo_style_body TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_header_guid TYPE zexcel_cell_style, + lv_style_body_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +" Create filled style +lo_style_header = lo_excel->add_new_style( ). +lo_style_header->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_header->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lo_style_header->borders->allborders = lo_border_dark. +lv_style_header_guid = lo_style_header->get_guid( ). +"Create style with border +lo_style_body = lo_excel->add_new_style( ). +lo_style_body->borders->allborders = lo_border_dark. +lv_style_body_guid = lo_style_body->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. +lo_worksheet->set_table( ip_table = lt_test + ip_hdr_style = lv_style_header_guid + ip_body_style = lv_style_body_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTab.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel4. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ). + +lo_worksheet = lo_excel->add_new_worksheet( ). +lo_worksheet->title = 'Sheet2'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ). + + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Sheets.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel5. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '100' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '1000' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '150' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '500' ip_style = lv_style_number_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\CondFormatting.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel6. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '100' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '1000' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '150' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '500' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = '1760' ip_formula = 'SUM(C4:C8)' ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Formula.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel7. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_style_number TYPE REF TO zcl_excel_style, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +lo_style_number = lo_excel->add_new_style( ). +lo_style_number->number_format->format_code = zcl_excel_style_number_format=>c_format_number. +lv_style_number_guid = lo_style_number->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 5 + ip_stop_column = 'B' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 5 + ip_stop_column = 'C' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3flags. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 5 + ip_stop_column = 'D' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'C_ICONSET_3FLAGS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 5 + ip_stop_column = 'E' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'C_ICONSET_3TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 5 + ip_stop_column = 'F' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'C_ICONSET_3TRAFFICLIGHTS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'F' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'F' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'F' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'F' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'G' + ip_start_row = 5 + ip_stop_column = 'G' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = 'C_ICONSET_3SIGNS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'G' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'G' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'G' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'G' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'G' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'H' + ip_start_row = 5 + ip_stop_column = 'H' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'H' ip_value = 'C_ICONSET_3SYMBOLS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'H' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'H' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'H' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'H' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'H' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'I' + ip_start_row = 5 + ip_stop_column = 'I' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'I' ip_value = 'C_ICONSET_3SYMBOLS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'I' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'I' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'I' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'I' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'I' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 12 + ip_stop_column = 'B' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = 'C_ICONSET_4ARROWS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 12 + ip_stop_column = 'C' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'C' ip_value = 'C_ICONSET_4ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 12 + ip_stop_column = 'D' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'D' ip_value = 'C_ICONSET_4REDTOBLACK' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 12 + ip_stop_column = 'E' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'E' ip_value = 'C_ICONSET_4RATING' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 12 + ip_stop_column = 'F' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'F' ip_value = 'C_ICONSET_4TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'F' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'F' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'F' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'F' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 19 + ip_stop_column = 'B' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'B' ip_value = 'C_ICONSET_5ARROWS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'B' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'B' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'B' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'B' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'B' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 19 + ip_stop_column = 'C' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'C' ip_value = 'C_ICONSET_5ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'C' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'C' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'C' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'C' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'C' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 19 + ip_stop_column = 'D' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'D' ip_value = 'C_ICONSET_5RATING' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'D' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'D' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'D' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'D' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'D' ip_value = '50' ip_style = lv_style_number_guid ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5quarters. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 19 + ip_stop_column = 'E' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = '10' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = '20' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = '30' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = '40' ip_style = lv_style_number_guid ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = '50' ip_style = lv_style_number_guid ). + +lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Iconset.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuggs/NUGG_ABAP2XLSX_V_1_1.nugg.zip b/nuggs/NUGG_ABAP2XLSX_V_1_1.nugg.zip new file mode 100644 index 0000000..73b35be Binary files /dev/null and b/nuggs/NUGG_ABAP2XLSX_V_1_1.nugg.zip differ diff --git a/nuggs/NUGG_ABAP2XLSX_V_2_1.nugg b/nuggs/NUGG_ABAP2XLSX_V_2_1.nugg new file mode 100644 index 0000000..34d7261 --- /dev/null +++ b/nuggs/NUGG_ABAP2XLSX_V_2_1.nugg @@ -0,0 +1,4964 @@ + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel. + +SUBMIT zdemo_excel1 AND RETURN. " Hello world +SUBMIT zdemo_excel2 AND RETURN. " Styles +SUBMIT zdemo_excel3 AND RETURN. " iTab binding +SUBMIT zdemo_excel4 AND RETURN. " Multi sheets +SUBMIT zdemo_excel5 AND RETURN. " Conditional formatting +SUBMIT zdemo_excel6 AND RETURN. " Formulas +SUBMIT zdemo_excel7 AND RETURN. " Conditional formatting +SUBMIT zdemo_excel8 AND RETURN. " Ranges +SUBMIT zdemo_excel9 AND RETURN. " Data validation +SUBMIT zdemo_excel10 AND RETURN. " Bind table with field catalog +" zdemo_excel11 is not added because it has a selection screen and +" you also need to have business partners maintained in transaction BP +SUBMIT zdemo_excel12 AND RETURN. " Column size +SUBMIT zdemo_excel13 AND RETURN. " Merge cell +SUBMIT zdemo_excel14 AND RETURN. " Alignment +SUBMIT zdemo_excel15 AND RETURN. " Read Excel and write it back + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel1. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer TYPE REF TO zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = sy-datum ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = sy-uzeit ). + +CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HelloWorld.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& Test Styles for ABAP2XLSX +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel2. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_bold TYPE REF TO zcl_excel_style, + lo_style_underline TYPE REF TO zcl_excel_style, + lo_style_filled TYPE REF TO zcl_excel_style, + lo_style_border TYPE REF TO zcl_excel_style, + lo_style_button TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border. + +DATA: lv_style_bold_guid TYPE zexcel_cell_style, + lv_style_underline_guid TYPE zexcel_cell_style, + lv_style_filled_guid TYPE zexcel_cell_style, + lv_style_filled_green_guid TYPE zexcel_cell_style, + lv_style_border_guid TYPE zexcel_cell_style, + lv_style_button_guid TYPE zexcel_cell_style. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Create border object +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. +CREATE OBJECT lo_border_light. +lo_border_light->border_color = zcl_excel_style_color=>c_gray. +lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. +" Create a bold / italic style +lo_style_bold = lo_excel->add_new_style( ). +lo_style_bold->font->bold = abap_true. +lo_style_bold->font->italic = abap_true. +lo_style_bold->font->color = zcl_excel_style_color=>c_red. +lv_style_bold_guid = lo_style_bold->get_guid( ). +" Create an underline double style +lo_style_underline = lo_excel->add_new_style( ). +lo_style_underline->font->underline = abap_true. +lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double. +lv_style_underline_guid = lo_style_underline->get_guid( ). +" Create filled style yellow +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_yellow. +lv_style_filled_guid = lo_style_filled->get_guid( ). +" Create border with button effects +lo_style_button = lo_excel->add_new_style( ). +lo_style_button->borders->right = lo_border_dark. +lo_style_button->borders->down = lo_border_dark. +lo_style_button->borders->left = lo_border_light. +lo_style_button->borders->top = lo_border_light. +lv_style_button_guid = lo_style_button->get_guid( ). +"Create style with border +lo_style_border = lo_excel->add_new_style( ). +lo_style_border->borders->allborders = lo_border_dark. +lv_style_border_guid = lo_style_border->get_guid( ). +" Create filled style green +lo_style_filled = lo_excel->add_new_style( ). +lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. +lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_green. +lv_style_filled_green_guid = lo_style_filled->get_guid( ). + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Styles'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ). +" Fill the cell and apply one style +lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lv_style_filled_guid ). +" Change the style +lo_worksheet->set_cell_style( ip_column = 'B' ip_row = 6 ip_style = lv_style_filled_green_guid ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Styles.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel3. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime. + +DATA: ls_table_settings TYPE zexcel_s_table_settings. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. + +ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2. +ls_table_settings-show_row_stripes = abap_true. + +lo_worksheet->bind_table( ip_table = lt_test + is_table_settings = ls_table_settings ). + +column_dimension = lo_worksheet->get_column_dimension( 'E' ). "make date field a bit wider +column_dimension->set_width( 11 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTab.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel4. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ). + +lo_worksheet = lo_excel->add_new_worksheet( ). +lo_worksheet->title = 'Sheet2'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Sheets.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel5. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 100 ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 1000 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 150 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 500 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\CondFormatting.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel6. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 100 ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 1000 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 150 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 500 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_formula = 'SUM(C4:C8)' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Formula.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel7. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 5 + ip_stop_column = 'B' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 5 + ip_stop_column = 'C' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = 50 ). +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3flags. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 5 + ip_stop_column = 'D' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'C_ICONSET_3FLAGS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'D' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'D' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 5 + ip_stop_column = 'E' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'C_ICONSET_3TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'E' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 5 + ip_stop_column = 'F' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'C_ICONSET_3TRAFFICLIGHTS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'F' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'F' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'F' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'F' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'G' + ip_start_row = 5 + ip_stop_column = 'G' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = 'C_ICONSET_3SIGNS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'G' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'G' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'G' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'G' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'G' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'H' + ip_start_row = 5 + ip_stop_column = 'H' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'H' ip_value = 'C_ICONSET_3SYMBOLS' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'H' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'H' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'H' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'H' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'H' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'I' + ip_start_row = 5 + ip_stop_column = 'I' + ip_stop_row = 9 ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'I' ip_value = 'C_ICONSET_3SYMBOLS2' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'I' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'I' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'I' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'I' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 9 ip_column = 'I' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 12 + ip_stop_column = 'B' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = 'C_ICONSET_4ARROWS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'B' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'B' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'B' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 12 + ip_stop_column = 'C' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'C' ip_value = 'C_ICONSET_4ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'C' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'C' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'C' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'C' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 12 + ip_stop_column = 'D' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'D' ip_value = 'C_ICONSET_4REDTOBLACK' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'D' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'D' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'D' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 12 + ip_stop_column = 'E' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'E' ip_value = 'C_ICONSET_4RATING' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'E' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'E' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'E' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'E' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'F' + ip_start_row = 12 + ip_stop_column = 'F' + ip_stop_row = 16 ). + +lo_worksheet->set_cell( ip_row = 11 ip_column = 'F' ip_value = 'C_ICONSET_4TRAFFICLIGHTS' ). +lo_worksheet->set_cell( ip_row = 12 ip_column = 'F' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 14 ip_column = 'F' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 15 ip_column = 'F' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 16 ip_column = 'F' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'B' + ip_start_row = 19 + ip_stop_column = 'B' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'B' ip_value = 'C_ICONSET_5ARROWS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'B' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'B' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'B' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'B' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'B' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'C' + ip_start_row = 19 + ip_stop_column = 'C' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'C' ip_value = 'C_ICONSET_5ARROWSGRAY' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'C' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'C' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'C' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'C' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'C' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5rating. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'D' + ip_start_row = 19 + ip_stop_column = 'D' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'D' ip_value = 'C_ICONSET_5RATING' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'D' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'D' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'D' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'D' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'D' ip_value = 50 ). + +lo_style_conditional = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5quarters. +lo_style_conditional->priority = 1. +lo_style_conditional->set_range( ip_start_column = 'E' + ip_start_row = 19 + ip_stop_column = 'E' + ip_stop_row = 23 ). + +lo_worksheet->set_cell( ip_row = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ). +lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = 10 ). +lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = 20 ). +lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = 30 ). +lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = 40 ). +lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = 50 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Iconset.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel8. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Range.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel9. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. +lo_range = lo_excel->add_new_range( ). +lo_range->name = 'range'. +lo_range->set_value( ip_sheet_name = lo_worksheet->title + ip_start_column = 'C' + ip_start_row = 4 + ip_stop_column = 'C' + ip_stop_row = 8 ). + +lo_data_validation = lo_worksheet->add_new_data_validation( ). +lo_data_validation->value = lo_range->name. +lo_data_validation->cell_row = 4. +lo_data_validation->cell_column = 'A'. + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Select a value' ). + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ). +lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\DataValidation.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZIFE_TEST_EXCEL +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel10. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_conditional2 TYPE REF TO zcl_excel_style_conditional, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_field_catalog TYPE zexcel_t_fieldcatalog, + ls_field_catalog TYPE zexcel_s_fieldcatalog, + ls_table_settings TYPE zexcel_s_table_settings, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Internal table'. + +"Conditional style +lo_style_conditional2 = lo_worksheet->add_new_conditional_style( ). +lo_style_conditional2->rule = zcl_excel_style_conditional=>c_rule_iconset. +lo_style_conditional2->iconset = zcl_excel_style_conditional=>c_iconset_5arrows. +lo_style_conditional2->priority = 1. + +DATA lt_test TYPE TABLE OF sflight. +SELECT * FROM sflight INTO TABLE lt_test. + +lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_test ). + +LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>. + CASE <fs_field_catalog>-fieldname. + WHEN 'CARRID'. + <fs_field_catalog>-position = 3. + <fs_field_catalog>-dynpfld = abap_true. + <fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_count. + WHEN 'CONNID'. + <fs_field_catalog>-position = 4. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FLDATE'. + <fs_field_catalog>-position = 2. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'PRICE'. + <fs_field_catalog>-position = 1. + <fs_field_catalog>-dynpfld = abap_true. + <fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_sum. + <fs_field_catalog>-cond_style = lo_style_conditional2. + WHEN OTHERS. + <fs_field_catalog>-dynpfld = abap_false. + ENDCASE. +ENDLOOP. + +ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5. + +lo_worksheet->bind_table( ip_table = lt_test + is_table_settings = ls_table_settings + it_field_catalog = lt_field_catalog ). + +column_dimension = lo_worksheet->get_column_dimension( 'D' ). "make date field a bit wider +column_dimension->set_width( 13 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\iTabFieldCatalog.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL11 +*& Export Organisation and Contact Persons using ABAP2XLSX +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel11. + +TYPE-POOLS: abap. + +DATA: central_search TYPE bapibus1006_central_search, + addressdata_search TYPE bapibus1006_addr_search, + others_search TYPE bapibus1006_other_data. +DATA: searchresult TYPE TABLE OF bapibus1006_bp_addr, + return TYPE TABLE OF bapiret2. +DATA: lines TYPE i. +FIELD-SYMBOLS: <searchresult_line> LIKE LINE OF searchresult. +DATA: centraldata TYPE bapibus1006_central, + centraldataperson TYPE bapibus1006_central_person, + centraldataorganization TYPE bapibus1006_central_organ. +DATA: addressdata TYPE bapibus1006_address. +DATA: relationships TYPE TABLE OF bapibus1006_relations. +FIELD-SYMBOLS: <relationship> LIKE LINE OF relationships. +DATA: relationship_centraldata TYPE bapibus1006002_central. +DATA: relationship_addresses TYPE TABLE OF bapibus1006002_addresses. +FIELD-SYMBOLS: <relationship_address> LIKE LINE OF relationship_addresses. + +DATA: lt_download TYPE TABLE OF zexcel_s_org_rel. +FIELD-SYMBOLS: <download> LIKE LINE OF lt_download. + +PARAMETERS: md TYPE flag RADIOBUTTON GROUP act. + +SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE a. +PARAMETERS: partnerc TYPE bu_type DEFAULT 2, " Organizations + postlcod TYPE ad_pstcd1 DEFAULT '8334*', + country TYPE land1 DEFAULT 'DE', + maxsel TYPE bu_maxsel DEFAULT 100. +SELECTION-SCREEN END OF BLOCK a. + +PARAMETERS: rel TYPE flag RADIOBUTTON GROUP act DEFAULT 'X'. + +SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE b. +PARAMETERS: reltyp TYPE bu_reltyp DEFAULT 'BUR011', + partner TYPE bu_partner DEFAULT '191'. +SELECTION-SCREEN END OF BLOCK b. + +INITIALIZATION. + a = 'Select by master data'. + b = 'Select by relationship'. + +START-OF-SELECTION. + IF md = abap_true. + " Read all Companies by Master Data + central_search-partnercategory = partnerc. + addressdata_search-postl_cod1 = postlcod. + addressdata_search-country = country. + others_search-maxsel = maxsel. + others_search-no_search_for_contactperson = 'X'. + + CALL FUNCTION 'BAPI_BUPA_SEARCH_2' + EXPORTING + centraldata = central_search + addressdata = addressdata_search + OTHERS = others_search + TABLES + searchresult = searchresult + return = return. + + SORT searchresult BY partner. + DELETE ADJACENT DUPLICATES FROM searchresult COMPARING partner. + ELSEIF rel = abap_true. + " Read by Relationship + SELECT but050~partner1 AS partner FROM but050 + INNER JOIN but000 ON but000~partner = but050~partner1 AND but000~type = '2' + INTO CORRESPONDING FIELDS OF TABLE searchresult + WHERE but050~partner2 = partner + AND but050~reltyp = reltyp. + ENDIF. + + DESCRIBE TABLE searchresult LINES lines. + WRITE: / 'Number of search results: ', lines. + + LOOP AT searchresult ASSIGNING <searchresult_line>. + " Read Details of Organization + CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL' + EXPORTING + businesspartner = <searchresult_line>-partner + IMPORTING + centraldataorganization = centraldataorganization. + " Read Standard Address of Organization + CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL' + EXPORTING + businesspartner = <searchresult_line>-partner + IMPORTING + addressdata = addressdata. + + " Add Organization to Download + APPEND INITIAL LINE TO lt_download ASSIGNING <download>. + " Fill Organization Partner Numbers + CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS' + EXPORTING + businesspartner = <searchresult_line>-partner + IMPORTING + businesspartnerout = <download>-org_number + businesspartnerguidout = <download>-org_guid. + + MOVE-CORRESPONDING centraldataorganization TO <download>. + MOVE-CORRESPONDING addressdata TO <download>. + CLEAR: addressdata. + + " Read all Relationships + CLEAR: relationships. + CALL FUNCTION 'BAPI_BUPA_RELATIONSHIPS_GET' + EXPORTING + businesspartner = <searchresult_line>-partner + TABLES + relationships = relationships. + DELETE relationships WHERE relationshipcategory <> 'BUR001'. + LOOP AT relationships ASSIGNING <relationship>. + " Read details of Contact person + CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL' + EXPORTING + businesspartner = <relationship>-partner2 + IMPORTING + centraldata = centraldata + centraldataperson = centraldataperson. + " Read details of the Relationship + CALL FUNCTION 'BAPI_BUPR_CONTP_GETDETAIL' + EXPORTING + businesspartner = <relationship>-partner1 + contactperson = <relationship>-partner2 + IMPORTING + centraldata = relationship_centraldata. + " Read relationship address + CLEAR: relationship_addresses. + + CALL FUNCTION 'BAPI_BUPR_CONTP_ADDRESSES_GET' + EXPORTING + businesspartner = <relationship>-partner1 + contactperson = <relationship>-partner2 + TABLES + addresses = relationship_addresses. + + READ TABLE relationship_addresses + ASSIGNING <relationship_address> + WITH KEY standardaddress = 'X'. + + IF <relationship_address> IS ASSIGNED. + " Read Relationship Address + CLEAR addressdata. + CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL' + EXPORTING + businesspartner = <searchresult_line>-partner + addressguid = <relationship_address>-addressguid + IMPORTING + addressdata = addressdata. + + APPEND INITIAL LINE TO lt_download ASSIGNING <download>. + CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS' + EXPORTING + businesspartner = <relationship>-partner1 + IMPORTING + businesspartnerout = <download>-org_number + businesspartnerguidout = <download>-org_guid. + + CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS' + EXPORTING + businesspartner = <relationship>-partner2 + IMPORTING + businesspartnerout = <download>-contpers_number + businesspartnerguidout = <download>-contpers_guid. + + MOVE-CORRESPONDING centraldataorganization TO <download>. + MOVE-CORRESPONDING addressdata TO <download>. + MOVE-CORRESPONDING centraldataperson TO <download>. + MOVE-CORRESPONDING relationship_centraldata TO <download>. + + WRITE: / <relationship>-partner1, <relationship>-partner2. + WRITE: centraldataorganization-name1(20), centraldataorganization-name2(10). + WRITE: centraldataperson-firstname(15), centraldataperson-lastname(15). + WRITE: addressdata-street(25), addressdata-house_no, + addressdata-postl_cod1, addressdata-city(25). + ENDIF. + ENDLOOP. + + ENDLOOP. + + DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer TYPE REF TO zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style_body TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border, + lo_border_light TYPE REF TO zcl_excel_style_border, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime, + row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + DATA: lv_style_body_odd_guid TYPE zexcel_cell_style, + lv_style_body_even_guid TYPE zexcel_cell_style, + lv_style_body_green TYPE zexcel_cell_style, + lv_style_body_odd_n_guid TYPE zexcel_cell_style, + lv_style_body_even_n_guid TYPE zexcel_cell_style. + + DATA: row TYPE zexcel_cell_row. + + DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + + DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog, + ls_table_settings TYPE zexcel_s_table_settings. + + DATA: column TYPE zexcel_cell_column, + column_alpha TYPE zexcel_cell_column_alpha, + value TYPE zexcel_cell_value. + + FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog. + + " Creates active sheet + CREATE OBJECT lo_excel. + + " Create border object + CREATE OBJECT lo_border_dark. + lo_border_dark->border_color = zcl_excel_style_color=>c_black. + lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. + "Create style with border odd + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->filltype = zcl_excel_style_fill=>c_fill_solid. + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_gray. + lo_style_body->borders->allborders = lo_border_dark. + lv_style_body_odd_guid = lo_style_body->get_guid( ). + "Create style with border even + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_yellow. + lo_style_body->borders->allborders = lo_border_dark. + lv_style_body_even_guid = lo_style_body->get_guid( ). + "Create style with border and green fill + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_green. + lo_style_body->borders->allborders = lo_border_dark. + lv_style_body_green = lo_style_body->get_guid( ). + "Create style numeric with border odd + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->fill->filltype = zcl_excel_style_fill=>c_fill_solid. + lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_gray. + lo_style_body->borders->allborders = lo_border_dark. + lo_style_body->number_format->format_code = zcl_excel_style_number_format=>c_format_number. + lv_style_body_odd_n_guid = lo_style_body->get_guid( ). + "Create style numeric with border odd + lo_style_body = lo_excel->add_new_style( ). + lo_style_body->borders->allborders = lo_border_dark. + lo_style_body->number_format->format_code = zcl_excel_style_number_format=>c_format_number. + lv_style_body_even_n_guid = lo_style_body->get_guid( ). + + " Get active sheet + lo_worksheet = lo_excel->get_active_worksheet( ). + lo_worksheet->title = 'Internal table'. + + lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_download ). + + LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>. + CASE <fs_field_catalog>-fieldname. + WHEN 'ORG_NUMBER'. + <fs_field_catalog>-position = 1. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'CONTPERS_NUMBER'. + <fs_field_catalog>-position = 2. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'NAME1'. + <fs_field_catalog>-position = 3. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'NAME2'. + <fs_field_catalog>-position = 4. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'STREET'. + <fs_field_catalog>-position = 5. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'HOUSE_NO'. + <fs_field_catalog>-position = 6. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'POSTL_COD1'. + <fs_field_catalog>-position = 7. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'CITY'. + <fs_field_catalog>-position = 8. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'COUNTRYISO'. + <fs_field_catalog>-position = 9. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FIRSTNAME'. + <fs_field_catalog>-position = 10. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'LASTNAME'. + <fs_field_catalog>-position = 11. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FUNCTIONNAME'. + <fs_field_catalog>-position = 12. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'DEPARTMENTNAME'. + <fs_field_catalog>-position = 13. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'TEL1_NUMBR'. + <fs_field_catalog>-position = 14. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'TEL1_EXT'. + <fs_field_catalog>-position = 15. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FAX_NUMBER'. + <fs_field_catalog>-position = 16. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'FAX_EXTENS'. + <fs_field_catalog>-position = 17. + <fs_field_catalog>-dynpfld = abap_true. + WHEN 'E_MAIL'. + <fs_field_catalog>-position = 18. + <fs_field_catalog>-dynpfld = abap_true. + WHEN OTHERS. + <fs_field_catalog>-dynpfld = abap_false. + ENDCASE. + ENDLOOP. + + ls_table_settings-top_left_column = 'A'. + ls_table_settings-top_left_row = '2'. + ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5. + + lo_worksheet->bind_table( ip_table = lt_download + is_table_settings = ls_table_settings + it_field_catalog = lt_field_catalog ). + LOOP AT lt_download ASSIGNING <download>. + row = sy-tabix + 2. + IF NOT <download>-org_number IS INITIAL + AND <download>-contpers_number IS INITIAL. + " Mark fields of Organization which can be changed green + lo_worksheet->set_cell_style( + ip_column = 'C' + ip_row = row + ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'D' + ip_row = row + ip_style = lv_style_body_green + ). +* CATCH zcx_excel. " Exceptions for ABAP2XLSX + ELSEIF NOT <download>-org_number IS INITIAL + AND NOT <download>-contpers_number IS INITIAL. + " Mark fields of Relationship which can be changed green + lo_worksheet->set_cell_style( + ip_column = 'L' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'M' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'N' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'O' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'P' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'Q' ip_row = row ip_style = lv_style_body_green + ). + lo_worksheet->set_cell_style( + ip_column = 'R' ip_row = row ip_style = lv_style_body_green + ). + ENDIF. + ENDLOOP. + " Add Fieldnames in first row and hide the row + LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog> + WHERE position <> '' AND dynpfld = abap_true. + column = <fs_field_catalog>-position. + column_alpha = zcl_excel_common=>convert_column2alpha( column ). + value = <fs_field_catalog>-fieldname. + lo_worksheet->set_cell( ip_column = column_alpha + ip_row = 1 + ip_value = value + ip_style = lv_style_body_even_guid ). + ENDLOOP. + " Hide first row + row_dimension = lo_worksheet->get_row_dimension( 1 ). + row_dimension->set_visible( abap_false ). + + " Set Column width + column_dimension = lo_worksheet->get_column_dimension( 'A' ). + column_dimension->set_width( 11 ). + column_dimension = lo_worksheet->get_column_dimension( 'B' ). + column_dimension->set_width( 11 ). + column_dimension = lo_worksheet->get_column_dimension( 'C' ). + column_dimension->set_width( 35 ). + column_dimension = lo_worksheet->get_column_dimension( 'E' ). + column_dimension->set_width( 18 ). + column_dimension = lo_worksheet->get_column_dimension( 'F' ). + column_dimension->set_width( 5 ). + column_dimension = lo_worksheet->get_column_dimension( 'G' ). + column_dimension->set_width( 6 ). + column_dimension = lo_worksheet->get_column_dimension( 'H' ). + column_dimension->set_width( 12 ). + column_dimension = lo_worksheet->get_column_dimension( 'I' ). + column_dimension->set_width( 3 ). + column_dimension = lo_worksheet->get_column_dimension( 'J' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'K' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'L' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'M' ). + column_dimension->set_width( 13 ). + column_dimension = lo_worksheet->get_column_dimension( 'N' ). + column_dimension->set_width( 12 ). + column_dimension = lo_worksheet->get_column_dimension( 'O' ). + column_dimension->set_width( 9 ). + column_dimension = lo_worksheet->get_column_dimension( 'P' ). + column_dimension->set_width( 12 ). + column_dimension = lo_worksheet->get_column_dimension( 'Q' ). + column_dimension->set_width( 9 ). + column_dimension = lo_worksheet->get_column_dimension( 'R' ). + column_dimension->set_width( 40 ). + + CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. + lv_file = lo_excel_writer->write_file( lo_excel ). + + " Convert to binary + CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + + " Save the file + CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\ZDEMO_EXCEL11.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL12 +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel12. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + column_dimension TYPE REF TO zcl_excel_worksheet_columndime, + row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + +DATA: lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1. + +" Creates active sheet +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'Sheet1'. +lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world in AutoSize column' ). +lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Hello world in a column width size 50' ). +lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Hello world (hidden column)' ). +lo_worksheet->set_cell( ip_column = 'F' ip_row = 2 ip_value = 'Outline column level 0' ). +lo_worksheet->set_cell( ip_column = 'G' ip_row = 2 ip_value = 'Outline column level 1' ). +lo_worksheet->set_cell( ip_column = 'H' ip_row = 2 ip_value = 'Outline column level 2' ). + + +lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Hello world (hidden row)' ). +lo_worksheet->set_cell( ip_column = 'E' ip_row = 5 ip_value = 'Hello world in a row height size 20' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Outline row level 0' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 7 ip_value = 'Outline row level 1' ). +lo_worksheet->set_cell( ip_column = 'B' ip_row = 8 ip_value = 'Outline row level 2' ). + +" Column Settings +column_dimension = lo_worksheet->get_column_dimension( 'B' ). +column_dimension->set_auto_size( abap_true ). +column_dimension = lo_worksheet->get_column_dimension( 'C' ). +column_dimension->set_width( 50 ). +column_dimension = lo_worksheet->get_column_dimension( 'D' ). +column_dimension->set_visible( abap_false ). +" Implementation in the Writer is not working yet ===== TODO ===== +column_dimension = lo_worksheet->get_column_dimension( 'F' ). +column_dimension->set_outline_level( 0 ). +column_dimension = lo_worksheet->get_column_dimension( 'G' ). +column_dimension->set_outline_level( 1 ). +column_dimension = lo_worksheet->get_column_dimension( 'H' ). +column_dimension->set_outline_level( 2 ). + +row_dimension = lo_worksheet->get_row_dimension( 1 ). +row_dimension->set_visible( abap_false ). +row_dimension = lo_worksheet->get_row_dimension( 5 ). +row_dimension->set_row_height( 20 ). +" Implementation in the Writer is not working yet ===== TODO ===== +row_dimension = lo_worksheet->get_row_dimension( 6 ). +row_dimension->set_outline_level( 0 ). +row_dimension = lo_worksheet->get_row_dimension( 7 ). +row_dimension->set_outline_level( 1 ). +row_dimension = lo_worksheet->get_row_dimension( 8 ). +row_dimension->set_outline_level( 2 ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +" Convert to binary +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. + +" Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\HideSizeOutlineRowsAndColumns.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL13 +*& +*&---------------------------------------------------------------------* +*& Example by: Alvaro "Blag" Tejada Galindo. +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel13. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer type ref to zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range, + lv_file TYPE xstring, + lv_style_number_guid TYPE zexcel_cell_style, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1, + lv_style_bold_border_guid TYPE zexcel_cell_style, + lo_style_bold_border TYPE REF TO zcl_excel_style, + lo_border_dark TYPE REF TO zcl_excel_style_border. + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. + +CREATE OBJECT lo_border_dark. +lo_border_dark->border_color = zcl_excel_style_color=>c_black. +lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. + +lo_style_bold_border = lo_excel->add_new_style( ). +lo_style_bold_border->font->bold = abap_true. +lo_style_bold_border->font->italic = abap_false. +lo_style_bold_border->font->color = zcl_excel_style_color=>c_black. +lo_style_bold_border->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lo_style_bold_border->borders->allborders = lo_border_dark. +lv_style_bold_border_guid = lo_style_bold_border->get_guid( ). + +lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = 'Test' ). + +lo_worksheet->set_cell( ip_row = 2 ip_column = 'B' ip_value = 'Banana' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'C' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'D' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'E' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'F' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_cell( ip_row = 2 ip_column = 'G' ip_value = '' ip_style = lv_style_bold_border_guid ). +lo_worksheet->set_merge( ip_row = 2 ip_column_start = 'B' ip_column_end = 'G' ). + +create object lo_excel_writer type zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Merged_Cells.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + interfaces ZIF_EXCEL_WRITER . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_TABLE + importing + !IO_TABLE type ref to ZCL_EXCEL_TABLE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* 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. + ep_file = me->create( ). +ENDMETHOD. + + + + method CREATE. + + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_nested_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string, + lv_value TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( lo_worksheet ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + + lo_nested_iterator = lo_worksheet->get_tables_iterator( ). + + WHILE lo_nested_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_table ?= lo_nested_iterator->if_object_collection_iterator~get_next( ). + lv_content = me->create_xl_table( lo_table ). + + lv_value = lo_table->get_name( ). + CONCATENATE 'xl/tables/' lv_value '.xml' into lv_value. + lo_zip->add( name = lv_value + content = lv_content ). + ENDWHILE. + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +endmethod. + + + + method CREATE_CONTENT_TYPES. + + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml', + lc_xml_node_table_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_nested_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i, + lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_worksheet_ct ). + lo_element_root->append_child( lo_element ). + ENDDO. + + lo_iterator = me->excel->get_worksheets_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->get_next( ). + + lo_nested_iterator = lo_worksheet->get_tables_iterator( ). + + WHILE lo_nested_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_nested_iterator->get_next( ). + + lv_value = lo_table->get_name( ). + CONCATENATE '/xl/tables/' lv_value '.xml' INTO lv_value. + + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_table_ct ). + lo_element_root->append_child( lo_element ). + ENDWHILE. + ENDWHILE. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_APP. + + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_CORE. + + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_RELATIONSHIPS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_RELATIONSHIPS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_SHAREDSTRINGS. + + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + + method CREATE_XL_SHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software. you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation. either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY. without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library. if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_sheetpr TYPE string VALUE 'sheetPr', + lc_xml_node_outlinepr TYPE string VALUE 'outlinePr', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_cols TYPE string VALUE 'cols', + lc_xml_node_col TYPE string VALUE 'col', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + lc_xml_node_datavalidations TYPE string VALUE 'dataValidations', + lc_xml_node_datavalidation TYPE string VALUE 'dataValidation', + lc_xml_node_formula1 TYPE string VALUE 'formula1', + lc_xml_node_mergecell TYPE string VALUE 'mergeCell', + lc_xml_node_mergecells TYPE string VALUE 'mergeCells', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_summarybelow TYPE string VALUE 'summaryBelow', + lc_xml_attr_summaryright TYPE string VALUE 'summaryRight', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_showgridlines TYPE string VALUE 'showGridLines', + lc_xml_attr_showrowcolheaders TYPE string VALUE 'showRowColHeaders', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_min TYPE string VALUE 'min', + lc_xml_attr_max TYPE string VALUE 'max', + lc_xml_attr_hidden TYPE string VALUE 'hidden', + lc_xml_attr_width TYPE string VALUE 'width', + lc_xml_attr_defaultwidth TYPE string VALUE '9.10', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_true TYPE string VALUE 'true', + lc_xml_attr_bestfit TYPE string VALUE 'bestFit', + lc_xml_attr_customheight TYPE string VALUE 'customHeight', + lc_xml_attr_customwidth TYPE string VALUE 'customWidth', + lc_xml_attr_collapsed TYPE string VALUE 'collapsed', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_defaultcolwidth TYPE string VALUE 'defaultColWidth', + lc_xml_attr_outlinelevelrow TYPE string VALUE 'x14ac:outlineLevelRow', + lc_xml_attr_outlinelevelcol TYPE string VALUE 'x14ac:outlineLevelCol', + lc_xml_attr_outlinelevel TYPE string VALUE 'outlineLevel', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + lc_xml_attr_allowblank TYPE string VALUE 'allowBlank', + lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage', + lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage', + lc_xml_attr_count TYPE string VALUE 'count', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + lc_xml_node_comp_ns TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006', + lc_xml_node_comp_pref TYPE string VALUE 'x14ac', + lc_xml_node_ig_ns TYPE string VALUE 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_value TYPE string, + t_range_merge TYPE string_table, + lv_merge TYPE string, + lv_column_p TYPE zexcel_cell_column_alpha, + lv_column TYPE zexcel_cell_column, + lv_flag TYPE c, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + lv_cell_row_s TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + DATA: default_col_dimension TYPE REF TO zcl_excel_worksheet_columndime, + default_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data, + <fs_range_merge> LIKE LINE OF t_range_merge. + DATA: column_dimensions TYPE zexcel_t_worksheet_columndime. + FIELD-SYMBOLS: <column_dimension> LIKE LINE OF column_dimensions. + DATA: row_dimensions TYPE zexcel_t_worksheet_rowdimensio. + FIELD-SYMBOLS: <row_dimension> LIKE LINE OF row_dimensions. + DATA: outline_level_row TYPE i VALUE 0, + outline_level_col TYPE i VALUE 0. + DATA: col_count TYPE int4. + DATA: row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + DATA: write_current_row TYPE boolean. +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:mc' + value = lc_xml_node_comp_ns ). + lo_element_root->set_attribute_ns( name = 'mc:Ignorable' + value = lc_xml_node_comp_pref ). + lo_element_root->set_attribute_ns( name = 'xmlns:x14ac' + value = lc_xml_node_ig_ns ). + + +********************************************************************** +* STEP 4: Create subnodes + " sheetPr + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetpr + parent = lo_document ). + " TODO tabColor + + " outlinePr + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_outlinepr + parent = lo_document ). + " TODO read attribute summaryBelow and set the attribute to 0 + lo_element_2->set_attribute_ns( name = lc_xml_attr_summarybelow + value = '1' ). + " TODO read attribute summaryRight and set the attribute to 0 + lo_element_2->set_attribute_ns( name = lc_xml_attr_summaryright + value = '1' ). + + lo_element->append_child( lo_element_2 ). + " TODO pageSetUpPr + + lo_element_root->append_child( lo_element ). + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + " showGridLines attribute + lo_element_2->set_attribute_ns( name = lc_xml_attr_showgridlines + value = 'true' ). + " showRowColHeaders attribute + lo_element_2->set_attribute_ns( name = lc_xml_attr_showrowcolheaders + value = '1' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + column_dimensions[] = io_worksheet->get_column_dimensions( ). + row_dimensions[] = io_worksheet->get_row_dimensions( ). + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + " defaultRowHeight + default_row_dimension = io_worksheet->get_default_row_dimension( ). + IF default_row_dimension IS BOUND. + IF default_row_dimension->get_row_height( ) >= 0. + lo_element->set_attribute_ns( name = lc_xml_attr_customheight + value = lc_xml_attr_true ). + lv_value = default_row_dimension->get_row_height( ). + ELSE. + lv_value = '12.75'. + ENDIF. + ELSE. + lv_value = '12.75'. + ENDIF. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + " defaultColWidth + default_col_dimension = io_worksheet->get_default_column_dimension( ). + IF default_col_dimension IS BOUND. + IF default_col_dimension->get_width( ) >= 0. + lv_value = default_col_dimension->get_width( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultcolwidth + value = lv_value ). + ENDIF. + ENDIF. + " outlineLevelRow + LOOP AT row_dimensions ASSIGNING <row_dimension>. + IF <row_dimension>-row_dimension->get_outline_level( ) > outline_level_row. + outline_level_row = <row_dimension>-row_dimension->get_outline_level( ). + ENDIF. + ENDLOOP. + lv_value = outline_level_row. + lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelrow + value = lv_value ). + " outlineLevelCol + LOOP AT column_dimensions ASSIGNING <column_dimension>. + IF <column_dimension>-column_dimension->get_outline_level( ) > outline_level_col. + outline_level_col = <column_dimension>-column_dimension->get_outline_level( ). + ENDIF. + ENDLOOP. + lv_value = outline_level_col. + lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelcol + value = lv_value ). + + lo_element_root->append_child( lo_element ). " sheetFormatPr node + " cols node + IF NOT column_dimensions IS INITIAL. + lo_element = lo_document->create_simple_element( name = lc_xml_node_cols + parent = lo_document ). + LOOP AT column_dimensions ASSIGNING <column_dimension>. + " col node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_col + parent = lo_document ). + lv_value = <column_dimension>-column_dimension->get_column_index( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_min + value = lv_value ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_max + value = lv_value ). + " Width + IF <column_dimension>-column_dimension->get_width( ) < 0. + lo_element_2->set_attribute_ns( name = lc_xml_attr_width + value = lc_xml_attr_defaultwidth ). + ELSE. + lv_value = <column_dimension>-column_dimension->get_width( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_width + value = lv_value ). + ENDIF. + " Column visibility + IF <column_dimension>-column_dimension->get_visible( ) = abap_false. + lo_element_2->set_attribute_ns( name = lc_xml_attr_hidden + value = lc_xml_attr_true ). + ENDIF. + " Auto size? + IF <column_dimension>-column_dimension->get_auto_size( ) = abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_bestfit + value = lc_xml_attr_true ). + ENDIF. + " Custom width? + IF default_col_dimension IS BOUND. + IF <column_dimension>-column_dimension->get_width( ) + <> default_col_dimension->get_width( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_customwidth + value = lc_xml_attr_true ). + + ENDIF. + ELSE. + lo_element_2->set_attribute_ns( name = lc_xml_attr_customwidth + value = lc_xml_attr_true ). + ENDIF. + " Collapsed + IF <column_dimension>-column_dimension->get_collapsed( ) = abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_collapsed + value = lc_xml_attr_true ). + ENDIF. + " outlineLevel + IF <column_dimension>-column_dimension->get_outline_level( ) > 0. + lv_value = <column_dimension>-column_dimension->get_outline_level( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_outlinelevel + value = lv_value ). + ENDIF. + " Style + lv_value = <column_dimension>-column_dimension->get_xf_index( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + + lo_element->append_child( lo_element_2 ). " col node + ENDLOOP. + ENDIF. + lo_element_root->append_child( lo_element ). " cols node + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + " Get column count + col_count = io_worksheet->get_highest_column( ). + + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + " Add new row + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + " r + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + " Spans + lv_value = col_count. + CONCATENATE '1:' lv_value INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = lv_value ). + row_dimension = io_worksheet->get_row_dimension( <ls_sheet_content>-cell_row ). + " Do we need the row dimension attributes? + IF row_dimension->get_row_height( ) >= 0 OR + row_dimension->get_visible( ) = abap_false OR + row_dimension->get_collapsed( ) = abap_true OR + row_dimension->get_outline_level( ) > 0 OR + row_dimension->get_xf_index( ) <> 0. + " Row dimensions + IF row_dimension->get_row_height( ) >= 0. + lo_element_2->set_attribute_ns( name = 'customHeight' value = '1'). + lv_value = row_dimension->get_row_height( ). + lo_element_2->set_attribute_ns( name = 'ht' value = lv_value ). + ENDIF. + " Row visibility + IF row_dimension->get_visible( ) = abap_false. + lo_element_2->set_attribute_ns( name = 'hidden' value = 'true'). + ENDIF. + " Collapsed + IF row_dimension->get_collapsed( ) = abap_true. + lo_element_2->set_attribute_ns( name = 'collapsed' value = 'true'). + ENDIF. + " Outline level + IF row_dimension->get_outline_level( ) > 0. + lv_value = row_dimension->get_outline_level( ). + lo_element_2->set_attribute_ns( name = 'outlineLevel' value = lv_value ). + ENDIF. + " Style + IF row_dimension->get_xf_index( ) <> 0. + lv_value = row_dimension->get_xf_index( ). + lo_element_2->set_attribute_ns( name = 's' value = lv_value ). + lo_element_2->set_attribute_ns( name = 'customFormat' value = '1'). + ENDIF. + ENDIF. + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + + " For cells with formula ignore the value - Excel will calculate it + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ELSE. + IF <ls_sheet_content>-data_type IS NOT INITIAL. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = <ls_sheet_content>-data_type ). + ENDIF. + + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF <ls_sheet_content>-data_type EQ 's'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + ENDIF. + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + + + IF io_worksheet->get_data_validations_size( ) GT 0. + " dataValidations node + lo_element = lo_document->create_simple_element( name = lc_xml_node_datavalidations + parent = lo_document ). + " Conditional formatting node + lo_iterator = io_worksheet->get_data_validations_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_data_validation ?= lo_iterator->get_next( ). + " dataValidation node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_datavalidation + parent = lo_document ). + lv_value = lo_data_validation->type. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + IF lo_data_validation->allowblank EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_allowblank + value = lv_value ). + IF lo_data_validation->showinputmessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showinputmessage + value = lv_value ). + IF lo_data_validation->showerrormessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showerrormessage + value = lv_value ). + lv_cell_row_s = lo_data_validation->cell_row. + SHIFT lv_cell_row_s RIGHT DELETING TRAILING space. + SHIFT lv_cell_row_s LEFT DELETING LEADING space. + CONCATENATE lo_data_validation->cell_column lv_cell_row_s INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + " formula1 node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula1 + parent = lo_document ). + lv_value = lo_data_validation->value. + lo_element_3->set_value( lv_value ). + + lo_element_2->append_child( lo_element_3 ). " formula1 node + + lo_element->append_child( lo_element_2 ). " dataValidation node + ENDWHILE. + lo_element_root->append_child( lo_element ). " dataValidations node + ENDIF. + + t_range_merge = io_worksheet->get_merge( ). + IF t_range_merge IS NOT INITIAL. + lo_element = lo_document->create_simple_element( name = lc_xml_node_mergecells + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + LOOP AT t_range_merge ASSIGNING <fs_range_merge>. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_mergecell + parent = lo_document ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_ref + value = <fs_range_merge> ). + lo_element->append_child( lo_element_2 ). + lo_element_root->append_child( lo_element ). + io_worksheet->delete_merge( ). + ENDLOOP. + ENDIF. + + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +* tables + DATA lv_table_count TYPE i. + + lv_table_count = io_worksheet->get_tables_size( ). + IF lv_table_count > 0. + lo_element = lo_document->create_simple_element( name = 'tableParts' + parent = lo_document ). + lv_value = lv_table_count. + CONDENSE lv_value. + lo_element->set_attribute_ns( name = 'count' + value = lv_value ). + + lv_table_count = 0. + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_iterator->get_next( ). + add 1 to lv_table_count. + + lv_value = lv_table_count. + condense lv_value. + CONCATENATE 'rId' lv_value INTO lv_value. + lo_element_2 = lo_document->create_simple_element( name = 'tablePart' + parent = lo_element ). + lo_element_2->set_attribute_ns( name = 'r:id' + value = lv_value ). + lo_element->append_child( lo_element_2 ). + + ENDWHILE. + + lo_element_root->append_child( lo_element ). + + ENDIF. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + method CREATE_XL_SHEET_RELS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + lc_xml_node_rid_table_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_value TYPE string, + lv_counter TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Add sheet Relationship nodes here + lv_counter = 0. + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_iterator->get_next( ). + ADD 1 TO lv_counter. + + lv_value = lv_counter. + CONDENSE lv_value. + CONCATENATE 'rId' lv_value INTO lv_value. + + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_table_tp ). + + lv_value = lo_table->get_name( ). + CONCATENATE '../tables/' lv_value '.xml' INTO lv_value. + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_value ). + lo_element_root->append_child( lo_element ). + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_STYLES. + + +** Constant node name + DATA: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " numfmt + lc_xml_node_numfmts TYPE string VALUE 'numFmts', + lc_xml_node_numfmt TYPE string VALUE 'numFmt', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + lc_xml_node_alignment TYPE string VALUE 'alignment', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + lc_xml_attr_applyalignment TYPE string VALUE 'applyAlignment', + lc_xml_attr_horizontal TYPE string VALUE 'horizontal', + lc_xml_attr_formatcode TYPE string VALUE 'formatCode', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_numfmts TYPE REF TO if_ixml_element, + lo_element_numfmt TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + lt_numfmts TYPE zexcel_t_style_numfmt, + ls_numfmt TYPE zexcel_s_style_numfmt, + lt_alignments TYPE zexcel_t_style_alignment, + ls_alignment TYPE zexcel_s_style_alignment, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i, + lv_align_flag TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + + lo_element_numfmts = lo_document->create_simple_element( name = lc_xml_node_numfmts + parent = lo_document ). + + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_alignment = lo_style->alignment->get_structure( ). + ls_numfmt = lo_style->number_format->get_structure( ). + + CLEAR ls_cellxfs. + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress alignment + READ TABLE lt_alignments FROM ls_alignment TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-alignmentid = sy-tabix. + ELSE. + APPEND ls_alignment TO lt_alignments. + DESCRIBE TABLE lt_alignments LINES ls_cellxfs-alignmentid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-alignmentid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + +* Compress number formats + IF ls_numfmt IS NOT INITIAL. + READ TABLE lt_numfmts FROM ls_numfmt TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-numfmtid = sy-tabix. + ELSE. + APPEND ls_numfmt TO lt_numfmts. + DESCRIBE TABLE lt_numfmts LINES ls_cellxfs-numfmtid. + ENDIF. + ADD zcl_excel_common=>c_excel_numfmt_offset TO ls_cellxfs-numfmtid. " Add OXML offset for custom styles + ls_cellxfs-applynumberformat = 1. + ELSE. + ls_cellxfs-applynumberformat = 0. + ENDIF. + + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-alignmentid NE 0. + ls_cellxfs-applyalignment = 1. + ELSE. + ls_cellxfs-applyalignment = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create numfmt elements + LOOP AT lt_numfmts INTO ls_numfmt. + lo_element_numfmt = lo_document->create_simple_element( name = lc_xml_node_numfmt + parent = lo_document ). + lv_value = sy-tabix + zcl_excel_common=>c_excel_numfmt_offset. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_numfmt->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + lv_value = ls_numfmt-numfmt. + lo_element_numfmt->set_attribute_ns( name = lc_xml_attr_formatcode + value = lv_value ). + lo_element_numfmts->append_child( lo_element_numfmt ). + ENDLOOP. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_numfmts ). + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyalignment EQ 1. " depends on each style not for all the sheet + MOVE ls_cellxfs-applyalignment TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyalignment + value = lv_value ). + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_alignment + parent = lo_document ). + ADD 1 TO ls_cellxfs-alignmentid. "Table index starts from 1 + READ TABLE lt_alignments INTO ls_alignment INDEX ls_cellxfs-alignmentid. + SUBTRACT 1 FROM ls_cellxfs-alignmentid. + MOVE ls_alignment-horizontal TO lv_value. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_horizontal + value = lv_value ). + lo_element->append_child( lo_sub_element_2 ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = '0' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = '0' ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = 'TableStyleMedium9' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = 'PivotStyleLight16' ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + METHOD create_xl_table. + + DATA: lc_xml_node_table TYPE string VALUE 'table', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_display_name TYPE string VALUE 'displayName', + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_totals TYPE string VALUE 'totalsRowShown', + " Node namespace + lc_xml_node_table_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + + lv_table_name TYPE string, + lv_id TYPE i, + lv_syindex TYPE char3, + lv_ref TYPE string, + lv_value TYPE string, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lv_num_columns TYPE i, + ls_fieldcat TYPE zexcel_s_fieldcatalog. + + +********************************************************************** +* STEP 1: Create xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node table + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_table + parent = lo_document ). + + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_table_ns ). + + lv_id = io_table->get_id( ). + lv_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_id ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_id + value = lv_value ). + + lv_table_name = io_table->get_name( ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_name + value = lv_table_name ). + + lo_element_root->set_attribute_ns( name = lc_xml_attr_display_name + value = lv_table_name ). + + lv_ref = io_table->get_reference( ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_ref + value = lv_ref ). + IF io_table->has_totals( ) = abap_true. + lo_element_root->set_attribute_ns( name = 'totalsRowCount' + value = '1' ). + ELSE. + lo_element_root->set_attribute_ns( name = lc_xml_attr_totals + value = '0' ). + ENDIF. + +********************************************************************** +* STEP 4: Create subnodes + + " autoFilter + lo_element = lo_document->create_simple_element( name = 'autoFilter' + parent = lo_document ). + + lv_ref = io_table->get_reference( ip_include_totals_row = abap_false ). + lo_element->set_attribute_ns( name = 'ref' + value = lv_ref ). + + lo_element_root->append_child( lo_element ). + + "columns + lo_element = lo_document->create_simple_element( name = 'tableColumns' + parent = lo_document ). + +* lo_columns = io_table->get_columns( ). + LOOP AT io_table->fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true. + ADD 1 TO lv_num_columns. + ENDLOOP. + + lv_value = lv_num_columns. + CONDENSE lv_value. + lo_element->set_attribute_ns( name = 'count' + value = lv_value ). + + lo_element_root->append_child( lo_element ). + + LOOP AT io_table->fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true. + lo_element2 = lo_document->create_simple_element_ns( name = 'tableColumn' + parent = lo_element ). + + lv_value = ls_fieldcat-position. + SHIFT lv_value LEFT DELETING LEADING '0'. + lo_element2->set_attribute_ns( name = 'id' + value = lv_value ). + lv_value = ls_fieldcat-scrtext_m. + lo_element2->set_attribute_ns( name = 'name' + value = lv_value ). + + IF ls_fieldcat-totals_function IS NOT INITIAL. + lo_element2->set_attribute_ns( name = 'totalsRowFunction' + value = ls_fieldcat-totals_function ). + ENDIF. + + lo_element->append_child( lo_element2 ). + ENDLOOP. + + + lo_element = lo_document->create_simple_element( name = 'tableStyleInfo' + parent = lo_element_root ). + + lo_element->set_attribute_ns( name = 'name' + value = io_table->settings-table_style ). + + lo_element->set_attribute_ns( name = 'showFirstColumn' + value = '0' ). + + lo_element->set_attribute_ns( name = 'showLastColumn' + value = '0' ). + + IF io_table->settings-show_row_stripes = abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + + lo_element->set_attribute_ns( name = 'showRowStripes' + value = lv_value ). + + IF io_table->settings-show_column_stripes = abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + + lo_element->set_attribute_ns( name = 'showColumnStripes' + value = lv_value ). + + lo_element_root->append_child( lo_element ). +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + method CREATE_XL_THEME. + + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +endmethod. + + + + method CREATE_XL_WORKBOOK. + + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + lc_xml_node_definednames TYPE string VALUE 'definedNames', + lc_xml_node_definedname TYPE string VALUE 'definedName', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + + " ranges node + lo_element = lo_document->create_simple_element( name = lc_xml_node_definedNames + parent = lo_document ). + lo_iterator = excel->get_ranges_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " range node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_definedName + parent = lo_document ). + lo_range ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_range->name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lv_value = lo_range->get_value( ). + lo_sub_element->set_value( lv_value ). + lo_element->append_child( lo_sub_element ). " range node + ENDWHILE. + lo_element_root->append_child( lo_element )." ranges node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + method FLAG2BOOL. + + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +endmethod. + + + + + method GET_SHARED_STRING_INDEX. + + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +endmethod. + + + + + + + + + + class ZCL_EXCEL definition + public + final + create public . + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! +public section. + + data PROPERTIES type ref to ZCL_EXCEL_PROPERTIES . + data SECURITY type ref to ZCL_EXCEL_SECURITY . + + methods ADD_NEW_DRAWING + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_DRAWING) type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_RANGE + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods ADD_NEW_STYLE + returning + value(EO_STYLE) type ref to ZCL_EXCEL_STYLE . + methods ADD_NEW_WORKSHEET + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods CONSTRUCTOR . + methods GET_ACTIVE_WORKSHEET + returning + value(EO_WORKSHEET) type ref to ZCL_EXCEL_WORKSHEET . + methods GET_DRAWINGS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_RANGES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_WORKSHEETS_NAME + returning + value(EP_NAME) type ZEXCEL_WORKSHEETS_NAME . + methods GET_WORKSHEETS_SIZE + returning + value(EP_SIZE) type I . + methods GET_NEXT_TABLE_ID + returning + value(EP_ID) type I . + *"* protected components of class ZCL_EXCEL +*"* do not include other source files here!!! +protected 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 . + data STYLES type ref to ZCL_EXCEL_STYLES . + data WORKSHEETS type ref to ZCL_EXCEL_WORKSHEETS . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + + + + + + + + + method ADD_NEW_DRAWING. + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_title = ip_title. + drawings->add( eo_drawing ). +endmethod. + + + + method ADD_NEW_RANGE. +* Create default blank range + CREATE OBJECT eo_range. + ranges->add( eo_range ). +endmethod. + + + + method ADD_NEW_STYLE. +* Create default style + CREATE OBJECT eo_style. + styles->add( eo_style ). + +endmethod. + + + + + method ADD_NEW_WORKSHEET. + DATA: lv_guid TYPE guid_16. +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_excel = me + ip_title = ip_title. + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). +endmethod. + + + method CONSTRUCTOR. + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_style TYPE REF TO zcl_excel_style. + +* Inizialize instance objects + CREATE OBJECT properties. + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings. + + 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. + + + + method GET_ACTIVE_WORKSHEET. + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + +endmethod. + + + + method GET_DRAWINGS_ITERATOR. + + eo_iterator = me->drawings->get_iterator( ). + +endmethod. + + + + method GET_NEXT_TABLE_ID. + DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lv_tables_count TYPE i. + + lo_iterator = me->get_worksheets_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->get_next( ). + + lv_tables_count = lo_worksheet->get_tables_size( ). + ADD lv_tables_count TO ep_id. + + ENDWHILE. + + ADD 1 TO ep_id. + +endmethod. + + + + method GET_RANGES_ITERATOR. + + eo_iterator = me->ranges->get_iterator( ). + +endmethod. + + + + method GET_STYLES_ITERATOR. + + eo_iterator = me->styles->get_iterator( ). + +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( ). + +endmethod. + + + diff --git a/nuggs/NUGG_ABAP2XLSX_V_2_1.nugg.zip b/nuggs/NUGG_ABAP2XLSX_V_2_1.nugg.zip new file mode 100644 index 0000000..7e093c6 Binary files /dev/null and b/nuggs/NUGG_ABAP2XLSX_V_2_1.nugg.zip differ diff --git a/nuggs/NUGG_ABAP2XLSX_V_3_0.nugg b/nuggs/NUGG_ABAP2XLSX_V_3_0.nugg new file mode 100644 index 0000000..cc04a8a --- /dev/null +++ b/nuggs/NUGG_ABAP2XLSX_V_3_0.nugg @@ -0,0 +1,3559 @@ + + + + + + + + + *&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL13 +*& +*&---------------------------------------------------------------------* +*& Example by: Alvaro "Blag" Tejada Galindo. +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel14. + +DATA: lo_excel TYPE REF TO zcl_excel, + lo_excel_writer TYPE REF TO zif_excel_writer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lv_file TYPE xstring, + lv_bytecount TYPE i, + lt_file_tab TYPE STANDARD TABLE OF solisti1, + lo_style_center TYPE REF TO zcl_excel_style, + lo_style_right TYPE REF TO zcl_excel_style, + lo_style_left TYPE REF TO zcl_excel_style, + lo_style_general TYPE REF TO zcl_excel_style, + lo_style_bottom TYPE REF TO zcl_excel_style, + lo_style_middle TYPE REF TO zcl_excel_style, + lo_style_top TYPE REF TO zcl_excel_style, + lo_style_justify TYPE REF TO zcl_excel_style, + lo_style_mixed TYPE REF TO zcl_excel_style, + lo_style_rotated TYPE REF TO zcl_excel_style, + lo_style_shrink TYPE REF TO zcl_excel_style, + lo_style_indent TYPE REF TO zcl_excel_style, + lv_style_center_guid TYPE zexcel_cell_style, + lv_style_right_guid TYPE zexcel_cell_style, + lv_style_left_guid TYPE zexcel_cell_style, + lv_style_general_guid TYPE zexcel_cell_style, + lv_style_bottom_guid TYPE zexcel_cell_style, + lv_style_middle_guid TYPE zexcel_cell_style, + lv_style_top_guid TYPE zexcel_cell_style, + lv_style_justify_guid TYPE zexcel_cell_style, + lv_style_mixed_guid TYPE zexcel_cell_style, + lv_style_rotated_guid TYPE zexcel_cell_style, + lv_style_shrink_guid TYPE zexcel_cell_style, + lv_style_indent_guid TYPE zexcel_cell_style. + +DATA: lo_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + +CREATE OBJECT lo_excel. + +" Get active sheet +lo_worksheet = lo_excel->get_active_worksheet( ). +lo_worksheet->title = 'sheet1'. + +"Center +lo_style_center = lo_excel->add_new_style( ). +lo_style_center->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lv_style_center_guid = lo_style_center->get_guid( ). +"Right +lo_style_right = lo_excel->add_new_style( ). +lo_style_right->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_right. +lv_style_right_guid = lo_style_right->get_guid( ). +"Left +lo_style_left = lo_excel->add_new_style( ). +lo_style_left->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_left. +lv_style_left_guid = lo_style_left->get_guid( ). +"General +lo_style_general = lo_excel->add_new_style( ). +lo_style_general->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_general. +lv_style_general_guid = lo_style_general->get_guid( ). +"Bottom +lo_style_bottom = lo_excel->add_new_style( ). +lo_style_bottom->alignment->vertical = zcl_excel_style_alignment=>c_vertical_bottom. +lv_style_bottom_guid = lo_style_bottom->get_guid( ). +"Middle +lo_style_middle = lo_excel->add_new_style( ). +lo_style_middle->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. +lv_style_middle_guid = lo_style_middle->get_guid( ). +"Top +lo_style_top = lo_excel->add_new_style( ). +lo_style_top->alignment->vertical = zcl_excel_style_alignment=>c_vertical_top. +lv_style_top_guid = lo_style_top->get_guid( ). +"Justify +lo_style_justify = lo_excel->add_new_style( ). +lo_style_justify->alignment->vertical = zcl_excel_style_alignment=>c_vertical_justify. +lv_style_justify_guid = lo_style_justify->get_guid( ). + +"Shrink +lo_style_shrink = lo_excel->add_new_style( ). +lo_style_shrink->alignment->shrinktofit = abap_true. +lv_style_shrink_guid = lo_style_shrink->get_guid( ). + +"Indent +lo_style_indent = lo_excel->add_new_style( ). +lo_style_indent->alignment->indent = 5. +lv_style_indent_guid = lo_style_indent->get_guid( ). + +"Middle / Centered / Wrap +lo_style_mixed = lo_excel->add_new_style( ). +lo_style_mixed->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lo_style_mixed->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. +lo_style_mixed->alignment->wraptext = abap_true. +lv_style_mixed_guid = lo_style_mixed->get_guid( ). + +"Center +lo_style_rotated = lo_excel->add_new_style( ). +lo_style_rotated->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. +lo_style_rotated->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. +lo_style_rotated->alignment->textrotation = 165. " -75° == 90° + 75° +lv_style_rotated_guid = lo_style_rotated->get_guid( ). + + +" Set row size for first 7 rows to 40 +DO 7 TIMES. + lo_row_dimension = lo_worksheet->get_row_dimension( sy-index ). + lo_row_dimension->set_row_height( 40 ). +ENDDO. + +"Horizontal alignment +lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'Centered Text' ip_style = lv_style_center_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 'Right Text' ip_style = lv_style_right_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 'Left Text' ip_style = lv_style_left_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 'General Text' ip_style = lv_style_general_guid ). + +" Shrink & indent +lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'Text shrinked' ip_style = lv_style_shrink_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = 'Text indented' ip_style = lv_style_indent_guid ). + +"Vertical alignment + +lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'Bottom Text' ip_style = lv_style_bottom_guid ). +lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 'Middle Text' ip_style = lv_style_middle_guid ). +lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 'Top Text' ip_style = lv_style_top_guid ). +lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = 'Justify Text' ip_style = lv_style_justify_guid ). + +" Wrapped +lo_worksheet->set_cell( ip_row = 10 ip_column = 'B' + ip_value = 'This is a wrapped text centered in the middle' + ip_style = lv_style_mixed_guid ). + +" Rotated +lo_worksheet->set_cell( ip_row = 10 ip_column = 'D' + ip_value = 'This is a centered text rotated by -75°' + ip_style = lv_style_rotated_guid ). + +CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. +lv_file = lo_excel_writer->write_file( lo_excel ). + +"convert to table +CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = lv_file + IMPORTING + output_length = lv_bytecount + TABLES + binary_tab = lt_file_tab. +"Save the file +CALL FUNCTION 'GUI_DOWNLOAD' + EXPORTING + bin_filesize = lv_bytecount + filename = 'C:\Alignment.xlsx' + filetype = 'BIN' + TABLES + data_tab = lt_file_tab. + + + + class ZCL_EXCEL_WRITER_2007 definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +public section. + + interfaces ZIF_EXCEL_WRITER . + *"* protected components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_WRITER_2007 +*"* do not include other source files here!!! +private section. + + constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT + constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT + constants C_DOCPROPS_CORE type STRING value 'docProps/core.xml'. "#EC NOTEXT + constants C_RELATIONSHIPS type STRING value '_rels/.rels'. "#EC NOTEXT + constants C_XL_RELATIONSHIPS type STRING value 'xl/_rels/workbook.xml.rels'. "#EC NOTEXT + constants C_XL_SHAREDSTRINGS type STRING value 'xl/sharedStrings.xml'. "#EC NOTEXT + constants C_XL_SHEET type STRING value 'xl/worksheets/sheet#.xml'. "#EC NOTEXT + constants C_XL_SHEET_RELS type STRING value 'xl/worksheets/_rels/sheet#.xml.rels'. "#EC NOTEXT + constants C_XL_STYLES type STRING value 'xl/styles.xml'. "#EC NOTEXT + constants C_XL_THEME type STRING value 'xl/theme/theme1.xml'. "#EC NOTEXT + constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL . + data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . + data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . + + methods CREATE + returning + value(EP_EXCEL) type XSTRING . + methods CREATE_CONTENT_TYPES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_APP + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_DOCPROPS_CORE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_RELATIONSHIPS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHAREDSTRINGS + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + !IV_ACTIVE type FLAG default '' + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_SHEET_RELS + importing + !IO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_THEME + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_TABLE + importing + !IO_TABLE type ref to ZCL_EXCEL_TABLE + returning + value(EP_CONTENT) type XSTRING . + methods CREATE_XL_WORKBOOK + returning + value(EP_CONTENT) type XSTRING . + methods FLAG2BOOL + importing + !IP_FLAG type FLAG + returning + value(EP_BOOLEAN) type CHAR5 . + methods GET_SHARED_STRING_INDEX + importing + !IP_CELL_VALUE type ZEXCEL_CELL_VALUE + returning + value(EP_INDEX) type INT4 . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* 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. + ep_file = me->create( ). +ENDMETHOD. + + + + method CREATE. + + +* Office 2007 file format is a cab of several xml files with extension .xlsx + + DATA: lo_zip TYPE REF TO cl_abap_zip, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_active_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_nested_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_content TYPE xstring, + lv_active TYPE flag, + lv_xl_sheet TYPE string, + lv_xl_sheet_rels TYPE string, + lv_syindex TYPE string, + lv_value TYPE string. + + +********************************************************************** +* STEP 1: Create archive object file (ZIP) + CREATE OBJECT lo_zip. + +********************************************************************** +* STEP 2: Add [Content_Types].xml to zip + lv_content = me->create_content_types( ). + lo_zip->add( name = me->c_content_types + content = lv_content ). + +********************************************************************** +* STEP 3: Add _rels/.rels to zip + lv_content = me->create_relationships( ). + lo_zip->add( name = me->c_relationships + content = lv_content ). + +********************************************************************** +* STEP 4: Add docProps/app.xml to zip + lv_content = me->create_docprops_app( ). + lo_zip->add( name = me->c_docprops_app + content = lv_content ). + +********************************************************************** +* STEP 5: Add docProps/core.xml to zip + lv_content = me->create_docprops_core( ). + lo_zip->add( name = me->c_docprops_core + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_relationships( ). + lo_zip->add( name = me->c_xl_relationships + content = lv_content ). + +********************************************************************** +* STEP 6: Add xl/_rels/workbook.xml.rels to zip + lv_content = me->create_xl_theme( ). + lo_zip->add( name = me->c_xl_theme + content = lv_content ). + +********************************************************************** +* STEP 7: Add xl/workbook.xml to zip + lv_content = me->create_xl_workbook( ). + lo_zip->add( name = me->c_xl_workbook + content = lv_content ). + +********************************************************************** +* STEP 8: Add xl/workbook.xml to zip +* lv_content = me->create_xl_styles_static( ). + lv_content = me->create_xl_styles( ). + lo_zip->add( name = me->c_xl_styles + content = lv_content ). + +********************************************************************** +* STEP 9: Add sharedStrings.xml to zip + lv_content = me->create_xl_sharedstrings( ). + lo_zip->add( name = me->c_xl_sharedstrings + content = lv_content ). + +********************************************************************** +* STEP 10: Add sheet#.xml to zip + lo_iterator = me->excel->get_worksheets_iterator( ). + lo_active_worksheet = me->excel->get_active_worksheet( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF lo_active_worksheet->get_guid( ) EQ lo_worksheet->get_guid( ). + lv_active = abap_true. + ELSE. + lv_active = abap_true. + ENDIF. + + lv_content = me->create_xl_sheet( io_worksheet = lo_worksheet + iv_active = lv_active ). + lv_xl_sheet = me->c_xl_sheet. + MOVE sy-index TO lv_syindex. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet + content = lv_content ). + + lv_xl_sheet_rels = me->c_xl_sheet_rels. + lv_content = me->create_xl_sheet_rels( lo_worksheet ). + REPLACE ALL OCCURRENCES OF '#' IN lv_xl_sheet_rels WITH lv_syindex. + lo_zip->add( name = lv_xl_sheet_rels + content = lv_content ). + + lo_nested_iterator = lo_worksheet->get_tables_iterator( ). + + WHILE lo_nested_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_table ?= lo_nested_iterator->if_object_collection_iterator~get_next( ). + lv_content = me->create_xl_table( lo_table ). + + lv_value = lo_table->get_name( ). + CONCATENATE 'xl/tables/' lv_value '.xml' into lv_value. + lo_zip->add( name = lv_value + content = lv_content ). + ENDWHILE. + ENDWHILE. + +********************************************************************** +* STEP 11: Create the final zip + ep_excel = lo_zip->save( ). + +endmethod. + + + + method CREATE_CONTENT_TYPES. + + +** Constant node name + DATA: lc_xml_node_types TYPE string VALUE 'Types', + lc_xml_node_override TYPE string VALUE 'Override', + lc_xml_node_default TYPE string VALUE 'Default', + " Node attributes + lc_xml_attr_partname TYPE string VALUE 'PartName', + lc_xml_attr_extension TYPE string VALUE 'Extension', + lc_xml_attr_contenttype TYPE string VALUE 'ContentType', + " Node namespace + lc_xml_node_types_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/content-types', + " Node extension + lc_xml_node_rels_ext TYPE string VALUE 'rels', + lc_xml_node_xml_ext TYPE string VALUE 'xml', + " Node partnumber + lc_xml_node_theme_pn TYPE string VALUE '/xl/theme/theme1.xml', + lc_xml_node_styles_pn TYPE string VALUE '/xl/styles.xml', + lc_xml_node_workb_pn TYPE string VALUE '/xl/workbook.xml', + lc_xml_node_props_pn TYPE string VALUE '/docProps/app.xml', + lc_xml_node_worksheet_pn TYPE string VALUE '/xl/worksheets/sheet#.xml', + lc_xml_node_strings_pn TYPE string VALUE '/xl/sharedStrings.xml', + lc_xml_node_core_pn TYPE string VALUE '/docProps/core.xml', + " Node contentType + lc_xml_node_theme_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.theme+xml', + lc_xml_node_styles_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + lc_xml_node_workb_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', + lc_xml_node_rels_ct TYPE string VALUE 'application/vnd.openxmlformats-package.relationships+xml', + lc_xml_node_xml_ct TYPE string VALUE 'application/xml', + lc_xml_node_props_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + lc_xml_node_worksheet_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + lc_xml_node_strings_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + lc_xml_node_core_ct TYPE string VALUE 'application/vnd.openxmlformats-package.core-properties+xml', + lc_xml_node_table_ct TYPE string VALUE 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_nested_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_worksheets_num TYPE i, + lv_worksheets_numc TYPE numc3, + lv_xml_node_worksheet_pn TYPE string, + lv_xml_size TYPE i, + lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node types + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_types + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_types_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_theme_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_theme_ct ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_styles_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_styles_ct ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_rels_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_rels_ct ). + lo_element_root->append_child( lo_element ). + + " extension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_default + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_extension + value = lc_xml_node_xml_ext ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_xml_ct ). + lo_element_root->append_child( lo_element ). + + " Workbook node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_workb_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_workb_ct ). + lo_element_root->append_child( lo_element ). + + " Properties node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_props_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_props_ct ). + lo_element_root->append_child( lo_element ). + + " Worksheet node + lv_worksheets_num = excel->get_worksheets_size( ). + DO lv_worksheets_num TIMES. + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + + MOVE sy-index TO lv_worksheets_numc. + SHIFT lv_worksheets_numc LEFT DELETING LEADING '0'. + lv_xml_node_worksheet_pn = lc_xml_node_worksheet_pn. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_worksheet_pn WITH lv_worksheets_numc. + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_xml_node_worksheet_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_worksheet_ct ). + lo_element_root->append_child( lo_element ). + ENDDO. + + lo_iterator = me->excel->get_worksheets_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->get_next( ). + + lo_nested_iterator = lo_worksheet->get_tables_iterator( ). + + WHILE lo_nested_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_nested_iterator->get_next( ). + + lv_value = lo_table->get_name( ). + CONCATENATE '/xl/tables/' lv_value '.xml' INTO lv_value. + + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_table_ct ). + lo_element_root->append_child( lo_element ). + ENDWHILE. + ENDWHILE. + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_strings_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_strings_ct ). + lo_element_root->append_child( lo_element ). + + " Strings node + lo_element = lo_document->create_simple_element( name = lc_xml_node_override + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_partname + value = lc_xml_node_core_pn ). + lo_element->set_attribute_ns( name = lc_xml_attr_contenttype + value = lc_xml_node_core_ct ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_APP. + + +** Constant node name + DATA: lc_xml_node_properties TYPE string VALUE 'Properties', + lc_xml_node_application TYPE string VALUE 'Application', + lc_xml_node_docsecurity TYPE string VALUE 'DocSecurity', + lc_xml_node_scalecrop TYPE string VALUE 'ScaleCrop', + lc_xml_node_headingpairs TYPE string VALUE 'HeadingPairs', + lc_xml_node_vector TYPE string VALUE 'vector', + lc_xml_node_variant TYPE string VALUE 'variant', + lc_xml_node_lpstr TYPE string VALUE 'lpstr', + lc_xml_node_i4 TYPE string VALUE 'i4', + lc_xml_node_titlesofparts TYPE string VALUE 'TitlesOfParts', + lc_xml_node_company TYPE string VALUE 'Company', + lc_xml_node_linksuptodate TYPE string VALUE 'LinksUpToDate', + lc_xml_node_shareddoc TYPE string VALUE 'SharedDoc', + lc_xml_node_hyperlinkschanged TYPE string VALUE 'HyperlinksChanged', + lc_xml_node_appversion TYPE string VALUE 'AppVersion', + " Namespace prefix + lc_vt_ns TYPE string VALUE 'vt', + lc_xml_node_props_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties', + lc_xml_node_props_vt_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes', + " Node attributes + lc_xml_attr_size TYPE string VALUE 'size', + lc_xml_attr_basetype TYPE string VALUE 'baseType'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element_vector TYPE REF TO if_ixml_element, + lo_sub_element_variant TYPE REF TO if_ixml_element, + lo_sub_element_lpstr TYPE REF TO if_ixml_element, + lo_sub_element_i4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node properties + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_properties + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_props_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:vt' + value = lc_xml_node_props_vt_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Application + lo_element = lo_document->create_simple_element( name = lc_xml_node_application + parent = lo_document ). + lv_value = excel->properties->application. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " DocSecurity + lo_element = lo_document->create_simple_element( name = lc_xml_node_docsecurity + parent = lo_document ). + lv_value = excel->properties->docsecurity. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " HeadingPairs + lo_element = lo_document->create_simple_element( name = lc_xml_node_headingpairs + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = '2' ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_variant ). + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_name( ). + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_lpstr ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + " ** variant node + lo_sub_element_variant = lo_document->create_simple_element_ns( name = lc_xml_node_variant + prefix = lc_vt_ns + parent = lo_document ). + + " *** i4 node + lo_sub_element_i4 = lo_document->create_simple_element_ns( name = lc_xml_node_i4 + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_i4->set_value( lv_value ). + lo_sub_element_variant->append_child( lo_sub_element_i4 ). " lpstr node + + lo_sub_element_vector->append_child( lo_sub_element_variant ). " variant node + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " HeadingPairs + + + " TitlesOfParts + lo_element = lo_document->create_simple_element( name = lc_xml_node_titlesofparts + parent = lo_document ). + + + " * vector node + lo_sub_element_vector = lo_document->create_simple_element_ns( name = lc_xml_node_vector + prefix = lc_vt_ns + parent = lo_document ). + lv_value = excel->get_worksheets_size( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_size + value = lv_value ). + lo_sub_element_vector->set_attribute_ns( name = lc_xml_attr_basetype + value = lc_xml_node_lpstr ). + + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " ** lpstr node + lo_sub_element_lpstr = lo_document->create_simple_element_ns( name = lc_xml_node_lpstr + prefix = lc_vt_ns + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lo_sub_element_lpstr->set_value( lv_value ). + lo_sub_element_vector->append_child( lo_sub_element_lpstr ). " lpstr node + ENDWHILE. + + lo_element->append_child( lo_sub_element_vector ). " vector node + + lo_element_root->append_child( lo_element ). " TitlesOfParts + + + + " Company + lo_element = lo_document->create_simple_element( name = lc_xml_node_company + parent = lo_document ). + lv_value = excel->properties->company. + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_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 ). + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " AppVersion + lo_element = lo_document->create_simple_element( name = lc_xml_node_appversion + parent = lo_document ). + lv_value = excel->properties->appversion. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_DOCPROPS_CORE. + + +** Constant node name + DATA: lc_xml_node_coreproperties TYPE string VALUE 'coreProperties', + lc_xml_node_creator TYPE string VALUE 'creator', + lc_xml_node_lastmodifiedby TYPE string VALUE 'lastModifiedBy', + lc_xml_node_created TYPE string VALUE 'created', + lc_xml_node_modified TYPE string VALUE 'modified', + " Node attributes + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_target TYPE string VALUE 'dcterms:W3CDTF', + " Node namespace + 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_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/', + lc_xml_node_dcterms_ns TYPE string VALUE 'http://purl.org/dc/terms/', + lc_xml_node_dcmitype_ns TYPE string VALUE 'http://purl.org/dc/dcmitype/', + lc_xml_node_xsi_ns TYPE string VALUE 'http://www.w3.org/2001/XMLSchema-instance'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_value TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node coreProperties + lo_element_root = lo_document->create_simple_element_ns( name = lc_xml_node_coreproperties + prefix = lc_cp_ns + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns:cp' + value = lc_xml_node_cp_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dc' + value = lc_xml_node_dc_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcterms' + value = lc_xml_node_dcterms_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:dcmitype' + value = lc_xml_node_dcmitype_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:xsi' + value = lc_xml_node_xsi_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Creator node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " lastModifiedBy node + 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. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Created node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_created + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + + " Modified node + lo_element = lo_document->create_simple_element_ns( name = lc_xml_node_modified + prefix = lc_dcterms_ns + parent = lo_document ). + 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'. + lo_element->set_value( lv_value ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_RELATIONSHIPS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_rId1_id TYPE string VALUE 'rId1', + lc_xml_node_rId2_id TYPE string VALUE 'rId2', + lc_xml_node_rId3_id TYPE string VALUE 'rId3', + " Node type + lc_xml_node_rId1_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + lc_xml_node_rId2_tp TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lc_xml_node_rId3_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + " Node target + lc_xml_node_rId1_tg TYPE string VALUE 'xl/workbook.xml', + lc_xml_node_rId2_tg TYPE string VALUE 'docProps/core.xml', + lc_xml_node_rId3_tg TYPE string VALUE 'docProps/app.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + " Theme node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId3_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId3_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId3_tg ). + lo_element_root->append_child( lo_element ). + + " Styles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId2_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId2_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId2_tg ). + lo_element_root->append_child( lo_element ). + + " rels node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lc_xml_node_rId1_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rId1_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rId1_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_RELATIONSHIPS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#', + " Node type + lc_xml_node_rid_sheet_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lc_xml_node_rid_theme_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + lc_xml_node_rid_styles_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lc_xml_node_rid_shared_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + " Node target + lc_xml_node_ridx_tg TYPE string VALUE 'worksheets/sheet#.xml', + lc_xml_node_rid_shared_tg TYPE string VALUE 'sharedStrings.xml', + lc_xml_node_rid_styles_tg TYPE string VALUE 'styles.xml', + lc_xml_node_rid_theme_tg TYPE string VALUE 'theme/theme1.xml'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer. + + DATA: lv_xml_node_ridx_tg TYPE string, + lv_xml_node_ridx_id TYPE string, + lv_size TYPE i, + lv_syindex(2) TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lv_size = excel->get_worksheets_size( ). + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size + 2. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_styles_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_styles_tg ). + lo_element_root->append_child( lo_element ). + + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_size = lv_size - 1. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_theme_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_theme_tg ). + lo_element_root->append_child( lo_element ). + + lv_size = excel->get_worksheets_size( ). + + DO lv_size TIMES. + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + lv_xml_node_ridx_tg = lc_xml_node_ridx_tg. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_tg WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_sheet_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_xml_node_ridx_tg ). + lo_element_root->append_child( lo_element ). + ENDDO. + + " Relationship node + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + ADD 3 TO lv_size. + lv_syindex = lv_size. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_xml_node_ridx_id ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_shared_tp ). + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lc_xml_node_rid_shared_tg ). + lo_element_root->append_child( lo_element ). + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + method CREATE_XL_SHAREDSTRINGS. + + +** Constant node name + DATA: lc_xml_node_sst TYPE string VALUE 'sst', + lc_xml_node_si TYPE string VALUE 'si', + lc_xml_node_t TYPE string VALUE 't', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_uniquecount TYPE string VALUE 'uniqueCount', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + + DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted, + ls_shared_string TYPE zexcel_s_shared_string, + lv_value TYPE string, + lv_count_str TYPE string, + lv_uniquecount_str TYPE string, + lv_sytabix TYPE sytabix, + lv_count TYPE i, + lv_uniquecount TYPE i. + + FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data, + <fs_sheet_string> TYPE zexcel_s_shared_string. + +********************************************************************** +* STEP 1: Collect strings from each worksheet + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + APPEND LINES OF lo_worksheet->sheet_content TO lt_cell_data. + ENDWHILE. + + DELETE lt_cell_data WHERE cell_formula IS NOT INITIAL. " delete formula content + + DESCRIBE TABLE lt_cell_data LINES lv_count. + MOVE lv_count TO lv_count_str. + + SHIFT lv_count_str RIGHT DELETING TRAILING space. + SHIFT lv_count_str LEFT DELETING LEADING space. + + SORT lt_cell_data BY cell_value. + DELETE ADJACENT DUPLICATES FROM lt_cell_data COMPARING cell_value. + + DESCRIBE TABLE lt_cell_data LINES lv_uniquecount. + MOVE lv_uniquecount TO lv_uniquecount_str. + + SHIFT lv_uniquecount_str RIGHT DELETING TRAILING space. + SHIFT lv_uniquecount_str LEFT DELETING LEADING space. + + LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>. + lv_sytabix = sy-tabix - 1. + MOVE lv_sytabix TO ls_shared_string-string_no. + MOVE <fs_sheet_content>-cell_value TO ls_shared_string-string_value. + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_sst + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_count + value = lv_count_str ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_uniquecount + value = lv_uniquecount_str ). + +********************************************************************** +* STEP 4: Create subnode + LOOP AT shared_strings ASSIGNING <fs_sheet_string>. + lo_element = lo_document->create_simple_element( name = lc_xml_node_si + parent = lo_document ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_t + parent = lo_document ). + lo_sub_element->set_value( <fs_sheet_string>-string_value ). + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + ENDLOOP. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + + method CREATE_XL_SHEET. +********************************************************************** +* abap2xlsx +* +* Copyright (c) 2010 - 2011 Plinky.it +* +* This library is free software. you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation. either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY. without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library. if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* @category ABAP xlsx Creator +* @package ZA2E +* @author Ivan Femia +* @company Techedge SpA +* @homepage http://www.plinky.it/software +* @copyright Copyright (c) 2010 - 2011 http://www.plinky.it +* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL +* @version 1.0, 2010-06-30 +********************************************************************** + +** Constant node name + DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', + lc_xml_node_sheetpr TYPE string VALUE 'sheetPr', + lc_xml_node_outlinepr TYPE string VALUE 'outlinePr', + lc_xml_node_dimension TYPE string VALUE 'dimension', + lc_xml_node_sheetviews TYPE string VALUE 'sheetViews', + lc_xml_node_sheetview TYPE string VALUE 'sheetView', + lc_xml_node_selection TYPE string VALUE 'selection', + lc_xml_node_sheetformatpr TYPE string VALUE 'sheetFormatPr', + lc_xml_node_cols TYPE string VALUE 'cols', + lc_xml_node_col TYPE string VALUE 'col', + lc_xml_node_sheetdata TYPE string VALUE 'sheetData', + lc_xml_node_row TYPE string VALUE 'row', + lc_xml_node_c TYPE string VALUE 'c', + lc_xml_node_v TYPE string VALUE 'v', + lc_xml_node_f TYPE string VALUE 'f', + lc_xml_node_pagemargins TYPE string VALUE 'pageMargins', + lc_xml_node_condformatting TYPE string VALUE 'conditionalFormatting', + lc_xml_node_cfrule TYPE string VALUE 'cfRule', + lc_xml_node_iconset TYPE string VALUE 'iconSet', + lc_xml_node_cfvo TYPE string VALUE 'cfvo', + lc_xml_node_formula TYPE string VALUE 'formula', + lc_xml_node_datavalidations TYPE string VALUE 'dataValidations', + lc_xml_node_datavalidation TYPE string VALUE 'dataValidation', + lc_xml_node_formula1 TYPE string VALUE 'formula1', + lc_xml_node_mergecell TYPE string VALUE 'mergeCell', + lc_xml_node_mergecells TYPE string VALUE 'mergeCells', + " Node attributes + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_summarybelow TYPE string VALUE 'summaryBelow', + lc_xml_attr_summaryright TYPE string VALUE 'summaryRight', + lc_xml_attr_tabselected TYPE string VALUE 'tabSelected', + lc_xml_attr_workbookviewid TYPE string VALUE 'workbookViewId', + lc_xml_attr_showgridlines TYPE string VALUE 'showGridLines', + lc_xml_attr_showrowcolheaders TYPE string VALUE 'showRowColHeaders', + lc_xml_attr_activecell TYPE string VALUE 'activeCell', + lc_xml_attr_sqref TYPE string VALUE 'sqref', + lc_xml_attr_min TYPE string VALUE 'min', + lc_xml_attr_max TYPE string VALUE 'max', + lc_xml_attr_hidden TYPE string VALUE 'hidden', + lc_xml_attr_width TYPE string VALUE 'width', + lc_xml_attr_defaultwidth TYPE string VALUE '9.10', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_true TYPE string VALUE 'true', + lc_xml_attr_bestfit TYPE string VALUE 'bestFit', + lc_xml_attr_customheight TYPE string VALUE 'customHeight', + lc_xml_attr_customwidth TYPE string VALUE 'customWidth', + lc_xml_attr_collapsed TYPE string VALUE 'collapsed', + lc_xml_attr_defaultrowheight TYPE string VALUE 'defaultRowHeight', + lc_xml_attr_defaultcolwidth TYPE string VALUE 'defaultColWidth', + lc_xml_attr_outlinelevelrow TYPE string VALUE 'x14ac:outlineLevelRow', + lc_xml_attr_outlinelevelcol TYPE string VALUE 'x14ac:outlineLevelCol', + lc_xml_attr_outlinelevel TYPE string VALUE 'outlineLevel', + lc_xml_attr_r TYPE string VALUE 'r', + lc_xml_attr_s TYPE string VALUE 's', + lc_xml_attr_spans TYPE string VALUE 'spans', + lc_xml_attr_t TYPE string VALUE 't', + lc_xml_attr_left TYPE string VALUE 'left', + lc_xml_attr_right TYPE string VALUE 'right', + lc_xml_attr_top TYPE string VALUE 'top', + lc_xml_attr_bottom TYPE string VALUE 'bottom', + lc_xml_attr_header TYPE string VALUE 'header', + lc_xml_attr_footer TYPE string VALUE 'footer', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_iconset TYPE string VALUE 'iconSet', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_dxfid TYPE string VALUE 'dxfId', + lc_xml_attr_priority TYPE string VALUE 'priority', + lc_xml_attr_operator TYPE string VALUE 'operator', + lc_xml_attr_allowblank TYPE string VALUE 'allowBlank', + lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage', + lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage', + lc_xml_attr_count TYPE string VALUE 'count', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + lc_xml_node_comp_ns TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006', + lc_xml_node_comp_pref TYPE string VALUE 'x14ac', + lc_xml_node_ig_ns TYPE string VALUE 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element_2 TYPE REF TO if_ixml_element, + lo_element_3 TYPE REF TO if_ixml_element, + lo_element_4 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style_conditional TYPE REF TO zcl_excel_style_conditional, + lo_data_validation TYPE REF TO zcl_excel_data_validation, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_value TYPE string, + t_range_merge TYPE string_table, + lv_merge TYPE string, + lv_column_p TYPE zexcel_cell_column_alpha, + lv_column TYPE zexcel_cell_column, + lv_flag TYPE c, + lt_percent_val TYPE TABLE OF string, + ls_percent_val TYPE string, + lv_cell_row_s TYPE string, + ls_last_row TYPE zexcel_s_cell_data, + ls_style_mapping TYPE zexcel_s_styles_mapping. + + DATA: default_col_dimension TYPE REF TO zcl_excel_worksheet_columndime, + default_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + + FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data, + <fs_range_merge> LIKE LINE OF t_range_merge. + DATA: column_dimensions TYPE zexcel_t_worksheet_columndime. + FIELD-SYMBOLS: <column_dimension> LIKE LINE OF column_dimensions. + DATA: row_dimensions TYPE zexcel_t_worksheet_rowdimensio. + FIELD-SYMBOLS: <row_dimension> LIKE LINE OF row_dimensions. + DATA: outline_level_row TYPE i VALUE 0, + outline_level_col TYPE i VALUE 0. + DATA: col_count TYPE int4. + DATA: row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. + DATA: write_current_row TYPE boolean. +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_worksheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:mc' + value = lc_xml_node_comp_ns ). + lo_element_root->set_attribute_ns( name = 'mc:Ignorable' + value = lc_xml_node_comp_pref ). + lo_element_root->set_attribute_ns( name = 'xmlns:x14ac' + value = lc_xml_node_ig_ns ). + + +********************************************************************** +* STEP 4: Create subnodes + " sheetPr + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetpr + parent = lo_document ). + " TODO tabColor + + " outlinePr + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_outlinepr + parent = lo_document ). + " TODO read attribute summaryBelow and set the attribute to 0 + lo_element_2->set_attribute_ns( name = lc_xml_attr_summarybelow + value = '1' ). + " TODO read attribute summaryRight and set the attribute to 0 + lo_element_2->set_attribute_ns( name = lc_xml_attr_summaryright + value = '1' ). + + lo_element->append_child( lo_element_2 ). + " TODO pageSetUpPr + + lo_element_root->append_child( lo_element ). + " dimension node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dimension + parent = lo_document ). + lv_value = io_worksheet->get_dimension_range( ). + lo_element->set_attribute_ns( name = lc_xml_attr_ref + value = lv_value ). + lo_element_root->append_child( lo_element ). + + " sheetViews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetviews + parent = lo_document ). + " sheetView node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_sheetview + parent = lo_document ). + IF iv_active EQ abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_tabselected + value = '1' ). + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_workbookviewid + value = '0' ). + " showGridLines attribute + lo_element_2->set_attribute_ns( name = lc_xml_attr_showgridlines + value = 'true' ). + " showRowColHeaders attribute + lo_element_2->set_attribute_ns( name = lc_xml_attr_showrowcolheaders + value = '1' ). + + " selection node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_selection + parent = lo_document ). + lv_value = io_worksheet->get_active_cell( ). + lo_element_3->set_attribute_ns( name = lc_xml_attr_activecell + value = lv_value ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + lo_element_2->append_child( lo_element_3 ). " sheetView node + + lo_element->append_child( lo_element_2 ). " sheetView node + + lo_element_root->append_child( lo_element ). " sheetViews node + + + column_dimensions[] = io_worksheet->get_column_dimensions( ). + row_dimensions[] = io_worksheet->get_row_dimensions( ). + " sheetFormatPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetformatpr + parent = lo_document ). + " defaultRowHeight + default_row_dimension = io_worksheet->get_default_row_dimension( ). + IF default_row_dimension IS BOUND. + IF default_row_dimension->get_row_height( ) >= 0. + lo_element->set_attribute_ns( name = lc_xml_attr_customheight + value = lc_xml_attr_true ). + lv_value = default_row_dimension->get_row_height( ). + ELSE. + lv_value = '12.75'. + ENDIF. + ELSE. + lv_value = '12.75'. + ENDIF. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultrowheight + value = lv_value ). + " defaultColWidth + default_col_dimension = io_worksheet->get_default_column_dimension( ). + IF default_col_dimension IS BOUND. + IF default_col_dimension->get_width( ) >= 0. + lv_value = default_col_dimension->get_width( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_defaultcolwidth + value = lv_value ). + ENDIF. + ENDIF. + " outlineLevelRow + LOOP AT row_dimensions ASSIGNING <row_dimension>. + IF <row_dimension>-row_dimension->get_outline_level( ) > outline_level_row. + outline_level_row = <row_dimension>-row_dimension->get_outline_level( ). + ENDIF. + ENDLOOP. + lv_value = outline_level_row. + lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelrow + value = lv_value ). + " outlineLevelCol + LOOP AT column_dimensions ASSIGNING <column_dimension>. + IF <column_dimension>-column_dimension->get_outline_level( ) > outline_level_col. + outline_level_col = <column_dimension>-column_dimension->get_outline_level( ). + ENDIF. + ENDLOOP. + lv_value = outline_level_col. + lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelcol + value = lv_value ). + + lo_element_root->append_child( lo_element ). " sheetFormatPr node + " cols node + IF NOT column_dimensions IS INITIAL. + lo_element = lo_document->create_simple_element( name = lc_xml_node_cols + parent = lo_document ). + LOOP AT column_dimensions ASSIGNING <column_dimension>. + " col node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_col + parent = lo_document ). + lv_value = <column_dimension>-column_dimension->get_column_index( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_min + value = lv_value ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_max + value = lv_value ). + " Width + IF <column_dimension>-column_dimension->get_width( ) < 0. + lo_element_2->set_attribute_ns( name = lc_xml_attr_width + value = lc_xml_attr_defaultwidth ). + ELSE. + lv_value = <column_dimension>-column_dimension->get_width( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_width + value = lv_value ). + ENDIF. + " Column visibility + IF <column_dimension>-column_dimension->get_visible( ) = abap_false. + lo_element_2->set_attribute_ns( name = lc_xml_attr_hidden + value = lc_xml_attr_true ). + ENDIF. + " Auto size? + IF <column_dimension>-column_dimension->get_auto_size( ) = abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_bestfit + value = lc_xml_attr_true ). + ENDIF. + " Custom width? + IF default_col_dimension IS BOUND. + IF <column_dimension>-column_dimension->get_width( ) + <> default_col_dimension->get_width( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_customwidth + value = lc_xml_attr_true ). + + ENDIF. + ELSE. + lo_element_2->set_attribute_ns( name = lc_xml_attr_customwidth + value = lc_xml_attr_true ). + ENDIF. + " Collapsed + IF <column_dimension>-column_dimension->get_collapsed( ) = abap_true. + lo_element_2->set_attribute_ns( name = lc_xml_attr_collapsed + value = lc_xml_attr_true ). + ENDIF. + " outlineLevel + IF <column_dimension>-column_dimension->get_outline_level( ) > 0. + lv_value = <column_dimension>-column_dimension->get_outline_level( ). + lo_element_2->set_attribute_ns( name = lc_xml_attr_outlinelevel + value = lv_value ). + ENDIF. + " Style + lv_value = <column_dimension>-column_dimension->get_xf_index( ). + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + + lo_element->append_child( lo_element_2 ). " col node + ENDLOOP. + ENDIF. + lo_element_root->append_child( lo_element ). " cols node + " sheetData node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetdata + parent = lo_document ). + " Get column count + col_count = io_worksheet->get_highest_column( ). + + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. + CLEAR ls_style_mapping. + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + " Add new row + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row + parent = lo_document ). + " r + lv_value = <ls_sheet_content>-cell_row. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_r + value = lv_value ). + " Spans + lv_value = col_count. + CONCATENATE '1:' lv_value INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_spans + value = lv_value ). + row_dimension = io_worksheet->get_row_dimension( <ls_sheet_content>-cell_row ). + " Do we need the row dimension attributes? + IF row_dimension->get_row_height( ) >= 0 OR + row_dimension->get_visible( ) = abap_false OR + row_dimension->get_collapsed( ) = abap_true OR + row_dimension->get_outline_level( ) > 0 OR + row_dimension->get_xf_index( ) <> 0. + " Row dimensions + IF row_dimension->get_row_height( ) >= 0. + lo_element_2->set_attribute_ns( name = 'customHeight' value = '1'). + lv_value = row_dimension->get_row_height( ). + lo_element_2->set_attribute_ns( name = 'ht' value = lv_value ). + ENDIF. + " Row visibility + IF row_dimension->get_visible( ) = abap_false. + lo_element_2->set_attribute_ns( name = 'hidden' value = 'true'). + ENDIF. + " Collapsed + IF row_dimension->get_collapsed( ) = abap_true. + lo_element_2->set_attribute_ns( name = 'collapsed' value = 'true'). + ENDIF. + " Outline level + IF row_dimension->get_outline_level( ) > 0. + lv_value = row_dimension->get_outline_level( ). + lo_element_2->set_attribute_ns( name = 'outlineLevel' value = lv_value ). + ENDIF. + " Style + IF row_dimension->get_xf_index( ) <> 0. + lv_value = row_dimension->get_xf_index( ). + lo_element_2->set_attribute_ns( name = 's' value = lv_value ). + lo_element_2->set_attribute_ns( name = 'customFormat' value = '1'). + ENDIF. + ENDIF. + ENDIF. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c + parent = lo_document ). + + lo_element_3->set_attribute_ns( name = lc_xml_attr_r + value = <ls_sheet_content>-cell_coords ). + + IF <ls_sheet_content>-cell_style IS NOT INITIAL. + READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. + lv_value = ls_style_mapping-style. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_3->set_attribute_ns( name = lc_xml_attr_s + value = lv_value ). + ENDIF. + + " For cells with formula ignore the value - Excel will calculate it + IF <ls_sheet_content>-cell_formula IS NOT INITIAL. + " fomula node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_f + parent = lo_document ). + lv_value = <ls_sheet_content>-cell_formula. + lo_element_4->set_value( lv_value ). + lo_element_3->append_child( lo_element_4 ). " fomula node + ELSE. + IF <ls_sheet_content>-data_type IS NOT INITIAL. + lo_element_3->set_attribute_ns( name = lc_xml_attr_t + value = <ls_sheet_content>-data_type ). + ENDIF. + + " value node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v + parent = lo_document ). + + IF <ls_sheet_content>-data_type EQ 's'. + lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ). + lo_element_4->set_value( lv_value ). + ELSE. + lv_value = <ls_sheet_content>-cell_value. + lo_element_4->set_value( lv_value ). + ENDIF. + + lo_element_3->append_child( lo_element_4 ). " value node + ENDIF. + + lo_element_2->append_child( lo_element_3 ). " column node + IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row. + lo_element->append_child( lo_element_2 ). " row node + ls_last_row = <ls_sheet_content>. + ENDIF. + + ENDLOOP. + lo_element_root->append_child( lo_element ). " sheetData node + + " Conditional formatting node + lo_iterator = io_worksheet->get_cond_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style_conditional ?= lo_iterator->get_next( ). + IF lo_style_conditional->rule IS INITIAL. + CONTINUE. + ENDIF. + lo_element = lo_document->create_simple_element( name = lc_xml_node_condformatting + parent = lo_document ). + lv_value = lo_style_conditional->get_dimension_range( ) . + lo_element->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + + " cfRule node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_cfrule + parent = lo_document ). + lv_value = lo_style_conditional->rule. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = lo_style_conditional->priority. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_2->set_attribute_ns( name = lc_xml_attr_priority + value = lv_value ). + + CASE lo_style_conditional->rule. + WHEN zcl_excel_style_conditional=>c_rule_iconset. + CLEAR lt_percent_val. + " iconset node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_iconset + parent = lo_document ). + IF lo_style_conditional->iconset NE zcl_excel_style_conditional=>c_iconset_3trafficlights. + lv_value = lo_style_conditional->iconset. + lo_element_3->set_attribute_ns( name = lc_xml_attr_iconset + value = lv_value ). + ENDIF. + + CASE lo_style_conditional->iconset. + WHEN zcl_excel_style_conditional=>c_iconset_3trafficlights2 OR + zcl_excel_style_conditional=>c_iconset_3arrows OR + zcl_excel_style_conditional=>c_iconset_3arrowsgray OR + zcl_excel_style_conditional=>c_iconset_3flags OR + zcl_excel_style_conditional=>c_iconset_3signs OR + zcl_excel_style_conditional=>c_iconset_3symbols OR + zcl_excel_style_conditional=>c_iconset_3symbols2 OR + zcl_excel_style_conditional=>c_iconset_3trafficlights OR + zcl_excel_style_conditional=>c_iconset_3trafficlights2. + APPEND '0' TO lt_percent_val. + APPEND '33' TO lt_percent_val. + APPEND '67' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_4arrows OR + zcl_excel_style_conditional=>c_iconset_4arrowsgray OR + zcl_excel_style_conditional=>c_iconset_4rating OR + zcl_excel_style_conditional=>c_iconset_4redtoblack OR + zcl_excel_style_conditional=>c_iconset_4trafficlights. + APPEND '0' TO lt_percent_val. + APPEND '25' TO lt_percent_val. + APPEND '50' TO lt_percent_val. + APPEND '75' TO lt_percent_val. + WHEN zcl_excel_style_conditional=>c_iconset_5arrows OR + zcl_excel_style_conditional=>c_iconset_5arrowsgray OR + zcl_excel_style_conditional=>c_iconset_5quarters OR + zcl_excel_style_conditional=>c_iconset_5rating. + APPEND '0' TO lt_percent_val. + APPEND '20' TO lt_percent_val. + APPEND '40' TO lt_percent_val. + APPEND '60' TO lt_percent_val. + APPEND '80' TO lt_percent_val. + WHEN OTHERS. + CLEAR lt_percent_val. + ENDCASE. + + LOOP AT lt_percent_val INTO ls_percent_val. + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = 'percent' ). + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = ls_percent_val ). + lo_element_3->append_child( lo_element_4 ). " cfvo node + ENDLOOP. + + + lo_element_2->append_child( lo_element_3 ). " iconset node + WHEN zcl_excel_style_conditional=>c_rule_cellis. + lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid + value = '0' ). " @TODO <***************************** + lv_value = lo_style_conditional->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). + " formula node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula + parent = lo_document ). + lv_value = lo_style_conditional->formula. + lo_element_3->set_value( lv_value ). + lo_element_2->append_child( lo_element_3 ). " formula node + + ENDCASE. + + lo_element->append_child( lo_element_2 ). " cfRule node + + lo_element_root->append_child( lo_element ). " Conditional formatting node + ENDWHILE. + + + IF io_worksheet->get_data_validations_size( ) GT 0. + " dataValidations node + lo_element = lo_document->create_simple_element( name = lc_xml_node_datavalidations + parent = lo_document ). + " Conditional formatting node + lo_iterator = io_worksheet->get_data_validations_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_data_validation ?= lo_iterator->get_next( ). + " dataValidation node + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_datavalidation + parent = lo_document ). + lv_value = lo_data_validation->type. + lo_element_2->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + IF lo_data_validation->allowblank EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_allowblank + value = lv_value ). + IF lo_data_validation->showinputmessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showinputmessage + value = lv_value ). + IF lo_data_validation->showerrormessage EQ abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + lo_element_2->set_attribute_ns( name = lc_xml_attr_showerrormessage + value = lv_value ). + lv_cell_row_s = lo_data_validation->cell_row. + SHIFT lv_cell_row_s RIGHT DELETING TRAILING space. + SHIFT lv_cell_row_s LEFT DELETING LEADING space. + CONCATENATE lo_data_validation->cell_column lv_cell_row_s INTO lv_value. + lo_element_2->set_attribute_ns( name = lc_xml_attr_sqref + value = lv_value ). + " formula1 node + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula1 + parent = lo_document ). + lv_value = lo_data_validation->value. + lo_element_3->set_value( lv_value ). + + lo_element_2->append_child( lo_element_3 ). " formula1 node + + lo_element->append_child( lo_element_2 ). " dataValidation node + ENDWHILE. + lo_element_root->append_child( lo_element ). " dataValidations node + ENDIF. + + t_range_merge = io_worksheet->get_merge( ). + IF t_range_merge IS NOT INITIAL. + lo_element = lo_document->create_simple_element( name = lc_xml_node_mergecells + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + LOOP AT t_range_merge ASSIGNING <fs_range_merge>. + lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_mergecell + parent = lo_document ). + + lo_element_2->set_attribute_ns( name = lc_xml_attr_ref + value = <fs_range_merge> ). + lo_element->append_child( lo_element_2 ). + lo_element_root->append_child( lo_element ). + io_worksheet->delete_merge( ). + ENDLOOP. + ENDIF. + + " pageMargins node + lo_element = lo_document->create_simple_element( name = lc_xml_node_pagemargins + parent = lo_document ). + + lo_element->set_attribute_ns( name = lc_xml_attr_left + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_right + value = '0.7' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_top + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_bottom + value = '0.75' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_header + value = '0.3' ). " @TODO <***************************** + lo_element->set_attribute_ns( name = lc_xml_attr_footer + value = '0.3' ). " @TODO <***************************** + lo_element_root->append_child( lo_element ). " sheetFormatPr node + +* tables + DATA lv_table_count TYPE i. + + lv_table_count = io_worksheet->get_tables_size( ). + IF lv_table_count > 0. + lo_element = lo_document->create_simple_element( name = 'tableParts' + parent = lo_document ). + lv_value = lv_table_count. + CONDENSE lv_value. + lo_element->set_attribute_ns( name = 'count' + value = lv_value ). + + lv_table_count = 0. + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_iterator->get_next( ). + add 1 to lv_table_count. + + lv_value = lv_table_count. + condense lv_value. + CONCATENATE 'rId' lv_value INTO lv_value. + lo_element_2 = lo_document->create_simple_element( name = 'tablePart' + parent = lo_element ). + lo_element_2->set_attribute_ns( name = 'r:id' + value = lv_value ). + lo_element->append_child( lo_element_2 ). + + ENDWHILE. + + lo_element_root->append_child( lo_element ). + + ENDIF. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + method CREATE_XL_SHEET_RELS. + + +** Constant node name + DATA: lc_xml_node_relationships TYPE string VALUE 'Relationships', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'Id', + lc_xml_attr_type TYPE string VALUE 'Type', + lc_xml_attr_target TYPE string VALUE 'Target', + " Node namespace + lc_xml_node_rels_ns TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + lc_xml_node_rid_table_tp TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_table TYPE REF TO zcl_excel_table. + + DATA: lv_value TYPE string, + lv_counter TYPE i. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_relationships + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_rels_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + " Add sheet Relationship nodes here + lv_counter = 0. + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_table ?= lo_iterator->get_next( ). + ADD 1 TO lv_counter. + + lv_value = lv_counter. + CONDENSE lv_value. + CONCATENATE 'rId' lv_value INTO lv_value. + + lo_element = lo_document->create_simple_element( name = lc_xml_node_relationship + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_id + value = lv_value ). + lo_element->set_attribute_ns( name = lc_xml_attr_type + value = lc_xml_node_rid_table_tp ). + + lv_value = lo_table->get_name( ). + CONCATENATE '../tables/' lv_value '.xml' INTO lv_value. + lo_element->set_attribute_ns( name = lc_xml_attr_target + value = lv_value ). + lo_element_root->append_child( lo_element ). + ENDWHILE. + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + METHOD create_xl_styles. + + +** Constant node name + CONSTANTS: lc_xml_node_stylesheet TYPE string VALUE 'styleSheet', + " font + lc_xml_node_fonts TYPE string VALUE 'fonts', + lc_xml_node_font TYPE string VALUE 'font', + lc_xml_node_b TYPE string VALUE 'b', "bold + lc_xml_node_i TYPE string VALUE 'i', "italic + lc_xml_node_u TYPE string VALUE 'u', "underline + lc_xml_node_strike TYPE string VALUE 'strike', "strikethrough + lc_xml_node_sz TYPE string VALUE 'sz', + lc_xml_node_color TYPE string VALUE 'color', + lc_xml_node_name TYPE string VALUE 'name', + lc_xml_node_family TYPE string VALUE 'family', + lc_xml_node_scheme TYPE string VALUE 'scheme', + " fill + lc_xml_node_fills TYPE string VALUE 'fills', + lc_xml_node_fill TYPE string VALUE 'fill', + lc_xml_node_patternfill TYPE string VALUE 'patternFill', + lc_xml_node_fgcolor TYPE string VALUE 'fgColor', + lc_xml_node_bgcolor TYPE string VALUE 'bgColor', + lc_xml_node_gradientfill TYPE string VALUE 'gradientFill', + lc_xml_node_stop TYPE string VALUE 'stop', + " borders + lc_xml_node_borders TYPE string VALUE 'borders', + lc_xml_node_border TYPE string VALUE 'border', + lc_xml_node_left TYPE string VALUE 'left', + lc_xml_node_right TYPE string VALUE 'right', + lc_xml_node_top TYPE string VALUE 'top', + lc_xml_node_bottom TYPE string VALUE 'bottom', + lc_xml_node_diagonal TYPE string VALUE 'diagonal', + " numfmt + lc_xml_node_numfmts TYPE string VALUE 'numFmts', + lc_xml_node_numfmt TYPE string VALUE 'numFmt', + " Styles + lc_xml_node_cellstylexfs TYPE string VALUE 'cellStyleXfs', + lc_xml_node_xf TYPE string VALUE 'xf', + lc_xml_node_cellxfs TYPE string VALUE 'cellXfs', + lc_xml_node_cellstyles TYPE string VALUE 'cellStyles', + lc_xml_node_cellstyle TYPE string VALUE 'cellStyle', + lc_xml_node_dxfs TYPE string VALUE 'dxfs', + lc_xml_node_tablestyles TYPE string VALUE 'tableStyles', + " Colors + lc_xml_node_colors TYPE string VALUE 'colors', + lc_xml_node_mrucolors TYPE string VALUE 'mruColors', + lc_xml_node_alignment TYPE string VALUE 'alignment', + " Node attributes + lc_xml_attr_count TYPE string VALUE 'count', + lc_xml_attr_val TYPE string VALUE 'val', + lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_position TYPE string VALUE 'position', + lc_xml_attr_degree TYPE string VALUE 'degree', + lc_xml_attr_patterntype TYPE string VALUE 'patternType', + lc_xml_attr_numfmtid TYPE string VALUE 'numFmtId', + lc_xml_attr_fontid TYPE string VALUE 'fontId', + lc_xml_attr_fillid TYPE string VALUE 'fillId', + lc_xml_attr_borderid TYPE string VALUE 'borderId', + lc_xml_attr_xfid TYPE string VALUE 'xfId', + lc_xml_attr_applynumberformat TYPE string VALUE 'applyNumberFormat', + lc_xml_attr_applyfont TYPE string VALUE 'applyFont', + lc_xml_attr_applyfill TYPE string VALUE 'applyFill', + lc_xml_attr_applyborder TYPE string VALUE 'applyBorder', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_builtinid TYPE string VALUE 'builtinId', + lc_xml_attr_defaulttablestyle TYPE string VALUE 'defaultTableStyle', + lc_xml_attr_defaultpivotstyle TYPE string VALUE 'defaultPivotStyle', + lc_xml_attr_applyalignment TYPE string VALUE 'applyAlignment', + lc_xml_attr_horizontal TYPE string VALUE 'horizontal', + lc_xml_attr_formatcode TYPE string VALUE 'formatCode', + lc_xml_attr_vertical TYPE string VALUE 'vertical', + lc_xml_attr_wraptext TYPE string VALUE 'wrapText', + lc_xml_attr_textrotation TYPE string VALUE 'textRotation', + lc_xml_attr_shrinktofit TYPE string VALUE 'shrinkToFit', + lc_xml_attr_indent TYPE string VALUE 'indent', + " Node namespace + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'. + + CONSTANTS: lc_on TYPE string VALUE '1', + lc_off TYPE string VALUE '0'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element_fonts TYPE REF TO if_ixml_element, + lo_element_font TYPE REF TO if_ixml_element, + lo_element_fills TYPE REF TO if_ixml_element, + lo_element_fill TYPE REF TO if_ixml_element, + lo_element_borders TYPE REF TO if_ixml_element, + lo_element_border TYPE REF TO if_ixml_element, + lo_element_numfmts TYPE REF TO if_ixml_element, + lo_element_numfmt TYPE REF TO if_ixml_element, + lo_element_cellxfs TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_sub_element_2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_style TYPE REF TO zcl_excel_style. + + + DATA: lt_fonts TYPE zexcel_t_style_font, + ls_font TYPE zexcel_s_style_font, + lt_fills TYPE zexcel_t_style_fill, + ls_fill TYPE zexcel_s_style_fill, + lt_borders TYPE zexcel_t_style_border, + ls_border TYPE zexcel_s_style_border, + lt_numfmts TYPE zexcel_t_style_numfmt, + ls_numfmt TYPE zexcel_s_style_numfmt, + lt_alignments TYPE zexcel_t_style_alignment, + ls_alignment TYPE zexcel_s_style_alignment, + lt_cellxfs TYPE zexcel_t_cellxfs, + ls_cellxfs TYPE zexcel_s_cellxfs, + ls_styles_mapping TYPE zexcel_s_styles_mapping, + lt_colors TYPE TABLE OF zexcel_style_color_argb, + ls_color TYPE zexcel_style_color_argb. + + DATA: lv_value TYPE string, + lv_fonts_count TYPE i, + lv_fills_count TYPE i, + lv_borders_count TYPE i, + lv_cellxfs_count TYPE i, + lv_align_flag TYPE c. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +*********************************************************************** +* STEP 3: Create main node relationships + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_stylesheet + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + +********************************************************************** +* STEP 4: Create subnodes + + lo_element_fonts = lo_document->create_simple_element( name = lc_xml_node_fonts + parent = lo_document ). + + lo_element_fills = lo_document->create_simple_element( name = lc_xml_node_fills + parent = lo_document ). + + lo_element_borders = lo_document->create_simple_element( name = lc_xml_node_borders + parent = lo_document ). + + lo_element_cellxfs = lo_document->create_simple_element( name = lc_xml_node_cellxfs + parent = lo_document ). + + lo_element_numfmts = lo_document->create_simple_element( name = lc_xml_node_numfmts + parent = lo_document ). + + +* Compress styles + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_style ?= lo_iterator->get_next( ). + ls_font = lo_style->font->get_structure( ). + ls_fill = lo_style->fill->get_structure( ). + ls_border = lo_style->borders->get_structure( ). + ls_alignment = lo_style->alignment->get_structure( ). + ls_numfmt = lo_style->number_format->get_structure( ). + + CLEAR ls_cellxfs. + + +* Compress fonts + READ TABLE lt_fonts FROM ls_font TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fontid = sy-tabix. + ELSE. + APPEND ls_font TO lt_fonts. + DESCRIBE TABLE lt_fonts LINES ls_cellxfs-fontid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fontid. + +* Compress alignment + READ TABLE lt_alignments FROM ls_alignment TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-alignmentid = sy-tabix. + ELSE. + APPEND ls_alignment TO lt_alignments. + DESCRIBE TABLE lt_alignments LINES ls_cellxfs-alignmentid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-alignmentid. + +* Compress fills + READ TABLE lt_fills FROM ls_fill TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-fillid = sy-tabix. + ELSE. + APPEND ls_fill TO lt_fills. + DESCRIBE TABLE lt_fills LINES ls_cellxfs-fillid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-fillid. + +* Compress borders + READ TABLE lt_borders FROM ls_border TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-borderid = sy-tabix. + ELSE. + APPEND ls_border TO lt_borders. + DESCRIBE TABLE lt_borders LINES ls_cellxfs-borderid. + ENDIF. + SUBTRACT 1 FROM ls_cellxfs-borderid. + +* Compress number formats + IF ls_numfmt IS NOT INITIAL. + READ TABLE lt_numfmts FROM ls_numfmt TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_cellxfs-numfmtid = sy-tabix. + ELSE. + APPEND ls_numfmt TO lt_numfmts. + DESCRIBE TABLE lt_numfmts LINES ls_cellxfs-numfmtid. + ENDIF. + ADD zcl_excel_common=>c_excel_numfmt_offset TO ls_cellxfs-numfmtid. " Add OXML offset for custom styles + ls_cellxfs-applynumberformat = 1. + ELSE. + ls_cellxfs-applynumberformat = 0. + ENDIF. + + IF ls_cellxfs-fontid NE 0. + ls_cellxfs-applyfont = 1. + ELSE. + ls_cellxfs-applyfont = 0. + ENDIF. + IF ls_cellxfs-alignmentid NE 0. + ls_cellxfs-applyalignment = 1. + ELSE. + ls_cellxfs-applyalignment = 0. + ENDIF. + IF ls_cellxfs-fillid NE 0. + ls_cellxfs-applyfill = 1. + ELSE. + ls_cellxfs-applyfill = 0. + ENDIF. + IF ls_cellxfs-borderid NE 0. + ls_cellxfs-applyborder = 1. + ELSE. + ls_cellxfs-applyborder = 0. + ENDIF. + +* Remap styles + READ TABLE lt_cellxfs FROM ls_cellxfs TRANSPORTING NO FIELDS. + IF sy-subrc EQ 0. + ls_styles_mapping-style = sy-tabix. + ELSE. + APPEND ls_cellxfs TO lt_cellxfs. + DESCRIBE TABLE lt_cellxfs LINES ls_styles_mapping-style. + ENDIF. + SUBTRACT 1 FROM ls_styles_mapping-style. + ls_styles_mapping-guid = lo_style->get_guid( ). + APPEND ls_styles_mapping TO me->styles_mapping. + ENDWHILE. + + " create numfmt elements + LOOP AT lt_numfmts INTO ls_numfmt. + lo_element_numfmt = lo_document->create_simple_element( name = lc_xml_node_numfmt + parent = lo_document ). + lv_value = sy-tabix + zcl_excel_common=>c_excel_numfmt_offset. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_numfmt->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + lv_value = ls_numfmt-numfmt. + lo_element_numfmt->set_attribute_ns( name = lc_xml_attr_formatcode + value = lv_value ). + lo_element_numfmts->append_child( lo_element_numfmt ). + ENDLOOP. + + " create font elements + LOOP AT lt_fonts INTO ls_font. + lo_element_font = lo_document->create_simple_element( name = lc_xml_node_font + parent = lo_document ). + IF ls_font-bold EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_b + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-italic EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_i + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-underline EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_u + parent = lo_document ). + lv_value = ls_font-underline_mode. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + IF ls_font-strikethrough EQ abap_true. + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_strike + parent = lo_document ). + lo_element_font->append_child( lo_sub_element ). + ENDIF. + "size + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_sz + parent = lo_document ). + lv_value = ls_font-size. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "color + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_font-color. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "name + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name + parent = lo_document ). + lv_value = ls_font-name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "family + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_family + parent = lo_document ). + lv_value = ls_font-family. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + "scheme + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_scheme + parent = lo_document ). + lv_value = ls_font-scheme. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_font->append_child( lo_sub_element ). + lo_element_fonts->append_child( lo_element_font ). + APPEND ls_font-color TO lt_colors. + ENDLOOP. + + " create fill elements + LOOP AT lt_fills INTO ls_fill. + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + IF ls_fill-fgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor + parent = lo_document ). + lv_value = ls_fill-fgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." fgcolor + ENDIF. + " bgcolor + IF ls_fill-bgcolor IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor + parent = lo_document ). + lv_value = ls_fill-bgcolor. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + + lo_sub_element->append_child( lo_sub_element_2 )." bgcolor + ENDIF. + + lo_element_fill->append_child( lo_sub_element )."pattern + lo_element_fills->append_child( lo_element_fill ). + " Collect color + IF ls_fill-fgcolor IS NOT INITIAL. + APPEND ls_fill-fgcolor TO lt_colors. + ENDIF. + ENDLOOP. + + " create border elements + LOOP AT lt_borders INTO ls_border. + lo_element_border = lo_document->create_simple_element( name = lc_xml_node_border + parent = lo_document ). + "left + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_left + parent = lo_document ). + IF ls_border-left_style IS NOT INITIAL. + lv_value = ls_border-left_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-left_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-left_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-left_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "right + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_right + parent = lo_document ). + IF ls_border-right_style IS NOT INITIAL. + lv_value = ls_border-right_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-right_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-right_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-right_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "top + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_top + parent = lo_document ). + IF ls_border-top_style IS NOT INITIAL. + lv_value = ls_border-top_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-top_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-top_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-top_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "bottom + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_bottom + parent = lo_document ). + IF ls_border-bottom_style IS NOT INITIAL. + lv_value = ls_border-bottom_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-bottom_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-bottom_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-bottom_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + + "diagonal + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_diagonal + parent = lo_document ). + IF ls_border-diagonal_style IS NOT INITIAL. + lv_value = ls_border-diagonal_style. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_style + value = lv_value ). + ENDIF. + IF ls_border-diagonal_color IS NOT INITIAL. + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_border-diagonal_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color +* Collect color + APPEND ls_border-diagonal_color TO lt_colors. + ENDIF. + lo_element_border->append_child( lo_sub_element ). + lo_element_borders->append_child( lo_element_border ). + ENDLOOP. + + " update attribute "count" + DESCRIBE TABLE lt_fonts LINES lv_fonts_count. + MOVE lv_fonts_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fonts->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_fills LINES lv_fills_count. + MOVE lv_fills_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_fills->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_borders LINES lv_borders_count. + MOVE lv_borders_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_borders->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + DESCRIBE TABLE lt_cellxfs LINES lv_cellxfs_count. + MOVE lv_cellxfs_count TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element_cellxfs->set_attribute_ns( name = lc_xml_attr_count + value = lv_value ). + + " Append to root node + lo_element_root->append_child( lo_element_numfmts ). + lo_element_root->append_child( lo_element_fonts ). + lo_element_root->append_child( lo_element_fills ). + lo_element_root->append_child( lo_element_borders ). + + " cellstylexfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstylexfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lc_off ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + LOOP AT lt_cellxfs INTO ls_cellxfs. + lo_element = lo_document->create_simple_element( name = lc_xml_node_xf + parent = lo_document ). + MOVE ls_cellxfs-numfmtid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_numfmtid + value = lv_value ). + MOVE ls_cellxfs-fontid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fontid + value = lv_value ). + MOVE ls_cellxfs-fillid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_fillid + value = lv_value ). + MOVE ls_cellxfs-borderid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_borderid + value = lv_value ). + MOVE ls_cellxfs-xfid TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lv_value ). + IF ls_cellxfs-applynumberformat EQ 1. + MOVE ls_cellxfs-applynumberformat TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applynumberformat + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfont EQ 1. + MOVE ls_cellxfs-applyfont TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfont + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyfill EQ 1. + MOVE ls_cellxfs-applyfill TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyfill + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyborder EQ 1. + MOVE ls_cellxfs-applyborder TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyborder + value = lv_value ). + ENDIF. + IF ls_cellxfs-applyalignment EQ 1. " depends on each style not for all the sheet + MOVE ls_cellxfs-applyalignment TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_element->set_attribute_ns( name = lc_xml_attr_applyalignment + value = lv_value ). + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_alignment + parent = lo_document ). + ADD 1 TO ls_cellxfs-alignmentid. "Table index starts from 1 + READ TABLE lt_alignments INTO ls_alignment INDEX ls_cellxfs-alignmentid. + SUBTRACT 1 FROM ls_cellxfs-alignmentid. + IF ls_alignment-horizontal IS NOT INITIAL. + MOVE ls_alignment-horizontal TO lv_value. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_horizontal + value = lv_value ). + ENDIF. + IF ls_alignment-vertical IS NOT INITIAL. + MOVE ls_alignment-vertical TO lv_value. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_vertical + value = lv_value ). + ENDIF. + IF ls_alignment-wraptext EQ abap_true. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_wraptext + value = lc_on ). + ENDIF. + IF ls_alignment-textrotation IS NOT INITIAL. + MOVE ls_alignment-textrotation TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_textrotation + value = lv_value ). + ENDIF. + IF ls_alignment-shrinktofit EQ abap_true. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_shrinktofit + value = lc_on ). + ENDIF. + IF ls_alignment-indent IS NOT INITIAL. + MOVE ls_alignment-indent TO lv_value. + SHIFT lv_value RIGHT DELETING TRAILING space. + SHIFT lv_value LEFT DELETING LEADING space. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indent + value = lv_value ). + ENDIF. + + lo_element->append_child( lo_sub_element_2 ). + ENDIF. + lo_element_cellxfs->append_child( lo_element ). + ENDLOOP. + + lo_element_root->append_child( lo_element_cellxfs ). + + " cellStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_cellstyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '1' ). + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_cellstyle + parent = lo_document ). + + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = 'Normal' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xfid + value = lc_off ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_builtinid + value = lc_off ). + + lo_element->append_child( lo_sub_element ). + lo_element_root->append_child( lo_element ). + + " dxfs node + lo_element = lo_document->create_simple_element( name = lc_xml_node_dxfs + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element_root->append_child( lo_element ). + + " tableStyles node + lo_element = lo_document->create_simple_element( name = lc_xml_node_tablestyles + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_count + value = '0' ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaulttablestyle + value = zcl_excel_table=>builtinstyle_medium9 ). + lo_element->set_attribute_ns( name = lc_xml_attr_defaultpivotstyle + value = zcl_excel_table=>builtinstyle_pivot_light16 ). + lo_element_root->append_child( lo_element ). + + " colors node + lo_element = lo_document->create_simple_element( name = lc_xml_node_colors + parent = lo_document ). + " mruColors node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_mrucolors + parent = lo_document ). + + SORT lt_colors. + DELETE ADJACENT DUPLICATES FROM lt_colors. + + LOOP AT lt_colors INTO ls_color. + " color node + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_color. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + lo_sub_element->append_child( lo_sub_element_2 )." color node + ENDLOOP. + + lo_element->append_child( lo_sub_element )." mruColors node + lo_element_root->append_child( lo_element )." colors node + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + + METHOD create_xl_table. + + DATA: lc_xml_node_table TYPE string VALUE 'table', + lc_xml_node_relationship TYPE string VALUE 'Relationship', + " Node attributes + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_display_name TYPE string VALUE 'displayName', + lc_xml_attr_ref TYPE string VALUE 'ref', + lc_xml_attr_totals TYPE string VALUE 'totalsRowShown', + " Node namespace + lc_xml_node_table_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_element2 TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + + lv_table_name TYPE string, + lv_id TYPE i, + lv_syindex TYPE char3, + lv_ref TYPE string, + lv_value TYPE string, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lv_num_columns TYPE i, + ls_fieldcat TYPE zexcel_s_fieldcatalog. + + +********************************************************************** +* STEP 1: Create xml + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node table + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_table + parent = lo_document ). + + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_table_ns ). + + lv_id = io_table->get_id( ). + lv_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_id ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_id + value = lv_value ). + + lv_table_name = io_table->get_name( ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_name + value = lv_table_name ). + + lo_element_root->set_attribute_ns( name = lc_xml_attr_display_name + value = lv_table_name ). + + lv_ref = io_table->get_reference( ). + lo_element_root->set_attribute_ns( name = lc_xml_attr_ref + value = lv_ref ). + IF io_table->has_totals( ) = abap_true. + lo_element_root->set_attribute_ns( name = 'totalsRowCount' + value = '1' ). + ELSE. + lo_element_root->set_attribute_ns( name = lc_xml_attr_totals + value = '0' ). + ENDIF. + +********************************************************************** +* STEP 4: Create subnodes + + " autoFilter + lo_element = lo_document->create_simple_element( name = 'autoFilter' + parent = lo_document ). + + lv_ref = io_table->get_reference( ip_include_totals_row = abap_false ). + lo_element->set_attribute_ns( name = 'ref' + value = lv_ref ). + + lo_element_root->append_child( lo_element ). + + "columns + lo_element = lo_document->create_simple_element( name = 'tableColumns' + parent = lo_document ). + +* lo_columns = io_table->get_columns( ). + LOOP AT io_table->fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true. + ADD 1 TO lv_num_columns. + ENDLOOP. + + lv_value = lv_num_columns. + CONDENSE lv_value. + lo_element->set_attribute_ns( name = 'count' + value = lv_value ). + + lo_element_root->append_child( lo_element ). + + LOOP AT io_table->fieldcat INTO ls_fieldcat WHERE dynpfld = abap_true. + lo_element2 = lo_document->create_simple_element_ns( name = 'tableColumn' + parent = lo_element ). + + lv_value = ls_fieldcat-position. + SHIFT lv_value LEFT DELETING LEADING '0'. + lo_element2->set_attribute_ns( name = 'id' + value = lv_value ). + lv_value = ls_fieldcat-scrtext_m. + lo_element2->set_attribute_ns( name = 'name' + value = lv_value ). + + IF ls_fieldcat-totals_function IS NOT INITIAL. + lo_element2->set_attribute_ns( name = 'totalsRowFunction' + value = ls_fieldcat-totals_function ). + ENDIF. + + lo_element->append_child( lo_element2 ). + ENDLOOP. + + + lo_element = lo_document->create_simple_element( name = 'tableStyleInfo' + parent = lo_element_root ). + + lo_element->set_attribute_ns( name = 'name' + value = io_table->settings-table_style ). + + lo_element->set_attribute_ns( name = 'showFirstColumn' + value = '0' ). + + lo_element->set_attribute_ns( name = 'showLastColumn' + value = '0' ). + + IF io_table->settings-show_row_stripes = abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + + lo_element->set_attribute_ns( name = 'showRowStripes' + value = lv_value ). + + IF io_table->settings-show_column_stripes = abap_true. + lv_value = '1'. + ELSE. + lv_value = '0'. + ENDIF. + + lo_element->set_attribute_ns( name = 'showColumnStripes' + value = lv_value ). + + lo_element_root->append_child( lo_element ). +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +ENDMETHOD. + + + + method CREATE_XL_THEME. + + +* @TODO * + + DATA: lv_xl_theme TYPE string, + lv_xl_theme_01 TYPE string, + lv_xl_theme_02 TYPE string, + lv_xl_theme_03 TYPE string, + lv_xl_theme_04 TYPE string, + lv_xl_theme_05 TYPE string, + lv_xl_theme_06 TYPE string, + lv_xl_theme_07 TYPE string, + lv_xl_theme_08 TYPE string, + lv_xl_theme_09 TYPE string, + lv_xl_theme_10 TYPE string, + lv_xl_theme_11 TYPE string, + lv_xl_theme_12 TYPE string, + lv_xl_theme_13 TYPE string, + lv_xl_theme_14 TYPE string, + lv_xl_theme_15 TYPE string, + lv_xl_theme_16 TYPE string, + lv_xl_theme_17 TYPE string, + lv_xl_theme_18 TYPE string, + lv_xl_theme_19 TYPE string, + lv_xl_theme_20 TYPE string, + lv_xl_theme_21 TYPE string, + lv_xl_theme_22 TYPE string, + lv_xl_theme_23 TYPE string, + lv_xl_theme_24 TYPE string, + lv_xl_theme_25 TYPE string, + lv_xl_theme_26 TYPE string, + lv_xl_theme_27 TYPE string, + lv_xl_theme_28 TYPE string, + lv_xl_theme_29 TYPE string, + lv_xl_theme_30 TYPE string, + lv_xl_theme_31 TYPE string, + lv_xl_theme_32 TYPE string. + + lv_xl_theme_01 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'. + lv_xl_theme_02 = '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" '. + lv_xl_theme_03 = 'lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr '. + lv_xl_theme_04 = 'val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink>'. + lv_xl_theme_05 = '<a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_06 = '<a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" '. + lv_xl_theme_07 = 'typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font '. + lv_xl_theme_08 = 'script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" '. + lv_xl_theme_09 = 'typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_10 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_11 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/>'. + lv_xl_theme_12 = '<a:font script="Arab" typeface="Arial"/><a:font script="Hebr" '. + lv_xl_theme_13 = 'typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font '. + lv_xl_theme_14 = 'script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font '. + lv_xl_theme_15 = 'script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" '. + lv_xl_theme_16 = 'typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" '. + lv_xl_theme_17 = 'typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_18 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod '. + lv_xl_theme_19 = 'val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1">'. + lv_xl_theme_20 = '<a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs '. + lv_xl_theme_21 = 'pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" '. + lv_xl_theme_22 = 'algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr '. + lv_xl_theme_23 = 'val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst>'. + lv_xl_theme_24 = '<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst>'. + lv_xl_theme_25 = '<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" '. + lv_xl_theme_26 = 'dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig '. + lv_xl_theme_27 = 'rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/>'. + lv_xl_theme_28 = '</a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade '. + lv_xl_theme_29 = 'val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" '. + lv_xl_theme_30 = 't="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr '. + lv_xl_theme_31 = 'val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>'. + lv_xl_theme_32 = '</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>'. + + + CONCATENATE lv_xl_theme_01 lv_xl_theme_02 lv_xl_theme_03 lv_xl_theme_04 lv_xl_theme_05 lv_xl_theme_06 lv_xl_theme_07 lv_xl_theme_08 lv_xl_theme_09 lv_xl_theme_10 lv_xl_theme_11 lv_xl_theme_12 lv_xl_theme_13 lv_xl_theme_14 lv_xl_theme_15 + lv_xl_theme_16 lv_xl_theme_17 lv_xl_theme_18 lv_xl_theme_19 lv_xl_theme_20 lv_xl_theme_21 lv_xl_theme_22 lv_xl_theme_23 lv_xl_theme_24 lv_xl_theme_25 lv_xl_theme_26 lv_xl_theme_27 lv_xl_theme_28 lv_xl_theme_29 lv_xl_theme_30 + lv_xl_theme_31 lv_xl_theme_32 + INTO lv_xl_theme SEPARATED BY space. + + CALL FUNCTION 'SCMS_STRING_TO_XSTRING' + EXPORTING + text = lv_xl_theme + IMPORTING + buffer = ep_content. + + +endmethod. + + + + method CREATE_XL_WORKBOOK. + + +** Constant node name + DATA: lc_xml_node_workbook TYPE string VALUE 'workbook', + lc_xml_node_fileversion TYPE string VALUE 'fileVersion', + lc_xml_node_workbookpr TYPE string VALUE 'workbookPr', + lc_xml_node_bookviews TYPE string VALUE 'bookViews', + lc_xml_node_workbookview TYPE string VALUE 'workbookView', + lc_xml_node_sheets TYPE string VALUE 'sheets', + lc_xml_node_sheet TYPE string VALUE 'sheet', + lc_xml_node_calcpr TYPE string VALUE 'calcPr', + lc_xml_node_definednames TYPE string VALUE 'definedNames', + lc_xml_node_definedname TYPE string VALUE 'definedName', + " Node attributes + lc_xml_attr_appname TYPE string VALUE 'appName', + lc_xml_attr_lastedited TYPE string VALUE 'lastEdited', + lc_xml_attr_lowestedited TYPE string VALUE 'lowestEdited', + lc_xml_attr_rupbuild TYPE string VALUE 'rupBuild', + lc_xml_attr_themeversion TYPE string VALUE 'defaultThemeVersion', + lc_xml_attr_xwindow TYPE string VALUE 'xWindow', + lc_xml_attr_ywindow TYPE string VALUE 'yWindow', + lc_xml_attr_windowwidth TYPE string VALUE 'windowWidth', + lc_xml_attr_windowheight TYPE string VALUE 'windowHeight', + lc_xml_attr_name TYPE string VALUE 'name', + lc_xml_attr_sheetid TYPE string VALUE 'sheetId', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_calcid TYPE string VALUE 'calcId', + " Node namespace + lc_r_ns TYPE string VALUE 'r', + lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + " Node id + lc_xml_node_ridx_id TYPE string VALUE 'rId#'. + + DATA: lo_ixml TYPE REF TO if_ixml, + lo_document TYPE REF TO if_ixml_document, + lo_element_root TYPE REF TO if_ixml_element, + lo_element TYPE REF TO if_ixml_element, + lo_sub_element TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_ostream TYPE REF TO if_ixml_ostream, + lo_renderer TYPE REF TO if_ixml_renderer, + lo_iterator TYPE REF TO cl_object_collection_iterator, + lo_worksheet TYPE REF TO zcl_excel_worksheet, + lo_range TYPE REF TO zcl_excel_range. + + DATA: lv_xml_node_ridx_id TYPE string, + lv_value TYPE string, + lv_syindex TYPE string. + +********************************************************************** +* STEP 1: Create [Content_Types].xml into the root of the ZIP + lo_ixml = cl_ixml=>create( ). + +********************************************************************** +* STEP 2: Set document attributes + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'utf-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + +********************************************************************** +* STEP 3: Create main node + lo_element_root = lo_document->create_simple_element( name = lc_xml_node_workbook + parent = lo_document ). + lo_element_root->set_attribute_ns( name = 'xmlns' + value = lc_xml_node_ns ). + lo_element_root->set_attribute_ns( name = 'xmlns:r' + value = lc_xml_node_r_ns ). + +********************************************************************** +* STEP 4: Create subnode + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_fileversion + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_appname + value = 'xl' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lastedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_lowestedited + value = '4' ). + lo_element->set_attribute_ns( name = lc_xml_attr_rupbuild + value = '4506' ). + lo_element_root->append_child( lo_element ). + + " fileVersion node + lo_element = lo_document->create_simple_element( name = lc_xml_node_workbookpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_themeversion + value = '124226' ). + lo_element_root->append_child( lo_element ). + + " bookviews node + lo_element = lo_document->create_simple_element( name = lc_xml_node_bookviews + parent = lo_document ). + " bookview node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_workbookview + parent = lo_document ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_xwindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_ywindow + value = '120' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowwidth + value = '19035' ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_windowheight + value = '8445' ). + lo_element->append_child( lo_sub_element )." bookview node + lo_element_root->append_child( lo_element )." bookviews node + + " sheets node + lo_element = lo_document->create_simple_element( name = lc_xml_node_sheets + parent = lo_document ). + lo_iterator = excel->get_worksheets_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " sheet node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_sheet + parent = lo_document ). + lo_worksheet ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_worksheet->title. + lv_syindex = sy-index. + SHIFT lv_syindex RIGHT DELETING TRAILING space. + SHIFT lv_syindex LEFT DELETING LEADING space. + lv_xml_node_ridx_id = lc_xml_node_ridx_id. + REPLACE ALL OCCURRENCES OF '#' IN lv_xml_node_ridx_id WITH lv_syindex. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_sheetid + value = lv_syindex ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_id + prefix = lc_r_ns + value = lv_xml_node_ridx_id ). + lo_element->append_child( lo_sub_element ). " sheet node + ENDWHILE. + lo_element_root->append_child( lo_element )." sheets node + + + " ranges node + lo_element = lo_document->create_simple_element( name = lc_xml_node_definedNames + parent = lo_document ). + lo_iterator = excel->get_ranges_iterator( ). + + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + " range node + lo_sub_element = lo_document->create_simple_element_ns( name = lc_xml_node_definedName + parent = lo_document ). + lo_range ?= lo_iterator->if_object_collection_iterator~get_next( ). + lv_value = lo_range->name. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_name + value = lv_value ). + lv_value = lo_range->get_value( ). + lo_sub_element->set_value( lv_value ). + lo_element->append_child( lo_sub_element ). " range node + ENDWHILE. + lo_element_root->append_child( lo_element )." ranges node + + " calcPr node + lo_element = lo_document->create_simple_element( name = lc_xml_node_calcpr + parent = lo_document ). + lo_element->set_attribute_ns( name = lc_xml_attr_calcid + value = '125725' ). + lo_element_root->append_child( lo_element ). + + +********************************************************************** +* STEP 5: Create xstring stream + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = ep_content ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + +endmethod. + + + + + method FLAG2BOOL. + + + IF ip_flag EQ abap_true. + ep_boolean = 'true'. + ELSE. + ep_boolean = 'false'. + ENDIF. +endmethod. + + + + + method GET_SHARED_STRING_INDEX. + + + DATA ls_shared_string TYPE zexcel_s_shared_string. + + READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value. + ep_index = ls_shared_string-string_no. + +endmethod. + + + + class ZCL_EXCEL_TABLE definition + public + final + create public . + +*"* public components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +public section. + type-pools ABAP . + + constants BUILTINSTYLE_DARK1 type ZEXCEL_TABLE_STYLE value 'TableStyleDark1'. "#EC NOTEXT + constants BUILTINSTYLE_DARK2 type ZEXCEL_TABLE_STYLE value 'TableStyleDark2'. "#EC NOTEXT + constants BUILTINSTYLE_DARK3 type ZEXCEL_TABLE_STYLE value 'TableStyleDark3'. "#EC NOTEXT + constants BUILTINSTYLE_DARK4 type ZEXCEL_TABLE_STYLE value 'TableStyleDark4'. "#EC NOTEXT + constants BUILTINSTYLE_DARK5 type ZEXCEL_TABLE_STYLE value 'TableStyleDark5'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT1 type ZEXCEL_TABLE_STYLE value 'TableStyleLight1'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT2 type ZEXCEL_TABLE_STYLE value 'TableStyleLight2'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT3 type ZEXCEL_TABLE_STYLE value 'TableStyleLight3'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT4 type ZEXCEL_TABLE_STYLE value 'TableStyleLight4'. "#EC NOTEXT + constants BUILTINSTYLE_LIGHT5 type ZEXCEL_TABLE_STYLE value 'TableStyleLight5'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM1 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium1'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM2 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium2'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM3 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium3'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM4 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium4'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM5 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium5'. "#EC NOTEXT + constants BUILTINSTYLE_MEDIUM9 type ZEXCEL_TABLE_STYLE value 'TableStyleMedium9'. "#EC NOTEXT + constants BUILTINSTYLE_PIVOT_LIGHT16 type ZEXCEL_TABLE_STYLE value 'PivotStyleLight16'. "#EC NOTEXT + data FIELDCAT type ZEXCEL_T_FIELDCATALOG . + data SETTINGS type ZEXCEL_S_TABLE_SETTINGS . + constants TOTALS_FUNCTION_AVERAGE type ZEXCEL_TABLE_TOTALS_FUNCTION value 'average'. "#EC NOTEXT + constants TOTALS_FUNCTION_COUNT type ZEXCEL_TABLE_TOTALS_FUNCTION value 'count'. "#EC NOTEXT + constants TOTALS_FUNCTION_MAX type ZEXCEL_TABLE_TOTALS_FUNCTION value 'max'. "#EC NOTEXT + constants TOTALS_FUNCTION_MIN type ZEXCEL_TABLE_TOTALS_FUNCTION value 'min'. "#EC NOTEXT + constants TOTALS_FUNCTION_SUM type ZEXCEL_TABLE_TOTALS_FUNCTION value 'sum'. "#EC NOTEXT + + methods GET_TOTALS_FORMULA + importing + !IP_COLUMN type CLIKE + !IP_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION + returning + value(EP_FORMULA) type STRING . + methods HAS_TOTALS + returning + value(EP_RESULT) type ABAP_BOOL . + methods SET_DATA + importing + !IR_DATA type STANDARD TABLE . + methods GET_ID + returning + value(OV_ID) type I . + methods SET_ID + importing + !IV_ID type I . + methods CONSTRUCTOR . + methods GET_NAME + returning + value(OV_NAME) type STRING . + methods GET_REFERENCE + importing + !IP_INCLUDE_TOTALS_ROW type ABAP_BOOL default ABAP_TRUE + returning + value(OV_REFERENCE) type STRING . + *"* protected components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +protected section. + *"* private components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +private section. + + data ID type I . + data NAME type STRING . + data TABLE_DATA type ref to DATA . + *"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + *"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + *"* use this source file for any macro definitions you need +*"* in the implementation part of the class + + ABAP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. + +endmethod. + + + + method GET_ID. + ov_id = id. +endmethod. + + + + method GET_NAME. + + IF me->name IS INITIAL. + me->name = zcl_excel_common=>number_to_excel_string( ip_value = me->id ). + CONCATENATE 'table' me->name INTO me->name. + ENDIF. + + ov_name = me->name. +endmethod. + + + + + method GET_REFERENCE. + DATA: lv_column TYPE zexcel_cell_column, + lv_table_lines TYPE i, + lv_right_column TYPE zexcel_cell_column_alpha, + ls_field_catalog TYPE zexcel_s_fieldcatalog, + lv_bottom_row TYPE zexcel_cell_row, + lv_top_row_string(10) TYPE c, + lv_bottom_row_string(10) TYPE c. + + FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE. + +*column + lv_column = zcl_excel_common=>convert_column2int( settings-top_left_column ). + lv_table_lines = 0. + LOOP AT fieldcat INTO ls_field_catalog WHERE dynpfld EQ abap_true. + ADD 1 TO lv_table_lines. + ENDLOOP. + lv_column = lv_column + lv_table_lines - 1. + lv_right_column = zcl_excel_common=>convert_column2alpha( lv_column ). + +*row + ASSIGN table_data->* TO <fs_table>. + DESCRIBE TABLE <fs_table> LINES lv_table_lines. + lv_bottom_row = settings-top_left_row + lv_table_lines . + + IF me->has_totals( ) = abap_true AND ip_include_totals_row = abap_true. + add 1 to lv_bottom_row. + ENDIF. + + WRITE settings-top_left_row TO lv_top_row_string. + CONDENSE lv_top_row_string. + WRITE lv_bottom_row TO lv_bottom_row_string. + CONDENSE lv_bottom_row_string. + + CONCATENATE settings-top_left_column lv_top_row_string + ':' + lv_right_column lv_bottom_row_string INTO ov_reference. + +endmethod. + + + + + + method GET_TOTALS_FORMULA. + CONSTANTS: lc_function_id_sum TYPE string VALUE '109', + lc_function_id_min TYPE string VALUE '105', + lc_function_id_max TYPE string VALUE '104', + lc_function_id_count TYPE string VALUE '103', + lc_function_id_average TYPE string VALUE '101'. + + DATA: lv_function_id TYPE string. + + CASE ip_function. + WHEN zcl_excel_table=>totals_function_sum. + lv_function_id = lc_function_id_sum. + + WHEN zcl_excel_table=>totals_function_min. + lv_function_id = lc_function_id_min. + + WHEN zcl_excel_table=>totals_function_max. + lv_function_id = lc_function_id_max. + + WHEN zcl_excel_table=>totals_function_count. + lv_function_id = lc_function_id_count. + + WHEN zcl_excel_table=>totals_function_average. + lv_function_id = lc_function_id_average. + + WHEN OTHERS. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Invalid totals formula. See ZCL_ for possible values'. + ENDCASE. + + CONCATENATE 'SUBTOTAL(' lv_function_id ',[' ip_column '])' INTO ep_formula. +endmethod. + + + + method HAS_TOTALS. + DATA: ls_field_catalog TYPE zexcel_s_fieldcatalog. + + ep_result = abap_false. + + LOOP AT fieldcat INTO ls_field_catalog. + IF ls_field_catalog-totals_function IS NOT INITIAL. + ep_result = abap_true. + EXIT. + ENDIF. + ENDLOOP. + +endmethod. + + + + method SET_DATA. + GET REFERENCE OF ir_data INTO me->table_data. +endmethod. + + + + method SET_ID. + id = iv_id. +endmethod. + + + diff --git a/nuggs/NUGG_ABAP2XLSX_V_3_0.nugg.zip b/nuggs/NUGG_ABAP2XLSX_V_3_0.nugg.zip new file mode 100644 index 0000000..0bbe9d7 Binary files /dev/null and b/nuggs/NUGG_ABAP2XLSX_V_3_0.nugg.zip differ diff --git a/test/OpenXMLValidator/Binaries/OpenXMLValidator.exe b/test/OpenXMLValidator/Binaries/OpenXMLValidator.exe new file mode 100644 index 0000000..5662f82 Binary files /dev/null and b/test/OpenXMLValidator/Binaries/OpenXMLValidator.exe differ diff --git a/test/OpenXMLValidator/Binaries/OpenXMLValidator.exe.config b/test/OpenXMLValidator/Binaries/OpenXMLValidator.exe.config new file mode 100644 index 0000000..809fa1f --- /dev/null +++ b/test/OpenXMLValidator/Binaries/OpenXMLValidator.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/test/OpenXMLValidator/Binaries/OpenXMLValidator.pdb b/test/OpenXMLValidator/Binaries/OpenXMLValidator.pdb new file mode 100644 index 0000000..700501a Binary files /dev/null and b/test/OpenXMLValidator/Binaries/OpenXMLValidator.pdb differ diff --git a/test/OpenXMLValidator/src/CommandLineArgs.cs b/test/OpenXMLValidator/src/CommandLineArgs.cs new file mode 100644 index 0000000..49c7dd8 --- /dev/null +++ b/test/OpenXMLValidator/src/CommandLineArgs.cs @@ -0,0 +1,77 @@ +namespace Abap2Xlsx.OpenXMLValidator +{ + using System; + using System.IO; + + /// + /// Command line arguments for validator + /// + public class CommandLineArgs + { + + private const string DefaultDirectory = "."; + private const string DefaultSearchPattern = "*.xlsx"; + + public string Directory { get; private set; } + public string SearchPattern { get; private set; } + public bool ShowUsage { get; private set; } + + public CommandLineArgs() + { + this.Directory = DefaultDirectory; + this.SearchPattern = DefaultSearchPattern; + } + + public void Parse(string[] args) + { + for (int currentArg = 0; currentArg < args.Length; currentArg++) + { + string arg = args[currentArg]; + + switch (arg) + { + case "-d": + case "/d": + string dir = GetNextArg(args, currentArg); + + DirectoryInfo di = new DirectoryInfo(dir); + if (!di.Exists) + { + throw new ArgumentException(string.Format("Unknown directory: {0}", dir)); + } + + this.Directory = dir; + currentArg++; + + break; + + case "-p": + case "/p": + this.SearchPattern = GetNextArg(args, currentArg); + currentArg++; + + break; + + case "-?": + case "/?": + this.ShowUsage = true; + + break; + + default: + throw new ArgumentException(string.Format("Unknown argument: {0}", arg)); + } + } + } + + private string GetNextArg(string[] args, int currentArg) + { + if (currentArg >= args.Length - 1) + { + throw new ArgumentException(string.Format("Missing value for argument: {0}", args[currentArg])); + } + + return args[currentArg + 1]; + } + } +} diff --git a/test/OpenXMLValidator/src/OpenXMLValidator.csproj b/test/OpenXMLValidator/src/OpenXMLValidator.csproj new file mode 100644 index 0000000..9c9eab7 --- /dev/null +++ b/test/OpenXMLValidator/src/OpenXMLValidator.csproj @@ -0,0 +1,74 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {99967614-17D7-4521-BE36-1540B6D5CD89} + Exe + Properties + OpenXMLValidator + OpenXMLValidator + v3.5 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + True + True + Resources.resx + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + \ No newline at end of file diff --git a/test/OpenXMLValidator/src/Program.cs b/test/OpenXMLValidator/src/Program.cs new file mode 100644 index 0000000..f4d3e7a --- /dev/null +++ b/test/OpenXMLValidator/src/Program.cs @@ -0,0 +1,101 @@ +namespace Abap2Xlsx.OpenXMLValidator +{ + using System; + using System.Linq; + using System.IO; + using DocumentFormat.OpenXml.Packaging; + using DocumentFormat.OpenXml.Validation; + + /// + /// Simple command line wrapper around OpenXMLValidator. + /// See CommandLineArgs for possible options. + /// + class Program + { + /// + /// Entry point + /// + /// The arguments + static void Main(string[] args) + { + CommandLineArgs arguments = new CommandLineArgs(); + try + { + arguments.Parse(args); + } + catch (ArgumentException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(Resources.Usage); + Environment.Exit(1); + } + + if (arguments.ShowUsage) + { + Console.WriteLine(Resources.Usage); + Environment.Exit(0); + } + + string[] files = Directory.GetFiles(arguments.Directory, arguments.SearchPattern); + if (!files.Any()) + { + Console.WriteLine("No matching files found"); + Environment.Exit(1); + } + + for (int i = 1; i <= files.Length; i++) + { + Console.WriteLine("Validating file {0} from {1}", i, files.Length); + ValidateFile(files[i - 1]); + } + } + + private static void ValidateFile(string file) + { + ConsoleColor color = Console.ForegroundColor; + + try + { + Console.WriteLine("File name: {0}", file); + + OpenXmlValidator validator = new OpenXmlValidator(); + + using (var doc = SpreadsheetDocument.Open(file, true)) + { + var errors = validator.Validate(doc); + if (errors.Any()) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Found {0} validation errors: ", errors.Count()); + + int count = 0; + foreach (ValidationErrorInfo error in errors) + { + count++; + Console.WriteLine("Error " + count); + Console.WriteLine("Part: " + error.Part.Uri); + Console.WriteLine("Description: " + error.Description); + Console.WriteLine("Path: " + error.Path.XPath); + } + } + else + { + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Document valid"); + } + + Console.WriteLine(); + } + } + catch (Exception e) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Exception occured while validating file: {0} - {1}",e.GetType().ToString() ,e.Message); + } + finally + { + Console.ForegroundColor = color; + } + } + } +} diff --git a/test/OpenXMLValidator/src/Properties/AssemblyInfo.cs b/test/OpenXMLValidator/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8541f65 --- /dev/null +++ b/test/OpenXMLValidator/src/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenXMLValidator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenXMLValidator")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ab032f8b-6f76-4bfc-8f1c-3a96d328f670")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test/OpenXMLValidator/src/Resources.Designer.cs b/test/OpenXMLValidator/src/Resources.Designer.cs new file mode 100644 index 0000000..7c39cac --- /dev/null +++ b/test/OpenXMLValidator/src/Resources.Designer.cs @@ -0,0 +1,89 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Abap2Xlsx.OpenXMLValidator +{ + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenXMLValidator.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to USAGE: + /// OpenXMLValidator.exe [-d direcory] [-p pattern] + /// + ///OPTIONS: + /// -d + /// Directory with files for validation (default value if not specified - current directory) + /// -p + /// Search pattern used for finding files. * and ? allowed as wildcards (default value if not specified - *.xlsx) + /// -? + /// Show this help + /// + ///EXAMPLES: + /// OpenXMLValidator.exe + /// validate all xlsx files in current directory + /// OpenXMLValidator.exe -d c:\temp + /// validate all xlsx files in c:\temp directory + /// OpenXMLValidator.exe -d c:\ [rest of string was truncated]";. + /// + internal static string Usage { + get { + return ResourceManager.GetString("Usage", resourceCulture); + } + } + } +} diff --git a/test/OpenXMLValidator/src/Resources.resx b/test/OpenXMLValidator/src/Resources.resx new file mode 100644 index 0000000..7b3ec18 --- /dev/null +++ b/test/OpenXMLValidator/src/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Resources\usage.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1250 + + \ No newline at end of file diff --git a/test/OpenXMLValidator/src/Resources/usage.txt b/test/OpenXMLValidator/src/Resources/usage.txt new file mode 100644 index 0000000..7a3b24c --- /dev/null +++ b/test/OpenXMLValidator/src/Resources/usage.txt @@ -0,0 +1,18 @@ +USAGE: + OpenXMLValidator.exe [-d direcory] [-p pattern] + +OPTIONS: + -d + Directory with files for validation (default value if not specified - current directory) + -p + Search pattern used for finding files. * and ? allowed as wildcards (default value if not specified - *.xlsx) + -? + Show this help + +EXAMPLES: + OpenXMLValidator.exe + validate all xlsx files in current directory + OpenXMLValidator.exe -d c:\temp + validate all xlsx files in c:\temp directory + OpenXMLValidator.exe -d c:\temp -p demo*.xlsx + validate all xlsx files in c:\temp directory starting with 'demo' \ No newline at end of file diff --git a/test/OpenXMLValidator/src/app.config b/test/OpenXMLValidator/src/app.config new file mode 100644 index 0000000..809fa1f --- /dev/null +++ b/test/OpenXMLValidator/src/app.config @@ -0,0 +1,3 @@ + + + diff --git a/test/OpenXMLValidator/src/readme.txt b/test/OpenXMLValidator/src/readme.txt new file mode 100644 index 0000000..ea70c99 --- /dev/null +++ b/test/OpenXMLValidator/src/readme.txt @@ -0,0 +1,2 @@ +To build and run you need .Net 3.5 and OpenXMl SDK installed. +It can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&displaylang=en \ No newline at end of file