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. endmethod. method CREATE_NEW_ARGB. 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. 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. 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. 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 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. 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. 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_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_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 SET_CELL. 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. 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. 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. 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. 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. me->excel = io_excel. 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. 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. ** 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. ** 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_CALCCHAIN. ** 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. ** 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. ** 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. ** 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. ** 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. ** 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. * @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. 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. 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_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_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. method SAVE_AS. 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. 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. 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. 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. 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. 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. 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. 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. *&---------------------------------------------------------------------* *& 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.