diff --git a/src/zcl_excel_columns.clas.abap b/src/zcl_excel_columns.clas.abap index ddbdae5..29b8648 100644 --- a/src/zcl_excel_columns.clas.abap +++ b/src/zcl_excel_columns.clas.abap @@ -5,38 +5,45 @@ class ZCL_EXCEL_COLUMNS definition *"* public components of class ZCL_EXCEL_COLUMNS *"* do not include other source files here!!! -public section. + public section. + types: + begin of MTY_S_HASHED_COLUMN, + COLUMN_INDEX type INT4, + COLUMN type ref to ZCL_EXCEL_COLUMN, + end of MTY_S_HASHED_COLUMN , + MTY_TS_HASEHD_COLUMN type hashed table of MTY_S_HASHED_COLUMN with unique key COLUMN_INDEX. - methods ADD - importing - !IO_COLUMN type ref to ZCL_EXCEL_COLUMN . - methods CLEAR . - methods CONSTRUCTOR . - methods GET - importing - !IP_INDEX type I - returning - value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . - 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 - !IO_COLUMN type ref to ZCL_EXCEL_COLUMN . - methods SIZE - returning - value(EP_SIZE) type I . + methods ADD + importing + !IO_COLUMN type ref to ZCL_EXCEL_COLUMN . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . + 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 + !IO_COLUMN type ref to ZCL_EXCEL_COLUMN . + methods SIZE + returning + value(EP_SIZE) type I . *"* protected components of class ZABAP_EXCEL_WORKSHEETS *"* do not include other source files here!!! -protected section. + protected section. *"* private components of class ZABAP_EXCEL_RANGES *"* do not include other source files here!!! -private section. + private section. - data COLUMNS type ref to CL_OBJECT_COLLECTION . + data COLUMNS type ref to CL_OBJECT_COLLECTION . + data COLUMNS_HASEHD type MTY_TS_HASEHD_COLUMN . ENDCLASS. @@ -44,44 +51,58 @@ ENDCLASS. CLASS ZCL_EXCEL_COLUMNS IMPLEMENTATION. -METHOD add. - columns->add( io_column ). -ENDMETHOD. + method ADD. + data: LS_HASHED_COLUMN type MTY_S_HASHED_COLUMN. + + LS_HASHED_COLUMN-COLUMN_INDEX = IO_COLUMN->GET_COLUMN_INDEX( ). + LS_HASHED_COLUMN-COLUMN = IO_COLUMN. + + insert LS_HASHED_COLUMN into table COLUMNS_HASEHD . + + COLUMNS->ADD( IO_COLUMN ). + endmethod. -METHOD clear. - columns->clear( ). -ENDMETHOD. + method CLEAR. + clear COLUMNS_HASEHD. + COLUMNS->CLEAR( ). + endmethod. -METHOD constructor. + method CONSTRUCTOR. - CREATE OBJECT columns. + create object COLUMNS. -ENDMETHOD. + endmethod. -METHOD get. - eo_column ?= columns->if_object_collection~get( ip_index ). -ENDMETHOD. + method GET. + field-symbols: type MTY_S_HASHED_COLUMN. + + read table COLUMNS_HASEHD with key COLUMN_INDEX = IP_INDEX assigning . + if SY-SUBRC = 0. + EO_COLUMN = -COLUMN. + endif. + endmethod. -METHOD get_iterator. - eo_iterator ?= columns->if_object_collection~get_iterator( ). -ENDMETHOD. + method GET_ITERATOR. + EO_ITERATOR ?= COLUMNS->IF_OBJECT_COLLECTION~GET_ITERATOR( ). + endmethod. -METHOD is_empty. - is_empty = columns->if_object_collection~is_empty( ). -ENDMETHOD. + method IS_EMPTY. + IS_EMPTY = COLUMNS->IF_OBJECT_COLLECTION~IS_EMPTY( ). + endmethod. -METHOD remove. - columns->remove( io_column ). -ENDMETHOD. + method REMOVE. + delete table COLUMNS_HASEHD with table key COLUMN_INDEX = IO_COLUMN->GET_COLUMN_INDEX( ) . + COLUMNS->REMOVE( IO_COLUMN ). + endmethod. -METHOD size. - ep_size = columns->if_object_collection~size( ). -ENDMETHOD. + method SIZE. + EP_SIZE = COLUMNS->IF_OBJECT_COLLECTION~SIZE( ). + endmethod. ENDCLASS. diff --git a/src/zcl_excel_rows.clas.abap b/src/zcl_excel_rows.clas.abap index c1cf0f1..7ce0244 100644 --- a/src/zcl_excel_rows.clas.abap +++ b/src/zcl_excel_rows.clas.abap @@ -12,36 +12,44 @@ class ZCL_EXCEL_ROWS definition *"* do not include other source files here!!! *"* protected components of class ZABAP_EXCEL_WORKSHEETS *"* do not include other source files here!!! -public section. + public section. + types: + begin of MTY_S_HASHED_ROW, + ROW_INDEX type INT4, + ROW type ref to ZCL_EXCEL_ROW, + end of MTY_S_HASHED_ROW , + MTY_TS_HASEHD_ROW type hashed table of MTY_S_HASHED_ROW with unique key ROW_INDEX. - methods ADD - importing - !IO_ROW type ref to ZCL_EXCEL_ROW . - methods CLEAR . - methods CONSTRUCTOR . - methods GET - importing - !IP_INDEX type I - returning - value(EO_ROW) type ref to ZCL_EXCEL_ROW . - 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 - !IO_ROW type ref to ZCL_EXCEL_ROW . - methods SIZE - returning - value(EP_SIZE) type I . - PROTECTED SECTION. + methods ADD + importing + !IO_ROW type ref to ZCL_EXCEL_ROW . + methods CLEAR . + methods CONSTRUCTOR . + methods GET + importing + !IP_INDEX type I + returning + value(EO_ROW) type ref to ZCL_EXCEL_ROW . + 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 + !IO_ROW type ref to ZCL_EXCEL_ROW . + methods SIZE + returning + value(EP_SIZE) type I . + protected section. *"* private components of class ZABAP_EXCEL_RANGES *"* do not include other source files here!!! - PRIVATE SECTION. + private section. + + data ROWS type ref to CL_OBJECT_COLLECTION . + data ROWS_HASEHD type MTY_TS_HASEHD_ROW . - DATA rows TYPE REF TO cl_object_collection . ENDCLASS. @@ -49,44 +57,58 @@ ENDCLASS. CLASS ZCL_EXCEL_ROWS IMPLEMENTATION. - METHOD add. - rows->add( io_row ). - ENDMETHOD. "ADD + method ADD. + data: LS_HASHED_ROW type MTY_S_HASHED_ROW. + + LS_HASHED_ROW-ROW_INDEX = IO_ROW->GET_ROW_INDEX( ). + LS_HASHED_ROW-ROW = IO_ROW. + + insert LS_HASHED_ROW into table ROWS_HASEHD. + + ROWS->ADD( IO_ROW ). + endmethod. "ADD - METHOD clear. - rows->clear( ). - ENDMETHOD. "CLEAR + method CLEAR. + clear ROWS_HASEHD. + ROWS->CLEAR( ). + endmethod. "CLEAR - METHOD constructor. + method CONSTRUCTOR. - CREATE OBJECT rows. + create object ROWS. - ENDMETHOD. "CONSTRUCTOR + endmethod. "CONSTRUCTOR - METHOD get. - eo_row ?= rows->if_object_collection~get( ip_index ). - ENDMETHOD. "GET + method GET. + field-symbols: type MTY_S_HASHED_ROW. + + read table ROWS_HASEHD with key ROW_INDEX = IP_INDEX assigning . + if SY-SUBRC = 0. + EO_ROW = -ROW. + endif. + endmethod. "GET - METHOD get_iterator. - eo_iterator ?= rows->if_object_collection~get_iterator( ). - ENDMETHOD. "GET_ITERATOR + method GET_ITERATOR. + EO_ITERATOR ?= ROWS->IF_OBJECT_COLLECTION~GET_ITERATOR( ). + endmethod. "GET_ITERATOR - METHOD is_empty. - is_empty = rows->if_object_collection~is_empty( ). - ENDMETHOD. "IS_EMPTY + method IS_EMPTY. + IS_EMPTY = ROWS->IF_OBJECT_COLLECTION~IS_EMPTY( ). + endmethod. "IS_EMPTY - METHOD remove. - rows->remove( io_row ). - ENDMETHOD. "REMOVE + method REMOVE. + delete table ROWS_HASEHD with table key ROW_INDEX = IO_ROW->GET_ROW_INDEX( ) . + ROWS->REMOVE( IO_ROW ). + endmethod. "REMOVE - METHOD size. - ep_size = rows->if_object_collection~size( ). - ENDMETHOD. "SIZE + method SIZE. + EP_SIZE = ROWS->IF_OBJECT_COLLECTION~SIZE( ). + endmethod. "SIZE ENDCLASS. diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index b9258ea..0eba77e 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -2,571 +2,571 @@ class ZCL_EXCEL_WORKSHEET definition public create public . -public section. + public section. *"* public components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! - type-pools ABAP . + type-pools ABAP . - interfaces ZIF_EXCEL_SHEET_PRINTSETTINGS . - interfaces ZIF_EXCEL_SHEET_PROPERTIES . - interfaces ZIF_EXCEL_SHEET_PROTECTION . - interfaces ZIF_EXCEL_SHEET_VBA_PROJECT . + interfaces ZIF_EXCEL_SHEET_PRINTSETTINGS . + interfaces ZIF_EXCEL_SHEET_PROPERTIES . + interfaces ZIF_EXCEL_SHEET_PROTECTION . + interfaces ZIF_EXCEL_SHEET_VBA_PROJECT . - types: - begin of MTY_S_OUTLINE_ROW, - row_from type i, - row_to type i, - collapsed type abap_bool, - end of mty_s_outline_row . - types: - MTY_TS_OUTLINES_ROW type sorted table of MTY_S_OUTLINE_ROW with unique key row_from row_to . + types: + begin of MTY_S_OUTLINE_ROW, + ROW_FROM type I, + ROW_TO type I, + COLLAPSED type ABAP_BOOL, + end of MTY_S_OUTLINE_ROW . + types: + MTY_TS_OUTLINES_ROW type sorted table of MTY_S_OUTLINE_ROW with unique key ROW_FROM ROW_TO . - constants C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT - constants C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT - constants C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT - data EXCEL type ref to ZCL_EXCEL read-only . + constants C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT + constants C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT + constants C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT + data EXCEL type ref to ZCL_EXCEL read-only . data PRINT_GRIDLINES type ZEXCEL_PRINT_GRIDLINES read-only value ABAP_FALSE. "#EC NOTEXT . " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . - data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . - data SHOW_GRIDLINES type ZEXCEL_SHOW_GRIDLINES read-only value ABAP_TRUE. "#EC NOTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - data SHOW_ROWCOLHEADERS type ZEXCEL_SHOW_GRIDLINES read-only value ABAP_TRUE. "#EC NOTEXT . " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - data STYLES type ZEXCEL_T_SHEET_STYLE . - data TABCOLOR type ZEXCEL_S_TABCOLOR read-only . + data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . + data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . + data SHOW_GRIDLINES type ZEXCEL_SHOW_GRIDLINES read-only value ABAP_TRUE. "#EC NOTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + data SHOW_ROWCOLHEADERS type ZEXCEL_SHOW_GRIDLINES read-only value ABAP_TRUE. "#EC NOTEXT . " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + data STYLES type ZEXCEL_T_SHEET_STYLE . + data TABCOLOR type ZEXCEL_S_TABCOLOR read-only . - methods ADD_DRAWING - importing - !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . - methods ADD_NEW_COLUMN - importing - !IP_COLUMN type SIMPLE - returning - value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . - methods ADD_NEW_STYLE_COND - returning - value(EO_STYLE_COND) type ref to ZCL_EXCEL_STYLE_COND . - methods ADD_NEW_DATA_VALIDATION - returning - value(EO_DATA_VALIDATION) type ref to ZCL_EXCEL_DATA_VALIDATION . - methods ADD_NEW_RANGE - returning - value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . - methods ADD_NEW_ROW - importing - !IP_ROW type SIMPLE - returning - value(EO_ROW) type ref to ZCL_EXCEL_ROW . - methods BIND_ALV - importing - !IO_ALV type ref to OBJECT - !IT_TABLE type STANDARD TABLE - !I_TOP type I default 1 - !I_LEFT type I default 1 - !TABLE_STYLE type ZEXCEL_TABLE_STYLE optional - !I_TABLE type ABAP_BOOL default ABAP_TRUE - raising - ZCX_EXCEL . - type-pools SLIS . - type-pools SOI . - methods BIND_ALV_OLE2 - importing - !I_DOCUMENT_URL type CHAR255 default SPACE - !I_XLS type C default SPACE - !I_SAVE_PATH type STRING - !IO_ALV type ref to CL_GUI_ALV_GRID - !IT_LISTHEADER type SLIS_T_LISTHEADER optional - !I_TOP type I default 1 - !I_LEFT type I default 1 - !I_COLUMNS_HEADER type C default 'X' - !I_COLUMNS_AUTOFIT type C default 'X' - !I_FORMAT_COL_HEADER type SOI_FORMAT_ITEM optional - !I_FORMAT_SUBTOTAL type SOI_FORMAT_ITEM optional - !I_FORMAT_TOTAL type SOI_FORMAT_ITEM optional - exceptions - MISS_GUIDE - EX_TRANSFER_KKBLO_ERROR - FATAL_ERROR - INV_DATA_RANGE - DIM_MISMATCH_VKEY - DIM_MISMATCH_SEMA - ERROR_IN_SEMA . - methods BIND_TABLE - importing - !IP_TABLE type STANDARD TABLE - !IT_FIELD_CATALOG type ZEXCEL_T_FIELDCATALOG optional - !IS_TABLE_SETTINGS type ZEXCEL_S_TABLE_SETTINGS optional - value(IV_DEFAULT_DESCR) type C optional - exporting - !ES_TABLE_SETTINGS type ZEXCEL_S_TABLE_SETTINGS - raising - ZCX_EXCEL . - methods CALCULATE_COLUMN_WIDTHS - raising - ZCX_EXCEL . - methods CHANGE_CELL_STYLE - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - !IP_COMPLETE type ZEXCEL_S_CSTYLE_COMPLETE optional - !IP_XCOMPLETE type ZEXCEL_S_CSTYLEX_COMPLETE optional - !IP_FONT type ZEXCEL_S_CSTYLE_FONT optional - !IP_XFONT type ZEXCEL_S_CSTYLEX_FONT optional - !IP_FILL type ZEXCEL_S_CSTYLE_FILL optional - !IP_XFILL type ZEXCEL_S_CSTYLEX_FILL optional - !IP_BORDERS type ZEXCEL_S_CSTYLE_BORDERS optional - !IP_XBORDERS type ZEXCEL_S_CSTYLEX_BORDERS optional - !IP_ALIGNMENT type ZEXCEL_S_CSTYLE_ALIGNMENT optional - !IP_XALIGNMENT type ZEXCEL_S_CSTYLEX_ALIGNMENT optional - !IP_NUMBER_FORMAT_FORMAT_CODE type ZEXCEL_NUMBER_FORMAT optional - !IP_PROTECTION type ZEXCEL_S_CSTYLE_PROTECTION optional - !IP_XPROTECTION type ZEXCEL_S_CSTYLEX_PROTECTION optional - !IP_FONT_BOLD type FLAG optional - !IP_FONT_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_FONT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_FONT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_FONT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_FONT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_FONT_FAMILY type ZEXCEL_STYLE_FONT_FAMILY optional - !IP_FONT_ITALIC type FLAG optional - !IP_FONT_NAME type ZEXCEL_STYLE_FONT_NAME optional - !IP_FONT_SCHEME type ZEXCEL_STYLE_FONT_SCHEME optional - !IP_FONT_SIZE type ZEXCEL_STYLE_FONT_SIZE optional - !IP_FONT_STRIKETHROUGH type FLAG optional - !IP_FONT_UNDERLINE type FLAG optional - !IP_FONT_UNDERLINE_MODE type ZEXCEL_STYLE_FONT_UNDERLINE optional - !IP_FILL_FILLTYPE type ZEXCEL_FILL_TYPE optional - !IP_FILL_ROTATION type ZEXCEL_ROTATION optional - !IP_FILL_FGCOLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_FILL_FGCOLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_FILL_FGCOLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_FILL_FGCOLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_FILL_FGCOLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_FILL_BGCOLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_FILL_BGCOLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_FILL_BGCOLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_FILL_BGCOLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_FILL_BGCOLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_ALLBORDERS type ZEXCEL_S_CSTYLE_BORDER optional - !IP_FILL_GRADTYPE_TYPE type ZEXCEL_S_GRADIENT_TYPE-TYPE optional - !IP_FILL_GRADTYPE_DEGREE type ZEXCEL_S_GRADIENT_TYPE-DEGREE optional - !IP_XBORDERS_ALLBORDERS type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_DIAGONAL type ZEXCEL_S_CSTYLE_BORDER optional - !IP_FILL_GRADTYPE_BOTTOM type ZEXCEL_S_GRADIENT_TYPE-BOTTOM optional - !IP_FILL_GRADTYPE_TOP type ZEXCEL_S_GRADIENT_TYPE-TOP optional - !IP_XBORDERS_DIAGONAL type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_DIAGONAL_MODE type ZEXCEL_DIAGONAL optional - !IP_FILL_GRADTYPE_RIGHT type ZEXCEL_S_GRADIENT_TYPE-RIGHT optional - !IP_BORDERS_DOWN type ZEXCEL_S_CSTYLE_BORDER optional - !IP_FILL_GRADTYPE_LEFT type ZEXCEL_S_GRADIENT_TYPE-LEFT optional - !IP_FILL_GRADTYPE_POSITION1 type ZEXCEL_S_GRADIENT_TYPE-POSITION1 optional - !IP_XBORDERS_DOWN type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_LEFT type ZEXCEL_S_CSTYLE_BORDER optional - !IP_FILL_GRADTYPE_POSITION2 type ZEXCEL_S_GRADIENT_TYPE-POSITION2 optional - !IP_FILL_GRADTYPE_POSITION3 type ZEXCEL_S_GRADIENT_TYPE-POSITION3 optional - !IP_XBORDERS_LEFT type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_RIGHT type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_RIGHT type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_TOP type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_TOP type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_ALIGNMENT_HORIZONTAL type ZEXCEL_ALIGNMENT optional - !IP_ALIGNMENT_VERTICAL type ZEXCEL_ALIGNMENT optional - !IP_ALIGNMENT_TEXTROTATION type ZEXCEL_TEXT_ROTATION optional - !IP_ALIGNMENT_WRAPTEXT type FLAG optional - !IP_ALIGNMENT_SHRINKTOFIT type FLAG optional - !IP_ALIGNMENT_INDENT type ZEXCEL_INDENT optional - !IP_PROTECTION_HIDDEN type ZEXCEL_CELL_PROTECTION optional - !IP_PROTECTION_LOCKED type ZEXCEL_CELL_PROTECTION optional - !IP_BORDERS_ALLBORDERS_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_ALLBORDERS_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_ALLBO_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_ALLBO_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_ALLBO_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_ALLBO_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_DIAGONAL_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_DIAGONAL_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_DIAGONAL_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_DIAGONAL_COLOR_INDE type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_DIAGONAL_COLOR_THEM type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_DIAGONAL_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_DOWN_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_DOWN_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_DOWN_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_DOWN_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_DOWN_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_DOWN_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_LEFT_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_LEFT_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_LEFT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_LEFT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_LEFT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_LEFT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_RIGHT_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_RIGHT_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_RIGHT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_RIGHT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_RIGHT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_RIGHT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_TOP_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_TOP_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_TOP_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_TOP_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_TOP_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_TOP_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - returning - value(EP_GUID) type ZEXCEL_CELL_STYLE - raising - ZCX_EXCEL . - methods CONSTRUCTOR - importing - !IP_EXCEL type ref to ZCL_EXCEL - !IP_TITLE type ZEXCEL_SHEET_TITLE optional - raising - ZCX_EXCEL . - methods DELETE_MERGE - importing - !IP_CELL_COLUMN type SIMPLE optional - !IP_CELL_ROW type ZEXCEL_CELL_ROW optional . - methods DELETE_ROW_OUTLINE - importing - !IV_ROW_FROM type I - !IV_ROW_TO type I - raising - ZCX_EXCEL . - methods FREEZE_PANES - importing - !IP_NUM_COLUMNS type I optional - !IP_NUM_ROWS type I optional - raising - ZCX_EXCEL . - methods GET_ACTIVE_CELL - returning - value(EP_ACTIVE_CELL) type STRING - raising - ZCX_EXCEL . - methods GET_CELL - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - exporting - !EP_VALUE type ZEXCEL_CELL_VALUE - !EP_RC type SYSUBRC - !EP_STYLE type ref to ZCL_EXCEL_STYLE - !EP_GUID type ZEXCEL_CELL_STYLE - !EP_FORMULA type ZEXCEL_CELL_FORMULA - raising - ZCX_EXCEL . - methods GET_COLUMN - importing - !IP_COLUMN type SIMPLE - returning - value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . - methods GET_COLUMNS - returning - value(EO_COLUMNS) type ref to ZCL_EXCEL_COLUMNS . - methods GET_COLUMNS_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_STYLE_COND_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_DATA_VALIDATIONS_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_DATA_VALIDATIONS_SIZE - returning - value(EP_SIZE) type I . - methods GET_DEFAULT_COLUMN - returning - value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . - methods GET_DEFAULT_EXCEL_DATE_FORMAT - returning - value(EP_DEFAULT_EXCEL_DATE_FORMAT) type ZEXCEL_NUMBER_FORMAT . - methods GET_DEFAULT_EXCEL_TIME_FORMAT - returning - value(EP_DEFAULT_EXCEL_TIME_FORMAT) type ZEXCEL_NUMBER_FORMAT . - methods GET_DEFAULT_ROW - returning - value(EO_ROW) type ref to ZCL_EXCEL_ROW . - methods GET_DIMENSION_RANGE - returning - value(EP_DIMENSION_RANGE) type STRING - raising - ZCX_EXCEL . - methods GET_DRAWINGS - importing - !IP_TYPE type ZEXCEL_DRAWING_TYPE optional - returning - value(R_DRAWINGS) type ref to ZCL_EXCEL_DRAWINGS . - methods GET_DRAWINGS_ITERATOR - importing - !IP_TYPE type ZEXCEL_DRAWING_TYPE - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_FREEZE_CELL - exporting - !EP_ROW type ZEXCEL_CELL_ROW - !EP_COLUMN type ZEXCEL_CELL_COLUMN . - methods GET_GUID - returning - value(EP_GUID) type UUID . - methods GET_HIGHEST_COLUMN - returning - value(R_HIGHEST_COLUMN) type ZEXCEL_CELL_COLUMN - raising - ZCX_EXCEL . - methods GET_HIGHEST_ROW - returning - value(R_HIGHEST_ROW) type INT4 - raising - ZCX_EXCEL . - methods GET_HYPERLINKS_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_HYPERLINKS_SIZE - returning - value(EP_SIZE) type I . - methods GET_MERGE - returning - value(MERGE_RANGE) type STRING_TABLE - raising - ZCX_EXCEL . - methods GET_PAGEBREAKS - returning - value(RO_PAGEBREAKS) type ref to ZCL_EXCEL_WORKSHEET_PAGEBREAKS - raising - ZCX_EXCEL . - methods GET_RANGES_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_ROW - importing - !IP_ROW type INT4 - returning - value(EO_ROW) type ref to ZCL_EXCEL_ROW . - methods GET_ROWS - returning - value(EO_ROWS) type ref to ZCL_EXCEL_ROWS . - methods GET_ROWS_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_ROW_OUTLINES - returning - value(RT_ROW_OUTLINES) type MTY_TS_OUTLINES_ROW . - methods GET_STYLE_COND - importing - !IP_GUID type ZEXCEL_CELL_STYLE - returning - value(EO_STYLE_COND) type ref to ZCL_EXCEL_STYLE_COND . - methods GET_TABCOLOR - returning - value(EV_TABCOLOR) type ZEXCEL_S_TABCOLOR . - methods GET_TABLES_ITERATOR - returning - value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . - methods GET_TABLES_SIZE - returning - value(EP_SIZE) type I . - methods GET_TITLE - importing - !IP_ESCAPED type FLAG default '' - returning - value(EP_TITLE) type ZEXCEL_SHEET_TITLE . - methods IS_CELL_MERGED - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - returning - value(RP_IS_MERGED) type ABAP_BOOL - raising - ZCX_EXCEL . - methods SET_CELL - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - !IP_VALUE type SIMPLE optional - !IP_FORMULA type ZEXCEL_CELL_FORMULA optional - !IP_STYLE type ZEXCEL_CELL_STYLE optional - !IP_HYPERLINK type ref to ZCL_EXCEL_HYPERLINK optional - !IP_DATA_TYPE type ZEXCEL_CELL_DATA_TYPE optional - !IP_ABAP_TYPE type ABAP_TYPEKIND optional - raising - ZCX_EXCEL . - methods SET_CELL_FORMULA - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - !IP_FORMULA type ZEXCEL_CELL_FORMULA - raising - ZCX_EXCEL . - methods SET_CELL_STYLE - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - !IP_STYLE type ZEXCEL_CELL_STYLE - raising - ZCX_EXCEL . - methods SET_COLUMN_WIDTH - importing - !IP_COLUMN type SIMPLE - !IP_WIDTH_FIX type SIMPLE default 0 - !IP_WIDTH_AUTOSIZE type FLAG default 'X' - raising - ZCX_EXCEL . - methods SET_DEFAULT_EXCEL_DATE_FORMAT - importing - !IP_DEFAULT_EXCEL_DATE_FORMAT type ZEXCEL_NUMBER_FORMAT - raising - ZCX_EXCEL . - methods SET_MERGE - importing - !IP_COLUMN_START type SIMPLE default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MIN_COL - !IP_COLUMN_END type SIMPLE default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MAX_COL - !IP_ROW type ZEXCEL_CELL_ROW default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MIN_ROW - !IP_ROW_TO type ZEXCEL_CELL_ROW default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MAX_ROW - raising - ZCX_EXCEL . - methods SET_PRINT_GRIDLINES - importing - !I_PRINT_GRIDLINES type ZEXCEL_PRINT_GRIDLINES . - methods SET_ROW_HEIGHT - importing - !IP_ROW type SIMPLE - !IP_HEIGHT_FIX type SIMPLE - raising - ZCX_EXCEL . - methods SET_ROW_OUTLINE - importing - !IV_ROW_FROM type I - !IV_ROW_TO type I - !IV_COLLAPSED type ABAP_BOOL - raising - ZCX_EXCEL . - methods SET_SHOW_GRIDLINES - importing - !I_SHOW_GRIDLINES type ZEXCEL_SHOW_GRIDLINES . - methods SET_SHOW_ROWCOLHEADERS - importing - !I_SHOW_ROWCOLHEADERS type ZEXCEL_SHOW_ROWCOLHEADER . - methods SET_TABCOLOR - importing - !IV_TABCOLOR type ZEXCEL_S_TABCOLOR . - methods SET_TABLE - importing - !IP_TABLE type STANDARD TABLE - !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional - !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional - !IP_TABLE_TITLE type STRING - !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' - !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 - !IP_TRANSPOSE type XFELD optional - !IP_NO_HEADER type XFELD optional - raising - ZCX_EXCEL . - methods SET_TITLE - importing - !IP_TITLE type ZEXCEL_SHEET_TITLE - raising - ZCX_EXCEL . - METHODS get_table - IMPORTING - iv_skipped_rows TYPE int4 DEFAULT 0 - iv_skipped_cols TYPE int4 DEFAULT 0 - EXPORTING - et_table TYPE STANDARD TABLE - RAISING - zcx_excel. + methods ADD_DRAWING + importing + !IP_DRAWING type ref to ZCL_EXCEL_DRAWING . + methods ADD_NEW_COLUMN + importing + !IP_COLUMN type SIMPLE + returning + value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . + methods ADD_NEW_STYLE_COND + returning + value(EO_STYLE_COND) type ref to ZCL_EXCEL_STYLE_COND . + methods ADD_NEW_DATA_VALIDATION + returning + value(EO_DATA_VALIDATION) type ref to ZCL_EXCEL_DATA_VALIDATION . + methods ADD_NEW_RANGE + returning + value(EO_RANGE) type ref to ZCL_EXCEL_RANGE . + methods ADD_NEW_ROW + importing + !IP_ROW type SIMPLE + returning + value(EO_ROW) type ref to ZCL_EXCEL_ROW . + methods BIND_ALV + importing + !IO_ALV type ref to OBJECT + !IT_TABLE type standard table + !I_TOP type I default 1 + !I_LEFT type I default 1 + !TABLE_STYLE type ZEXCEL_TABLE_STYLE optional + !I_TABLE type ABAP_BOOL default ABAP_TRUE + raising + ZCX_EXCEL . + type-pools SLIS . + type-pools SOI . + methods BIND_ALV_OLE2 + importing + !I_DOCUMENT_URL type CHAR255 default SPACE + !I_XLS type C default SPACE + !I_SAVE_PATH type STRING + !IO_ALV type ref to CL_GUI_ALV_GRID + !IT_LISTHEADER type SLIS_T_LISTHEADER optional + !I_TOP type I default 1 + !I_LEFT type I default 1 + !I_COLUMNS_HEADER type C default 'X' + !I_COLUMNS_AUTOFIT type C default 'X' + !I_FORMAT_COL_HEADER type SOI_FORMAT_ITEM optional + !I_FORMAT_SUBTOTAL type SOI_FORMAT_ITEM optional + !I_FORMAT_TOTAL type SOI_FORMAT_ITEM optional + exceptions + MISS_GUIDE + EX_TRANSFER_KKBLO_ERROR + FATAL_ERROR + INV_DATA_RANGE + DIM_MISMATCH_VKEY + DIM_MISMATCH_SEMA + ERROR_IN_SEMA . + methods BIND_TABLE + importing + !IP_TABLE type standard table + !IT_FIELD_CATALOG type ZEXCEL_T_FIELDCATALOG optional + !IS_TABLE_SETTINGS type ZEXCEL_S_TABLE_SETTINGS optional + value(IV_DEFAULT_DESCR) type C optional + exporting + !ES_TABLE_SETTINGS type ZEXCEL_S_TABLE_SETTINGS + raising + ZCX_EXCEL . + methods CALCULATE_COLUMN_WIDTHS + raising + ZCX_EXCEL . + methods CHANGE_CELL_STYLE + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + !IP_COMPLETE type ZEXCEL_S_CSTYLE_COMPLETE optional + !IP_XCOMPLETE type ZEXCEL_S_CSTYLEX_COMPLETE optional + !IP_FONT type ZEXCEL_S_CSTYLE_FONT optional + !IP_XFONT type ZEXCEL_S_CSTYLEX_FONT optional + !IP_FILL type ZEXCEL_S_CSTYLE_FILL optional + !IP_XFILL type ZEXCEL_S_CSTYLEX_FILL optional + !IP_BORDERS type ZEXCEL_S_CSTYLE_BORDERS optional + !IP_XBORDERS type ZEXCEL_S_CSTYLEX_BORDERS optional + !IP_ALIGNMENT type ZEXCEL_S_CSTYLE_ALIGNMENT optional + !IP_XALIGNMENT type ZEXCEL_S_CSTYLEX_ALIGNMENT optional + !IP_NUMBER_FORMAT_FORMAT_CODE type ZEXCEL_NUMBER_FORMAT optional + !IP_PROTECTION type ZEXCEL_S_CSTYLE_PROTECTION optional + !IP_XPROTECTION type ZEXCEL_S_CSTYLEX_PROTECTION optional + !IP_FONT_BOLD type FLAG optional + !IP_FONT_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_FONT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_FONT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_FONT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_FONT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_FONT_FAMILY type ZEXCEL_STYLE_FONT_FAMILY optional + !IP_FONT_ITALIC type FLAG optional + !IP_FONT_NAME type ZEXCEL_STYLE_FONT_NAME optional + !IP_FONT_SCHEME type ZEXCEL_STYLE_FONT_SCHEME optional + !IP_FONT_SIZE type ZEXCEL_STYLE_FONT_SIZE optional + !IP_FONT_STRIKETHROUGH type FLAG optional + !IP_FONT_UNDERLINE type FLAG optional + !IP_FONT_UNDERLINE_MODE type ZEXCEL_STYLE_FONT_UNDERLINE optional + !IP_FILL_FILLTYPE type ZEXCEL_FILL_TYPE optional + !IP_FILL_ROTATION type ZEXCEL_ROTATION optional + !IP_FILL_FGCOLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_FILL_FGCOLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_FILL_FGCOLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_FILL_FGCOLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_FILL_FGCOLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_FILL_BGCOLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_FILL_BGCOLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_FILL_BGCOLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_FILL_BGCOLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_FILL_BGCOLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_BORDERS_ALLBORDERS type ZEXCEL_S_CSTYLE_BORDER optional + !IP_FILL_GRADTYPE_TYPE type ZEXCEL_S_GRADIENT_TYPE-TYPE optional + !IP_FILL_GRADTYPE_DEGREE type ZEXCEL_S_GRADIENT_TYPE-DEGREE optional + !IP_XBORDERS_ALLBORDERS type ZEXCEL_S_CSTYLEX_BORDER optional + !IP_BORDERS_DIAGONAL type ZEXCEL_S_CSTYLE_BORDER optional + !IP_FILL_GRADTYPE_BOTTOM type ZEXCEL_S_GRADIENT_TYPE-BOTTOM optional + !IP_FILL_GRADTYPE_TOP type ZEXCEL_S_GRADIENT_TYPE-TOP optional + !IP_XBORDERS_DIAGONAL type ZEXCEL_S_CSTYLEX_BORDER optional + !IP_BORDERS_DIAGONAL_MODE type ZEXCEL_DIAGONAL optional + !IP_FILL_GRADTYPE_RIGHT type ZEXCEL_S_GRADIENT_TYPE-RIGHT optional + !IP_BORDERS_DOWN type ZEXCEL_S_CSTYLE_BORDER optional + !IP_FILL_GRADTYPE_LEFT type ZEXCEL_S_GRADIENT_TYPE-LEFT optional + !IP_FILL_GRADTYPE_POSITION1 type ZEXCEL_S_GRADIENT_TYPE-POSITION1 optional + !IP_XBORDERS_DOWN type ZEXCEL_S_CSTYLEX_BORDER optional + !IP_BORDERS_LEFT type ZEXCEL_S_CSTYLE_BORDER optional + !IP_FILL_GRADTYPE_POSITION2 type ZEXCEL_S_GRADIENT_TYPE-POSITION2 optional + !IP_FILL_GRADTYPE_POSITION3 type ZEXCEL_S_GRADIENT_TYPE-POSITION3 optional + !IP_XBORDERS_LEFT type ZEXCEL_S_CSTYLEX_BORDER optional + !IP_BORDERS_RIGHT type ZEXCEL_S_CSTYLE_BORDER optional + !IP_XBORDERS_RIGHT type ZEXCEL_S_CSTYLEX_BORDER optional + !IP_BORDERS_TOP type ZEXCEL_S_CSTYLE_BORDER optional + !IP_XBORDERS_TOP type ZEXCEL_S_CSTYLEX_BORDER optional + !IP_ALIGNMENT_HORIZONTAL type ZEXCEL_ALIGNMENT optional + !IP_ALIGNMENT_VERTICAL type ZEXCEL_ALIGNMENT optional + !IP_ALIGNMENT_TEXTROTATION type ZEXCEL_TEXT_ROTATION optional + !IP_ALIGNMENT_WRAPTEXT type FLAG optional + !IP_ALIGNMENT_SHRINKTOFIT type FLAG optional + !IP_ALIGNMENT_INDENT type ZEXCEL_INDENT optional + !IP_PROTECTION_HIDDEN type ZEXCEL_CELL_PROTECTION optional + !IP_PROTECTION_LOCKED type ZEXCEL_CELL_PROTECTION optional + !IP_BORDERS_ALLBORDERS_STYLE type ZEXCEL_BORDER optional + !IP_BORDERS_ALLBORDERS_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_BORDERS_ALLBO_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_BORDERS_ALLBO_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_BORDERS_ALLBO_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_BORDERS_ALLBO_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_BORDERS_DIAGONAL_STYLE type ZEXCEL_BORDER optional + !IP_BORDERS_DIAGONAL_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_BORDERS_DIAGONAL_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_BORDERS_DIAGONAL_COLOR_INDE type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_BORDERS_DIAGONAL_COLOR_THEM type ZEXCEL_STYLE_COLOR_THEME optional + !IP_BORDERS_DIAGONAL_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_BORDERS_DOWN_STYLE type ZEXCEL_BORDER optional + !IP_BORDERS_DOWN_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_BORDERS_DOWN_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_BORDERS_DOWN_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_BORDERS_DOWN_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_BORDERS_DOWN_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_BORDERS_LEFT_STYLE type ZEXCEL_BORDER optional + !IP_BORDERS_LEFT_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_BORDERS_LEFT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_BORDERS_LEFT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_BORDERS_LEFT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_BORDERS_LEFT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_BORDERS_RIGHT_STYLE type ZEXCEL_BORDER optional + !IP_BORDERS_RIGHT_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_BORDERS_RIGHT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_BORDERS_RIGHT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_BORDERS_RIGHT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_BORDERS_RIGHT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + !IP_BORDERS_TOP_STYLE type ZEXCEL_BORDER optional + !IP_BORDERS_TOP_COLOR type ZEXCEL_S_STYLE_COLOR optional + !IP_BORDERS_TOP_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional + !IP_BORDERS_TOP_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional + !IP_BORDERS_TOP_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional + !IP_BORDERS_TOP_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional + returning + value(EP_GUID) type ZEXCEL_CELL_STYLE + raising + ZCX_EXCEL . + methods CONSTRUCTOR + importing + !IP_EXCEL type ref to ZCL_EXCEL + !IP_TITLE type ZEXCEL_SHEET_TITLE optional + raising + ZCX_EXCEL . + methods DELETE_MERGE + importing + !IP_CELL_COLUMN type SIMPLE optional + !IP_CELL_ROW type ZEXCEL_CELL_ROW optional . + methods DELETE_ROW_OUTLINE + importing + !IV_ROW_FROM type I + !IV_ROW_TO type I + raising + ZCX_EXCEL . + methods FREEZE_PANES + importing + !IP_NUM_COLUMNS type I optional + !IP_NUM_ROWS type I optional + raising + ZCX_EXCEL . + methods GET_ACTIVE_CELL + returning + value(EP_ACTIVE_CELL) type STRING + raising + ZCX_EXCEL . + methods GET_CELL + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + exporting + !EP_VALUE type ZEXCEL_CELL_VALUE + !EP_RC type SYSUBRC + !EP_STYLE type ref to ZCL_EXCEL_STYLE + !EP_GUID type ZEXCEL_CELL_STYLE + !EP_FORMULA type ZEXCEL_CELL_FORMULA + raising + ZCX_EXCEL . + methods GET_COLUMN + importing + !IP_COLUMN type SIMPLE + returning + value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . + methods GET_COLUMNS + returning + value(EO_COLUMNS) type ref to ZCL_EXCEL_COLUMNS . + methods GET_COLUMNS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_STYLE_COND_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_DATA_VALIDATIONS_SIZE + returning + value(EP_SIZE) type I . + methods GET_DEFAULT_COLUMN + returning + value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN . + methods GET_DEFAULT_EXCEL_DATE_FORMAT + returning + value(EP_DEFAULT_EXCEL_DATE_FORMAT) type ZEXCEL_NUMBER_FORMAT . + methods GET_DEFAULT_EXCEL_TIME_FORMAT + returning + value(EP_DEFAULT_EXCEL_TIME_FORMAT) type ZEXCEL_NUMBER_FORMAT . + methods GET_DEFAULT_ROW + returning + value(EO_ROW) type ref to ZCL_EXCEL_ROW . + methods GET_DIMENSION_RANGE + returning + value(EP_DIMENSION_RANGE) type STRING + raising + ZCX_EXCEL . + methods GET_DRAWINGS + importing + !IP_TYPE type ZEXCEL_DRAWING_TYPE optional + returning + value(R_DRAWINGS) type ref to ZCL_EXCEL_DRAWINGS . + methods GET_DRAWINGS_ITERATOR + importing + !IP_TYPE type ZEXCEL_DRAWING_TYPE + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_FREEZE_CELL + exporting + !EP_ROW type ZEXCEL_CELL_ROW + !EP_COLUMN type ZEXCEL_CELL_COLUMN . + methods GET_GUID + returning + value(EP_GUID) type UUID . + methods GET_HIGHEST_COLUMN + returning + value(R_HIGHEST_COLUMN) type ZEXCEL_CELL_COLUMN + raising + ZCX_EXCEL . + methods GET_HIGHEST_ROW + returning + value(R_HIGHEST_ROW) type INT4 + raising + ZCX_EXCEL . + methods GET_HYPERLINKS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_HYPERLINKS_SIZE + returning + value(EP_SIZE) type I . + methods GET_MERGE + returning + value(MERGE_RANGE) type STRING_TABLE + raising + ZCX_EXCEL . + methods GET_PAGEBREAKS + returning + value(RO_PAGEBREAKS) type ref to ZCL_EXCEL_WORKSHEET_PAGEBREAKS + raising + ZCX_EXCEL . + methods GET_RANGES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_ROW + importing + !IP_ROW type INT4 + returning + value(EO_ROW) type ref to ZCL_EXCEL_ROW . + methods GET_ROWS + returning + value(EO_ROWS) type ref to ZCL_EXCEL_ROWS . + methods GET_ROWS_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_ROW_OUTLINES + returning + value(RT_ROW_OUTLINES) type MTY_TS_OUTLINES_ROW . + methods GET_STYLE_COND + importing + !IP_GUID type ZEXCEL_CELL_STYLE + returning + value(EO_STYLE_COND) type ref to ZCL_EXCEL_STYLE_COND . + methods GET_TABCOLOR + returning + value(EV_TABCOLOR) type ZEXCEL_S_TABCOLOR . + methods GET_TABLES_ITERATOR + returning + value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . + methods GET_TABLES_SIZE + returning + value(EP_SIZE) type I . + methods GET_TITLE + importing + !IP_ESCAPED type FLAG default '' + returning + value(EP_TITLE) type ZEXCEL_SHEET_TITLE . + methods IS_CELL_MERGED + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + returning + value(RP_IS_MERGED) type ABAP_BOOL + raising + ZCX_EXCEL . + methods SET_CELL + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + !IP_VALUE type SIMPLE optional + !IP_FORMULA type ZEXCEL_CELL_FORMULA optional + !IP_STYLE type ZEXCEL_CELL_STYLE optional + !IP_HYPERLINK type ref to ZCL_EXCEL_HYPERLINK optional + !IP_DATA_TYPE type ZEXCEL_CELL_DATA_TYPE optional + !IP_ABAP_TYPE type ABAP_TYPEKIND optional + raising + ZCX_EXCEL . + methods SET_CELL_FORMULA + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + !IP_FORMULA type ZEXCEL_CELL_FORMULA + raising + ZCX_EXCEL . + methods SET_CELL_STYLE + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + !IP_STYLE type ZEXCEL_CELL_STYLE + raising + ZCX_EXCEL . + methods SET_COLUMN_WIDTH + importing + !IP_COLUMN type SIMPLE + !IP_WIDTH_FIX type SIMPLE default 0 + !IP_WIDTH_AUTOSIZE type FLAG default 'X' + raising + ZCX_EXCEL . + methods SET_DEFAULT_EXCEL_DATE_FORMAT + importing + !IP_DEFAULT_EXCEL_DATE_FORMAT type ZEXCEL_NUMBER_FORMAT + raising + ZCX_EXCEL . + methods SET_MERGE + importing + !IP_COLUMN_START type SIMPLE default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MIN_COL + !IP_COLUMN_END type SIMPLE default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MAX_COL + !IP_ROW type ZEXCEL_CELL_ROW default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MIN_ROW + !IP_ROW_TO type ZEXCEL_CELL_ROW default ZCL_EXCEL_COMMON=>C_EXCEL_SHEET_MAX_ROW + raising + ZCX_EXCEL . + methods SET_PRINT_GRIDLINES + importing + !I_PRINT_GRIDLINES type ZEXCEL_PRINT_GRIDLINES . + methods SET_ROW_HEIGHT + importing + !IP_ROW type SIMPLE + !IP_HEIGHT_FIX type SIMPLE + raising + ZCX_EXCEL . + methods SET_ROW_OUTLINE + importing + !IV_ROW_FROM type I + !IV_ROW_TO type I + !IV_COLLAPSED type ABAP_BOOL + raising + ZCX_EXCEL . + methods SET_SHOW_GRIDLINES + importing + !I_SHOW_GRIDLINES type ZEXCEL_SHOW_GRIDLINES . + methods SET_SHOW_ROWCOLHEADERS + importing + !I_SHOW_ROWCOLHEADERS type ZEXCEL_SHOW_ROWCOLHEADER . + methods SET_TABCOLOR + importing + !IV_TABCOLOR type ZEXCEL_S_TABCOLOR . + methods SET_TABLE + importing + !IP_TABLE type standard table + !IP_HDR_STYLE type ZEXCEL_CELL_STYLE optional + !IP_BODY_STYLE type ZEXCEL_CELL_STYLE optional + !IP_TABLE_TITLE type STRING + !IP_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA default 'B' + !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 + !IP_TRANSPOSE type XFELD optional + !IP_NO_HEADER type XFELD optional + raising + ZCX_EXCEL . + methods SET_TITLE + importing + !IP_TITLE type ZEXCEL_SHEET_TITLE + raising + ZCX_EXCEL . + methods GET_TABLE + importing + IV_SKIPPED_ROWS type INT4 default 0 + IV_SKIPPED_COLS type INT4 default 0 + exporting + ET_TABLE type standard table + raising + ZCX_EXCEL. *"* protected components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! *"* protected components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! -protected section. -private section. + protected section. + private section. - types: - BEGIN OF mty_s_font_metric, - char TYPE c LENGTH 1, - char_width TYPE tdcwidths, - END OF mty_s_font_metric . - types: - mty_th_font_metrics - TYPE HASHED TABLE OF mty_s_font_metric - WITH UNIQUE KEY char . - types: - BEGIN OF mty_s_font_cache, - font_name TYPE zexcel_style_font_name, - font_height TYPE tdfontsize, - flag_bold TYPE abap_bool, - flag_italic TYPE abap_bool, - th_font_metrics TYPE mty_th_font_metrics, - END OF mty_s_font_cache . - types: - mty_th_font_cache - TYPE HASHED TABLE OF mty_s_font_cache - WITH UNIQUE KEY font_name font_height flag_bold flag_italic . - types: + types: + begin of MTY_S_FONT_METRIC, + CHAR type C length 1, + CHAR_WIDTH type TDCWIDTHS, + end of MTY_S_FONT_METRIC . + types: + MTY_TH_FONT_METRICS + type hashed table of MTY_S_FONT_METRIC + with unique key CHAR . + types: + begin of MTY_S_FONT_CACHE, + FONT_NAME type ZEXCEL_STYLE_FONT_NAME, + FONT_HEIGHT type TDFONTSIZE, + FLAG_BOLD type ABAP_BOOL, + FLAG_ITALIC type ABAP_BOOL, + TH_FONT_METRICS type MTY_TH_FONT_METRICS, + end of MTY_S_FONT_CACHE . + types: + MTY_TH_FONT_CACHE + type hashed table of MTY_S_FONT_CACHE + with unique key FONT_NAME FONT_HEIGHT FLAG_BOLD FLAG_ITALIC . + types: * types: * mty_ts_row_dimension TYPE SORTED TABLE OF zexcel_s_worksheet_rowdimensio WITH UNIQUE KEY row . - BEGIN OF mty_merge, - row_from TYPE i, - row_to TYPE i, - col_from TYPE i, - col_to TYPE i, - END OF mty_merge . - types: - mty_ts_merge TYPE SORTED TABLE OF mty_merge WITH UNIQUE KEY table_line . + begin of MTY_MERGE, + ROW_FROM type I, + ROW_TO type I, + COL_FROM type I, + COL_TO type I, + end of MTY_MERGE . + types: + MTY_TS_MERGE type sorted table of MTY_MERGE with unique key TABLE_LINE . *"* private components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! - data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . - data CHARTS type ref to ZCL_EXCEL_DRAWINGS . - data COLUMNS type ref to ZCL_EXCEL_COLUMNS . - data ROW_DEFAULT type ref to ZCL_EXCEL_ROW . - data COLUMN_DEFAULT type ref to ZCL_EXCEL_COLUMN . - data STYLES_COND type ref to ZCL_EXCEL_STYLES_COND . - data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . - data DEFAULT_EXCEL_DATE_FORMAT type ZEXCEL_NUMBER_FORMAT . - data DEFAULT_EXCEL_TIME_FORMAT type ZEXCEL_NUMBER_FORMAT . - data DRAWINGS type ref to ZCL_EXCEL_DRAWINGS . - data FREEZE_PANE_CELL_COLUMN type ZEXCEL_CELL_COLUMN . - data FREEZE_PANE_CELL_ROW type ZEXCEL_CELL_ROW . - data GUID type UUID . - data HYPERLINKS type ref to CL_OBJECT_COLLECTION . - data LOWER_CELL type ZEXCEL_S_CELL_DATA . - data MO_PAGEBREAKS type ref to ZCL_EXCEL_WORKSHEET_PAGEBREAKS . - class-data MTH_FONT_CACHE type MTY_TH_FONT_CACHE . - data MT_MERGED_CELLS type MTY_TS_MERGE . - data MT_ROW_OUTLINES type MTY_TS_OUTLINES_ROW . - data PRINT_TITLE_COL_FROM type ZEXCEL_CELL_COLUMN_ALPHA . - data PRINT_TITLE_COL_TO type ZEXCEL_CELL_COLUMN_ALPHA . - data PRINT_TITLE_ROW_FROM type ZEXCEL_CELL_ROW . - data PRINT_TITLE_ROW_TO type ZEXCEL_CELL_ROW . - data RANGES type ref to ZCL_EXCEL_RANGES . - data ROWS type ref to ZCL_EXCEL_ROWS . - data TABLES type ref to CL_OBJECT_COLLECTION . - data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . " . - data UPPER_CELL type ZEXCEL_S_CELL_DATA . + data ACTIVE_CELL type ZEXCEL_S_CELL_DATA . + data CHARTS type ref to ZCL_EXCEL_DRAWINGS . + data COLUMNS type ref to ZCL_EXCEL_COLUMNS . + data ROW_DEFAULT type ref to ZCL_EXCEL_ROW . + data COLUMN_DEFAULT type ref to ZCL_EXCEL_COLUMN . + data STYLES_COND type ref to ZCL_EXCEL_STYLES_COND . + data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . + data DEFAULT_EXCEL_DATE_FORMAT type ZEXCEL_NUMBER_FORMAT . + data DEFAULT_EXCEL_TIME_FORMAT type ZEXCEL_NUMBER_FORMAT . + data DRAWINGS type ref to ZCL_EXCEL_DRAWINGS . + data FREEZE_PANE_CELL_COLUMN type ZEXCEL_CELL_COLUMN . + data FREEZE_PANE_CELL_ROW type ZEXCEL_CELL_ROW . + data GUID type UUID . + data HYPERLINKS type ref to CL_OBJECT_COLLECTION . + data LOWER_CELL type ZEXCEL_S_CELL_DATA . + data MO_PAGEBREAKS type ref to ZCL_EXCEL_WORKSHEET_PAGEBREAKS . + class-data MTH_FONT_CACHE type MTY_TH_FONT_CACHE . + data MT_MERGED_CELLS type MTY_TS_MERGE . + data MT_ROW_OUTLINES type MTY_TS_OUTLINES_ROW . + data PRINT_TITLE_COL_FROM type ZEXCEL_CELL_COLUMN_ALPHA . + data PRINT_TITLE_COL_TO type ZEXCEL_CELL_COLUMN_ALPHA . + data PRINT_TITLE_ROW_FROM type ZEXCEL_CELL_ROW . + data PRINT_TITLE_ROW_TO type ZEXCEL_CELL_ROW . + data RANGES type ref to ZCL_EXCEL_RANGES . + data ROWS type ref to ZCL_EXCEL_ROWS . + data TABLES type ref to CL_OBJECT_COLLECTION . + data TITLE type ZEXCEL_SHEET_TITLE value 'Worksheet'. "#EC NOTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . " . + data UPPER_CELL type ZEXCEL_S_CELL_DATA . - methods CALCULATE_CELL_WIDTH - importing - !IP_COLUMN type SIMPLE - !IP_ROW type ZEXCEL_CELL_ROW - returning - value(EP_WIDTH) type FLOAT - raising - ZCX_EXCEL . - methods GENERATE_TITLE - returning - value(EP_TITLE) type ZEXCEL_SHEET_TITLE . - methods GET_VALUE_TYPE - importing - !IP_VALUE type SIMPLE - exporting - !EP_VALUE type SIMPLE - !EP_VALUE_TYPE type ABAP_TYPEKIND . - methods PRINT_TITLE_SET_RANGE . - methods UPDATE_DIMENSION_RANGE - raising - ZCX_EXCEL . + methods CALCULATE_CELL_WIDTH + importing + !IP_COLUMN type SIMPLE + !IP_ROW type ZEXCEL_CELL_ROW + returning + value(EP_WIDTH) type FLOAT + raising + ZCX_EXCEL . + methods GENERATE_TITLE + returning + value(EP_TITLE) type ZEXCEL_SHEET_TITLE . + methods GET_VALUE_TYPE + importing + !IP_VALUE type SIMPLE + exporting + !EP_VALUE type SIMPLE + !EP_VALUE_TYPE type ABAP_TYPEKIND . + methods PRINT_TITLE_SET_RANGE . + methods UPDATE_DIMENSION_RANGE + raising + ZCX_EXCEL . ENDCLASS. @@ -574,82 +574,82 @@ ENDCLASS. CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. -method ADD_DRAWING. - CASE ip_drawing->get_type( ). - WHEN zcl_excel_drawing=>type_image. - drawings->include( ip_drawing ). - WHEN zcl_excel_drawing=>type_chart. - charts->include( ip_drawing ). - ENDCASE. + method ADD_DRAWING. + case IP_DRAWING->GET_TYPE( ). + when ZCL_EXCEL_DRAWING=>TYPE_IMAGE. + DRAWINGS->INCLUDE( IP_DRAWING ). + when ZCL_EXCEL_DRAWING=>TYPE_CHART. + CHARTS->INCLUDE( IP_DRAWING ). + endcase. endmethod. -METHOD add_new_column. - DATA: lv_column_alpha TYPE zexcel_cell_column_alpha. + method ADD_NEW_COLUMN. + data: LV_COLUMN_ALPHA type ZEXCEL_CELL_COLUMN_ALPHA. - lv_column_alpha = zcl_excel_common=>convert_column2alpha( ip_column ). + LV_COLUMN_ALPHA = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( IP_COLUMN ). - CREATE OBJECT eo_column - EXPORTING - ip_index = lv_column_alpha - ip_excel = me->excel - ip_worksheet = me. - columns->add( eo_column ). -ENDMETHOD. - - -method ADD_NEW_DATA_VALIDATION. - - CREATE OBJECT eo_data_validation. - data_validations->add( eo_data_validation ). + create object EO_COLUMN + exporting + IP_INDEX = LV_COLUMN_ALPHA + IP_EXCEL = ME->EXCEL + IP_WORKSHEET = ME. + COLUMNS->ADD( EO_COLUMN ). endmethod. -METHOD add_new_range. + method ADD_NEW_DATA_VALIDATION. + + create object EO_DATA_VALIDATION. + DATA_VALIDATIONS->ADD( EO_DATA_VALIDATION ). + endmethod. + + + method ADD_NEW_RANGE. * Create default blank range - CREATE OBJECT eo_range. - ranges->add( eo_range ). -ENDMETHOD. + create object EO_RANGE. + RANGES->ADD( EO_RANGE ). + endmethod. -METHOD add_new_row. - CREATE OBJECT eo_row - EXPORTING - ip_index = ip_row. - rows->add( eo_row ). -ENDMETHOD. + method ADD_NEW_ROW. + create object EO_ROW + exporting + IP_INDEX = IP_ROW. + ROWS->ADD( EO_ROW ). + endmethod. -METHOD add_new_style_cond. - CREATE OBJECT eo_style_cond. - styles_cond->add( eo_style_cond ). -ENDMETHOD. + method ADD_NEW_STYLE_COND. + create object EO_STYLE_COND. + STYLES_COND->ADD( EO_STYLE_COND ). + endmethod. -method BIND_ALV. - data: lo_converter type ref to zcl_excel_converter. + method BIND_ALV. + data: LO_CONVERTER type ref to ZCL_EXCEL_CONVERTER. - create object lo_converter. + create object LO_CONVERTER. - try. - lo_converter->convert( - exporting - io_alv = io_alv - it_table = it_table - i_row_int = i_top - i_column_int = i_left - i_table = i_table - i_style_table = table_style - io_worksheet = me - changing - co_excel = excel ). - catch zcx_excel . - endtry. + try. + LO_CONVERTER->CONVERT( + exporting + IO_ALV = IO_ALV + IT_TABLE = IT_TABLE + I_ROW_INT = I_TOP + I_COLUMN_INT = I_LEFT + I_TABLE = I_TABLE + I_STYLE_TABLE = TABLE_STYLE + IO_WORKSHEET = ME + changing + CO_EXCEL = EXCEL ). + catch ZCX_EXCEL . + endtry. endmethod. -method BIND_ALV_OLE2. + method BIND_ALV_OLE2. *--------------------------------------------------------------------* * Method description: * Method use to export a CL_GUI_ALV_GRID object to xlsx/xls file @@ -664,69 +664,69 @@ method BIND_ALV_OLE2. * Data for session 0: DOI constructor * ------------------------------------------ - data: lo_control type ref to I_OI_CONTAINER_CONTROL. - data: lo_proxy type ref to I_OI_DOCUMENT_PROXY. - data: lo_spreadsheet type ref to I_OI_SPREADSHEET. - data: lo_error type ref to I_OI_ERROR. - data: lc_retcode type SOI_RET_STRING. - data: li_has type i. "Proxy has spreadsheet interface? - data: l_is_closed type i. + data: LO_CONTROL type ref to I_OI_CONTAINER_CONTROL. + data: LO_PROXY type ref to I_OI_DOCUMENT_PROXY. + data: LO_SPREADSHEET type ref to I_OI_SPREADSHEET. + data: LO_ERROR type ref to I_OI_ERROR. + data: LC_RETCODE type SOI_RET_STRING. + data: LI_HAS type I. "Proxy has spreadsheet interface? + data: L_IS_CLOSED type I. * Data for session 1: Get LVC data from ALV object * ------------------------------------------ - data: l_has_activex, - l_doctype_excel_sheet(11) type c. + data: L_HAS_ACTIVEX, + L_DOCTYPE_EXCEL_SHEET(11) type C. * LVC - data: lt_fieldcat_lvc type LVC_T_FCAT. - data: wa_fieldcat_lvc type lvc_s_fcat. - data: lt_sort_lvc type LVC_T_SORT. - data: lt_filter_idx_lvc type LVC_T_FIDX. - data: lt_GROUPLEVELS_LVC type LVC_T_GRPL. + data: LT_FIELDCAT_LVC type LVC_T_FCAT. + data: WA_FIELDCAT_LVC type LVC_S_FCAT. + data: LT_SORT_LVC type LVC_T_SORT. + data: LT_FILTER_IDX_LVC type LVC_T_FIDX. + data: LT_GROUPLEVELS_LVC type LVC_T_GRPL. * KKBLO - DATA: LT_FIELDCAT_KKBLO Type KKBLO_T_FIELDCAT. - DATA: LT_SORT_KKBLO Type KKBLO_T_SORTINFO. - DATA: LT_GROUPLEVELS_KKBLO Type KKBLO_T_GROUPLEVELS. - DATA: LT_FILTER_IDX_KKBLO Type KKBLO_T_SFINFO. - data: wa_listheader like line of it_listheader. + data: LT_FIELDCAT_KKBLO type KKBLO_T_FIELDCAT. + data: LT_SORT_KKBLO type KKBLO_T_SORTINFO. + data: LT_GROUPLEVELS_KKBLO type KKBLO_T_GROUPLEVELS. + data: LT_FILTER_IDX_KKBLO type KKBLO_T_SFINFO. + data: WA_LISTHEADER like line of IT_LISTHEADER. * Subtotal - data: lt_collect00 type ref to data. - data: lt_collect01 type ref to data. - data: lt_collect02 type ref to data. - data: lt_collect03 type ref to data. - data: lt_collect04 type ref to data. - data: lt_collect05 type ref to data. - data: lt_collect06 type ref to data. - data: lt_collect07 type ref to data. - data: lt_collect08 type ref to data. - data: lt_collect09 type ref to data. + data: LT_COLLECT00 type ref to DATA. + data: LT_COLLECT01 type ref to DATA. + data: LT_COLLECT02 type ref to DATA. + data: LT_COLLECT03 type ref to DATA. + data: LT_COLLECT04 type ref to DATA. + data: LT_COLLECT05 type ref to DATA. + data: LT_COLLECT06 type ref to DATA. + data: LT_COLLECT07 type ref to DATA. + data: LT_COLLECT08 type ref to DATA. + data: LT_COLLECT09 type ref to DATA. * data table name - data: l_tabname type kkblo_tabname. + data: L_TABNAME type KKBLO_TABNAME. * local object - data: lo_grid type ref to lcl_gui_alv_grid. + data: LO_GRID type ref to LCL_GUI_ALV_GRID. * data table get from ALV - data: lt_alv type ref to data. + data: LT_ALV type ref to DATA. * total / subtotal data - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. - field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. + field-symbols: type standard table. * table before append subtotal lines - field-symbols: type standard table. + field-symbols: type standard table. * data for session 2: sort, filter and calculate total/subtotal * ------------------------------------------ @@ -734,193 +734,193 @@ method BIND_ALV_OLE2. * table to save index of subotal / total line in excel tanle * this ideal to control index of subtotal / total line later * for ex, when get subtotal / total line to format - types: begin of st_subtot_indexs, - index type i, - end of st_subtot_indexs. - data: lt_subtot_indexs type table of st_subtot_indexs. - data: wa_subtot_indexs like line of lt_subtot_indexs. + types: begin of ST_SUBTOT_INDEXS, + INDEX type I, + end of ST_SUBTOT_INDEXS. + data: LT_SUBTOT_INDEXS type table of ST_SUBTOT_INDEXS. + data: WA_SUBTOT_INDEXS like line of LT_SUBTOT_INDEXS. * data table after append subtotal - data: lt_excel type ref to data. + data: LT_EXCEL type ref to DATA. - data: l_tabix type i. - data: l_save_index type i. + data: L_TABIX type I. + data: L_SAVE_INDEX type I. * dyn subtotal table name - data: l_collect type string. + data: L_COLLECT type STRING. * subtotal range, to format subtotal (and total) - data: subranges type soi_range_list. - data: subrangeitem type soi_range_item. - data: l_sub_index type i. + data: SUBRANGES type SOI_RANGE_LIST. + data: SUBRANGEITEM type SOI_RANGE_ITEM. + data: L_SUB_INDEX type I. * table after append subtotal lines - field-symbols: type standard table. - field-symbols: type any. + field-symbols: type standard table. + field-symbols: type ANY. * dyn subtotal tables - field-symbols: type standard table. - field-symbols: type any. + field-symbols: type standard table. + field-symbols: type ANY. - field-symbols: like line of LT_FILTER_IDX_KKBLO. - field-symbols: like line of LT_FIELDCAT_KKBLO. - field-symbols: like line of LT_GROUPLEVELS_KKBLO. - field-symbols: type any. + field-symbols: like line of LT_FILTER_IDX_KKBLO. + field-symbols: like line of LT_FIELDCAT_KKBLO. + field-symbols: like line of LT_GROUPLEVELS_KKBLO. + field-symbols: type ANY. * Data for session 3: map data to semantic table * ------------------------------------------ - types: begin of st_column_index, - fieldname type kkblo_fieldname, - tabname type kkblo_tabname, - col like sy-index, - end of st_column_index. + types: begin of ST_COLUMN_INDEX, + FIELDNAME type KKBLO_FIELDNAME, + TABNAME type KKBLO_TABNAME, + COL like SY-INDEX, + end of ST_COLUMN_INDEX. * columns index - data: lt_column_index type table of st_column_index. - data: wa_column_index like line of lt_column_index. + data: LT_COLUMN_INDEX type table of ST_COLUMN_INDEX. + data: WA_COLUMN_INDEX like line of LT_COLUMN_INDEX. * table of dependent field ( currency and quantity unit field) - data: lt_fieldcat_depf type kkblo_t_fieldcat. - data: wa_fieldcat_depf type kkblo_fieldcat. + data: LT_FIELDCAT_DEPF type KKBLO_T_FIELDCAT. + data: WA_FIELDCAT_DEPF type KKBLO_FIELDCAT. * XXL interface: * -XXL: contain exporting columns characteristic - data: lt_sema type table of gxxlt_s initial size 0. - data: wa_sema like line of lt_sema. + data: LT_SEMA type table of GXXLT_S initial size 0. + data: WA_SEMA like line of LT_SEMA. * -XXL interface: header - data: lt_hkey type table of gxxlt_h initial size 0. - data: wa_hkey like line of lt_hkey. + data: LT_HKEY type table of GXXLT_H initial size 0. + data: WA_HKEY like line of LT_HKEY. * -XXL interface: header keys - data: lt_vkey type table of gxxlt_v initial size 0. - data: wa_vkey like line of lt_vkey. + data: LT_VKEY type table of GXXLT_V initial size 0. + data: WA_VKEY like line of LT_VKEY. * Number of H Keys: number of key columns - data: l_n_hrz_keys type i. + data: L_N_HRZ_KEYS type I. * Number of data columns in the list object: non-key columns no - data: l_n_att_cols type i. + data: L_N_ATT_COLS type I. * Number of V Keys: number of header row - data: l_n_vrt_keys type i. + data: L_N_VRT_KEYS type I. * curency to format amount - data: lt_tcurx type table of tcurx. - data: wa_tcurx like line of lt_tcurx. - data: l_def type flag. " currency / quantity flag - data: wa_t006 type t006. " decimal place of unit + data: LT_TCURX type table of TCURX. + data: WA_TCURX like line of LT_TCURX. + data: L_DEF type FLAG. " currency / quantity flag + data: WA_T006 type T006. " decimal place of unit - data: l_num type i. " table columns number - data: l_typ type c. " table type - data: wa type ref to data. - data: l_int type i. - data: l_counter type i. + data: L_NUM type I. " table columns number + data: L_TYP type C. " table type + data: WA type ref to DATA. + data: L_INT type I. + data: L_COUNTER type I. - field-symbols: type any. - field-symbols: type any. + field-symbols: type ANY. + field-symbols: type ANY. * Data for session 4: write to excel * ------------------------------------------ - data: sema_type type c. + data: SEMA_TYPE type C. - data l_error type ref to c_oi_proxy_error. - data count type i. - data datac type i. - data datareal type i. " exporting column number - data vkeycount type i. - data all type i. - data mit type i value 1. " index of recent row? - data li_col_pos type i value 1. " column position - data li_col_num type i. " table columns number - field-symbols: type any. - field-symbols: type any. + data L_ERROR type ref to C_OI_PROXY_ERROR. + data COUNT type I. + data DATAC type I. + data DATAREAL type I. " exporting column number + data VKEYCOUNT type I. + data ALL type I. + data MIT type I value 1. " index of recent row? + data LI_COL_POS type I value 1. " column position + data LI_COL_NUM type I. " table columns number + field-symbols: type ANY. + field-symbols: type ANY. - data td type sydes_desc. + data TD type SYDES_DESC. - data: typ. - data: ranges type soi_range_list. - data: rangeitem type soi_range_item. - data: contents type soi_generic_table. - data: contentsitem type soi_generic_item. - data: semaitem type gxxlt_s. - data: hkeyitem type gxxlt_h. - data: vkeyitem type gxxlt_v. - data: li_commentary_rows type i. "row number of title lines + 1 - data: lo_error_w type ref to i_oi_error. - data: l_retcode type soi_ret_string. - data: no_flush type c value 'X'. - data: li_head_top type i. "header rows position + data: TYP. + data: RANGES type SOI_RANGE_LIST. + data: RANGEITEM type SOI_RANGE_ITEM. + data: CONTENTS type SOI_GENERIC_TABLE. + data: CONTENTSITEM type SOI_GENERIC_ITEM. + data: SEMAITEM type GXXLT_S. + data: HKEYITEM type GXXLT_H. + data: VKEYITEM type GXXLT_V. + data: LI_COMMENTARY_ROWS type I. "row number of title lines + 1 + data: LO_ERROR_W type ref to I_OI_ERROR. + data: L_RETCODE type SOI_RET_STRING. + data: NO_FLUSH type C value 'X'. + data: LI_HEAD_TOP type I. "header rows position * Data for session 5: Save and clode document * ------------------------------------------ - data: li_document_size type i. - data: ls_path type RLGRAP-FILENAME. + data: LI_DOCUMENT_SIZE type I. + data: LS_PATH type RLGRAP-FILENAME. * MACRO: Close_document *------------------------------------------- - DEFINE close_document. - clear: l_is_closed. - IF lo_proxy is not initial. + define CLOSE_DOCUMENT. + clear: L_IS_CLOSED. + if LO_PROXY is not initial. * check proxy detroyed adi - call method lo_proxy->is_destroyed - IMPORTING - ret_value = l_is_closed. + call method LO_PROXY->IS_DESTROYED + importing + RET_VALUE = L_IS_CLOSED. * if dun detroyed yet: close -> release proxy - IF l_is_closed is initial. - call method lo_proxy->close_document + if L_IS_CLOSED is initial. + call method LO_PROXY->CLOSE_DOCUMENT * EXPORTING * do_save = do_save - IMPORTING - error = lo_error - retcode = lc_retcode. - ENDIF. + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE. + endif. - call method lo_proxy->release_document - IMPORTING - error = lo_error - retcode = lC_retcode. + call method LO_PROXY->RELEASE_DOCUMENT + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - else. - lc_retcode = c_oi_errors=>ret_document_not_open. - ENDIF. + else. + LC_RETCODE = C_OI_ERRORS=>RET_DOCUMENT_NOT_OPEN. + endif. * Detroy control container - IF lo_control is not initial. - CALL METHOD lo_control->destroy_control. - ENDIF. + if LO_CONTROL is not initial. + call method LO_CONTROL->DESTROY_CONTROL. + endif. - clear: - lo_spreadsheet, - lo_proxy, - lo_control. + clear: + LO_SPREADSHEET, + LO_PROXY, + LO_CONTROL. * free local - clear: l_is_closed. + clear: L_IS_CLOSED. - END-OF-DEFINITION. + end-of-definition. * Macro to catch DOI error *------------------------------------------- - DEFINE error_doi. - if lc_retcode ne c_oi_errors=>ret_ok. - close_document. - call method lo_error->raise_message - EXPORTING - type = 'E'. - clear: lo_error. - endif. - END-OF-DEFINITION. + define ERROR_DOI. + if LC_RETCODE ne C_OI_ERRORS=>RET_OK. + CLOSE_DOCUMENT. + call method LO_ERROR->RAISE_MESSAGE + exporting + TYPE = 'E'. + clear: LO_ERROR. + endif. + end-of-definition. *--------------------------------------------------------------------* * SESSION 0: DOI CONSTRUCTOR @@ -928,119 +928,119 @@ method BIND_ALV_OLE2. * check active windown - call function 'GUI_HAS_ACTIVEX' - IMPORTING - return = l_has_activex. + call function 'GUI_HAS_ACTIVEX' + importing + RETURN = L_HAS_ACTIVEX. - if l_has_activex is initial. - raise MISS_GUIDE. - endif. + if L_HAS_ACTIVEX is initial. + raise MISS_GUIDE. + endif. * Get Container Object of Screen - call method c_oi_container_control_creator=>get_container_control - IMPORTING - control = lo_control - retcode = lC_retcode. + call method C_OI_CONTAINER_CONTROL_CREATOR=>GET_CONTAINER_CONTROL + importing + CONTROL = LO_CONTROL + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. * Initialize Container control - CALL METHOD lo_control->init_control - EXPORTING - parent = CL_GUI_CONTAINER=>DEFAULT_SCREEN - r3_application_name = '' - inplace_enabled = 'X' - no_flush = 'X' - register_on_close_event = 'X' - register_on_custom_event = 'X' - IMPORTING - error = lO_ERROR - retcode = lc_retcode. + call method LO_CONTROL->INIT_CONTROL + exporting + PARENT = CL_GUI_CONTAINER=>DEFAULT_SCREEN + R3_APPLICATION_NAME = '' + INPLACE_ENABLED = 'X' + NO_FLUSH = 'X' + REGISTER_ON_CLOSE_EVENT = 'X' + REGISTER_ON_CUSTOM_EVENT = 'X' + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. * Get Proxy Document: * check exist of document proxy, if exist -> close first - if not lo_proxy is initial. - close_document. - endif. + if not LO_PROXY is initial. + CLOSE_DOCUMENT. + endif. - IF i_xls is not initial. + if I_XLS is not initial. * xls format, doctype = soi_doctype_excel97_sheet - l_doctype_excel_sheet = 'Excel.Sheet.8'. - else. + L_DOCTYPE_EXCEL_SHEET = 'Excel.Sheet.8'. + else. * xlsx format, doctype = soi_doctype_excel_sheet - l_doctype_excel_sheet = 'Excel.Sheet'. - ENDIF. + L_DOCTYPE_EXCEL_SHEET = 'Excel.Sheet'. + endif. - CALL METHOD lo_control->get_document_proxy - EXPORTING - document_type = l_doctype_excel_sheet - register_container = 'X' - IMPORTING - document_proxy = lo_proxy - error = lO_ERROR - retcode = lc_retcode. + call method LO_CONTROL->GET_DOCUMENT_PROXY + exporting + DOCUMENT_TYPE = L_DOCTYPE_EXCEL_SHEET + REGISTER_CONTAINER = 'X' + importing + DOCUMENT_PROXY = LO_PROXY + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. - IF I_DOCUMENT_URL is initial. + if I_DOCUMENT_URL is initial. * create new excel document - call method lo_proxy->create_document - EXPORTING - create_view_data = 'X' - open_inplace = 'X' - no_flush = 'X' - IMPORTING - ERROR = lO_ERROR - retcode = lc_retcode. + call method LO_PROXY->CREATE_DOCUMENT + exporting + CREATE_VIEW_DATA = 'X' + OPEN_INPLACE = 'X' + NO_FLUSH = 'X' + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. - else. + else. * Read excel template for i_DOCUMENT_URL * this excel template can be store in local or server - CALL METHOD lo_proxy->open_document - EXPORTING - document_url = i_document_url - open_inplace = 'X' - no_flush = 'X' - IMPORTING - error = lo_error - retcode = lc_retcode. + call method LO_PROXY->OPEN_DOCUMENT + exporting + DOCUMENT_URL = I_DOCUMENT_URL + OPEN_INPLACE = 'X' + NO_FLUSH = 'X' + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. - endif. + endif. * Check Spreadsheet Interface of Document Proxy - CALL METHOD lo_proxy->has_spreadsheet_interface - IMPORTING - is_available = li_has - error = lO_ERROR - retcode = lc_retcode. + call method LO_PROXY->HAS_SPREADSHEET_INTERFACE + importing + IS_AVAILABLE = LI_HAS + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. * create Spreadsheet object - CHECK li_has IS NOT INITIAL. + check LI_HAS is not initial. - CALL METHOD lo_proxy->get_spreadsheet_interface - IMPORTING - sheet_interface = lo_spreadsheet - error = lO_ERROR - retcode = lc_retcode. + call method LO_PROXY->GET_SPREADSHEET_INTERFACE + importing + SHEET_INTERFACE = LO_SPREADSHEET + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. *--------------------------------------------------------------------* * SESSION 1: GET LVC DATA FROM ALV OBJECT @@ -1048,109 +1048,109 @@ method BIND_ALV_OLE2. * data table - create object lo_grid - EXPORTING - i_parent = CL_GUI_CONTAINER=>SCREEN0. + create object LO_GRID + exporting + I_PARENT = CL_GUI_CONTAINER=>SCREEN0. - call method lo_grid->get_alv_attributes - EXPORTING - io_grid = io_alv - IMPORTING - Et_table = lt_alv. + call method LO_GRID->GET_ALV_ATTRIBUTES + exporting + IO_GRID = IO_ALV + importing + ET_TABLE = LT_ALV. - assign lt_alv->* to . + assign LT_ALV->* to . * fieldcat - CALL METHOD iO_alv->GET_FRONTEND_FIELDCATALOG - IMPORTING - ET_FIELDCATALOG = lt_fieldcat_LVC. + call method IO_ALV->GET_FRONTEND_FIELDCATALOG + importing + ET_FIELDCATALOG = LT_FIELDCAT_LVC. * table name - loop at lt_fieldcat_LVC into wa_fieldcat_lvc - where not tabname is initial. - l_tabname = wa_fieldcat_lvc-tabname. - exit. - endloop. + loop at LT_FIELDCAT_LVC into WA_FIELDCAT_LVC + where not TABNAME is initial. + L_TABNAME = WA_FIELDCAT_LVC-TABNAME. + exit. + endloop. - if sy-subrc ne 0. - l_tabname = '1'. - endif. - clear: wa_fieldcat_lvc. + if SY-SUBRC ne 0. + L_TABNAME = '1'. + endif. + clear: WA_FIELDCAT_LVC. * sort table - CALL METHOD IO_ALV->GET_SORT_CRITERIA - IMPORTING - ET_SORT = lt_sort_lvc. + call method IO_ALV->GET_SORT_CRITERIA + importing + ET_SORT = LT_SORT_LVC. * filter index - CALL METHOD IO_ALV->GET_FILTERED_ENTRIES - IMPORTING - ET_FILTERED_ENTRIES = lt_filter_idx_lvc. + call method IO_ALV->GET_FILTERED_ENTRIES + importing + ET_FILTERED_ENTRIES = LT_FILTER_IDX_LVC. * group level + subtotal - CALL METHOD IO_ALV->GET_SUBTOTALS - IMPORTING - EP_COLLECT00 = lt_collect00 - EP_COLLECT01 = lt_collect01 - EP_COLLECT02 = lt_collect02 - EP_COLLECT03 = lt_collect03 - EP_COLLECT04 = lt_collect04 - EP_COLLECT05 = lt_collect05 - EP_COLLECT06 = lt_collect06 - EP_COLLECT07 = lt_collect07 - EP_COLLECT08 = lt_collect08 - EP_COLLECT09 = lt_collect09 - ET_GROUPLEVELS = lt_GROUPLEVELS_LVC. + call method IO_ALV->GET_SUBTOTALS + importing + EP_COLLECT00 = LT_COLLECT00 + EP_COLLECT01 = LT_COLLECT01 + EP_COLLECT02 = LT_COLLECT02 + EP_COLLECT03 = LT_COLLECT03 + EP_COLLECT04 = LT_COLLECT04 + EP_COLLECT05 = LT_COLLECT05 + EP_COLLECT06 = LT_COLLECT06 + EP_COLLECT07 = LT_COLLECT07 + EP_COLLECT08 = LT_COLLECT08 + EP_COLLECT09 = LT_COLLECT09 + ET_GROUPLEVELS = LT_GROUPLEVELS_LVC. - assign lt_collect00->* to . - assign lt_collect01->* to . - assign lt_collect02->* to . - assign lt_collect03->* to . - assign lt_collect04->* to . - assign lt_collect05->* to . - assign lt_collect06->* to . - assign lt_collect07->* to . - assign lt_collect08->* to . - assign lt_collect09->* to . + assign LT_COLLECT00->* to . + assign LT_COLLECT01->* to . + assign LT_COLLECT02->* to . + assign LT_COLLECT03->* to . + assign LT_COLLECT04->* to . + assign LT_COLLECT05->* to . + assign LT_COLLECT06->* to . + assign LT_COLLECT07->* to . + assign LT_COLLECT08->* to . + assign LT_COLLECT09->* to . * transfer to KKBLO struct - CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO' - EXPORTING - IT_FIELDCAT_LVC = lt_fieldcat_lvc - IT_SORT_LVC = lt_sort_lvc - IT_FILTER_INDEX_LVC = lt_filter_idx_lvc - IT_GROUPLEVELS_LVC = lt_grouplevels_lvc - IMPORTING - ET_FIELDCAT_KKBLO = lt_fieldcat_kkblo - ET_SORT_KKBLO = lt_sort_kkblo - ET_FILTERED_ENTRIES_KKBLO = lt_filter_idx_kkblo - ET_GROUPLEVELS_KKBLO = lt_grouplevels_kkblo - TABLES - IT_DATA = - EXCEPTIONS - IT_DATA_MISSING = 1 - IT_FIELDCAT_LVC_MISSING = 2 - OTHERS = 3. - IF SY-SUBRC <> 0. - raise ex_transfer_KKBLO_ERROR. - ENDIF. + call function 'LVC_TRANSFER_TO_KKBLO' + exporting + IT_FIELDCAT_LVC = LT_FIELDCAT_LVC + IT_SORT_LVC = LT_SORT_LVC + IT_FILTER_INDEX_LVC = LT_FILTER_IDX_LVC + IT_GROUPLEVELS_LVC = LT_GROUPLEVELS_LVC + importing + ET_FIELDCAT_KKBLO = LT_FIELDCAT_KKBLO + ET_SORT_KKBLO = LT_SORT_KKBLO + ET_FILTERED_ENTRIES_KKBLO = LT_FILTER_IDX_KKBLO + ET_GROUPLEVELS_KKBLO = LT_GROUPLEVELS_KKBLO + tables + IT_DATA = + exceptions + IT_DATA_MISSING = 1 + IT_FIELDCAT_LVC_MISSING = 2 + others = 3. + if SY-SUBRC <> 0. + raise EX_TRANSFER_KKBLO_ERROR. + endif. - clear: - wa_fieldcat_lvc, - lt_fieldcat_lvc, - lt_sort_lvc, - lt_filter_idx_lvc, - lt_GROUPLEVELS_LVC. + clear: + WA_FIELDCAT_LVC, + LT_FIELDCAT_LVC, + LT_SORT_LVC, + LT_FILTER_IDX_LVC, + LT_GROUPLEVELS_LVC. - clear: - lo_grid. + clear: + LO_GRID. *--------------------------------------------------------------------* @@ -1159,176 +1159,176 @@ method BIND_ALV_OLE2. * append subtotal & total line - create data lt_excel like . - assign lt_excel->* to . + create data LT_EXCEL like . + assign LT_EXCEL->* to . - loop at assigning . - l_save_index = sy-tabix. + loop at assigning . + L_SAVE_INDEX = SY-TABIX. * filter base on filter index table - read table LT_FILTER_IDX_KKBLO assigning - with key index = l_save_index - binary search. - if sy-subrc ne 0. - append to . - endif. + read table LT_FILTER_IDX_KKBLO assigning + with key INDEX = L_SAVE_INDEX + binary search. + if SY-SUBRC ne 0. + append to . + endif. * append subtotal lines - read table LT_GROUPLEVELS_KKBLO assigning - with key index_to = l_save_index - binary search. - if sy-subrc = 0. - l_tabix = sy-tabix. - do. - if -subtot eq 'X' and - -hide_level is initial and - -cindex_from ne 0. + read table LT_GROUPLEVELS_KKBLO assigning + with key INDEX_TO = L_SAVE_INDEX + binary search. + if SY-SUBRC = 0. + L_TABIX = SY-TABIX. + do. + if -SUBTOT eq 'X' and + -HIDE_LEVEL is initial and + -CINDEX_FROM ne 0. * dynamic append subtotal line to excel table base on grouplevel table * ex -level = 1 * then = '' - l_collect = -level. - condense l_collect. - concatenate '' + L_COLLECT = -LEVEL. + condense L_COLLECT. + concatenate '' * '->*' - into l_collect. + into L_COLLECT. - assign (l_collect) to . + assign (L_COLLECT) to . * incase there're more than 1 total line of group, at the same level * for example: subtotal of multi currency - LOOP AT assigning . - IF sy-tabix between -cindex_from - and -cindex_to. + loop at assigning . + if SY-TABIX between -CINDEX_FROM + and -CINDEX_TO. - append to . + append to . * save subtotal lines index - wa_subtot_indexs-index = sy-tabix. - append wa_subtot_indexs to lt_subtot_indexs. + WA_SUBTOT_INDEXS-INDEX = SY-TABIX. + append WA_SUBTOT_INDEXS to LT_SUBTOT_INDEXS. * append sub total ranges table for format later - add 1 to l_sub_index. - subrangeitem-name = l_sub_index. - condense subrangeitem-name. - concatenate 'SUBTOT' - subrangeitem-name - into subrangeitem-name. + add 1 to L_SUB_INDEX. + SUBRANGEITEM-NAME = L_SUB_INDEX. + condense SUBRANGEITEM-NAME. + concatenate 'SUBTOT' + SUBRANGEITEM-NAME + into SUBRANGEITEM-NAME. - subrangeitem-rows = wa_subtot_indexs-index. - subrangeitem-columns = 1. " start col - append subrangeitem to subranges. - clear: subrangeitem. + SUBRANGEITEM-ROWS = WA_SUBTOT_INDEXS-INDEX. + SUBRANGEITEM-COLUMNS = 1. " start col + append SUBRANGEITEM to SUBRANGES. + clear: SUBRANGEITEM. - ENDIF. - ENDLOOP. - unassign: . - unassign: . - clear: l_collect. - endif. + endif. + endloop. + unassign: . + unassign: . + clear: L_COLLECT. + endif. * check next subtotal level of group - unassign: . - add 1 to l_tabix. + unassign: . + add 1 to L_TABIX. - read table LT_GROUPLEVELS_KKBLO assigning - index l_tabix. - if sy-subrc ne 0 - or -index_to ne l_save_index. - exit. - endif. + read table LT_GROUPLEVELS_KKBLO assigning + index L_TABIX. + if SY-SUBRC ne 0 + or -INDEX_TO ne L_SAVE_INDEX. + exit. + endif. - unassign: - , - . + unassign: + , + . - enddo. - endif. + enddo. + endif. - clear: - l_tabix, - l_save_index. + clear: + L_TABIX, + L_SAVE_INDEX. - unassign: - , - . + unassign: + , + . - endloop. + endloop. * free local data - unassign: - , - , - , - . + unassign: + , + , + , + . * append grand total line - IF is assigned. - assign to . - if is not initial. - LOOP AT assigning . + if is assigned. + assign to . + if is not initial. + loop at assigning . - append to . + append to . * save total line index - wa_subtot_indexs-index = sy-tabix. - append wa_subtot_indexs to lt_subtot_indexs. + WA_SUBTOT_INDEXS-INDEX = SY-TABIX. + append WA_SUBTOT_INDEXS to LT_SUBTOT_INDEXS. * append grand total range (to format) - add 1 to l_sub_index. - subrangeitem-name = l_sub_index. - condense subrangeitem-name. - concatenate 'TOTAL' - subrangeitem-name - into subrangeitem-name. + add 1 to L_SUB_INDEX. + SUBRANGEITEM-NAME = L_SUB_INDEX. + condense SUBRANGEITEM-NAME. + concatenate 'TOTAL' + SUBRANGEITEM-NAME + into SUBRANGEITEM-NAME. - subrangeitem-rows = wa_subtot_indexs-index. - subrangeitem-columns = 1. " start col - append subrangeitem to subranges. - ENDLOOP. + SUBRANGEITEM-ROWS = WA_SUBTOT_INDEXS-INDEX. + SUBRANGEITEM-COLUMNS = 1. " start col + append SUBRANGEITEM to SUBRANGES. + endloop. + endif. endif. - ENDIF. - clear: - subrangeitem, - LT_SORT_KKBLO, - , - , - , - , - , - , - , - , - , - . + clear: + SUBRANGEITEM, + LT_SORT_KKBLO, + , + , + , + , + , + , + , + , + , + . - unassign: - , - , - , - , - , - , - , - , - , - , - , - . + unassign: + , + , + , + , + , + , + , + , + , + , + , + . *--------------------------------------------------------------------* * SESSION 3: MAP DATA TO SEMANTIC TABLE @@ -1336,1197 +1336,1197 @@ method BIND_ALV_OLE2. * get dependent field field: currency and quantity - create data wa like line of . - assign wa->* to . + create data WA like line of . + assign WA->* to . - describe field type l_typ components l_num. + describe field type L_TYP components L_NUM. - do l_num times. - l_save_index = sy-index. - assign component l_save_index of structure - to . - if sy-subrc ne 0. - message e059(0k) with 'FATAL ERROR' raising fatal_error. - endif. + do L_NUM times. + L_SAVE_INDEX = SY-INDEX. + assign component L_SAVE_INDEX of structure + to . + if SY-SUBRC ne 0. + message E059(0K) with 'FATAL ERROR' raising FATAL_ERROR. + endif. - loop at LT_FIELDCAT_KKBLO assigning - where tabname = l_tabname. - assign component -fieldname - of structure to . + loop at LT_FIELDCAT_KKBLO assigning + where TABNAME = L_TABNAME. + assign component -FIELDNAME + of structure to . - describe distance between and - into l_int in byte mode. + describe distance between and + into L_INT in byte mode. * append column index * this columns index is of table, not fieldcat - if l_int = 0. - wa_column_index-fieldname = -fieldname. - wa_column_index-tabname = -tabname. - wa_column_index-col = l_save_index. - append wa_column_index to lt_column_index. - endif. + if L_INT = 0. + WA_COLUMN_INDEX-FIELDNAME = -FIELDNAME. + WA_COLUMN_INDEX-TABNAME = -TABNAME. + WA_COLUMN_INDEX-COL = L_SAVE_INDEX. + append WA_COLUMN_INDEX to LT_COLUMN_INDEX. + endif. * append dependent fields (currency and quantity unit) - if -cfieldname is not initial. - clear wa_fieldcat_depf. - wa_fieldcat_depf-fieldname = -cfieldname. - wa_fieldcat_depf-tabname = -ctabname. - collect wa_fieldcat_depf into lt_fieldcat_depf. - endif. + if -CFIELDNAME is not initial. + clear WA_FIELDCAT_DEPF. + WA_FIELDCAT_DEPF-FIELDNAME = -CFIELDNAME. + WA_FIELDCAT_DEPF-TABNAME = -CTABNAME. + collect WA_FIELDCAT_DEPF into LT_FIELDCAT_DEPF. + endif. - if -qfieldname is not initial. - clear wa_fieldcat_depf. - wa_fieldcat_depf-fieldname = -qfieldname. - wa_fieldcat_depf-tabname = -qtabname. - collect wa_fieldcat_depf into lt_fieldcat_depf. - endif. + if -QFIELDNAME is not initial. + clear WA_FIELDCAT_DEPF. + WA_FIELDCAT_DEPF-FIELDNAME = -QFIELDNAME. + WA_FIELDCAT_DEPF-TABNAME = -QTABNAME. + collect WA_FIELDCAT_DEPF into LT_FIELDCAT_DEPF. + endif. * rewrite field data type - if -inttype = 'X' - and -datatype(3) = 'INT'. - -inttype = 'I'. - endif. + if -INTTYPE = 'X' + and -DATATYPE(3) = 'INT'. + -INTTYPE = 'I'. + endif. - endloop. + endloop. - clear: l_save_index. - unassign: . + clear: L_SAVE_INDEX. + unassign: . - enddo. + enddo. * build semantic tables - l_n_hrz_keys = 1. + L_N_HRZ_KEYS = 1. * Get keyfigures - loop at LT_FIELDCAT_KKBLO assigning - where tabname = l_tabname - and tech ne 'X' - and no_out ne 'X'. + loop at LT_FIELDCAT_KKBLO assigning + where TABNAME = L_TABNAME + and TECH ne 'X' + and NO_OUT ne 'X'. - clear wa_sema. - clear wa_hkey. + clear WA_SEMA. + clear WA_HKEY. * Units belong to keyfigures -> display as str - read table lt_fieldcat_depf into wa_fieldcat_depf with key - fieldname = -fieldname - tabname = -tabname. + read table LT_FIELDCAT_DEPF into WA_FIELDCAT_DEPF with key + FIELDNAME = -FIELDNAME + TABNAME = -TABNAME. - if sy-subrc = 0. - wa_sema-col_typ = 'STR'. - wa_sema-col_ops = 'DFT'. + if SY-SUBRC = 0. + WA_SEMA-COL_TYP = 'STR'. + WA_SEMA-COL_OPS = 'DFT'. * Keyfigures - else. - case -datatype. - when 'QUAN'. - wa_sema-col_typ = 'N03'. + else. + case -DATATYPE. + when 'QUAN'. + WA_SEMA-COL_TYP = 'N03'. - if -no_sum ne 'X'. - wa_sema-col_ops = 'ADD'. - else. - wa_sema-col_ops = 'NOP'. " no dependent field - endif. + if -NO_SUM ne 'X'. + WA_SEMA-COL_OPS = 'ADD'. + else. + WA_SEMA-COL_OPS = 'NOP'. " no dependent field + endif. - when 'DATS'. - wa_sema-col_typ = 'DAT'. - wa_sema-col_ops = 'NOP'. + when 'DATS'. + WA_SEMA-COL_TYP = 'DAT'. + WA_SEMA-COL_OPS = 'NOP'. - when 'CHAR' OR 'UNIT' OR 'CUKY'. " Added fieldformats UNIT and CUKY - dd. 26-10-2012 Wouter Heuvelmans - wa_sema-col_typ = 'STR'. - wa_sema-col_ops = 'DFT'. " dependent field + when 'CHAR' or 'UNIT' or 'CUKY'. " Added fieldformats UNIT and CUKY - dd. 26-10-2012 Wouter Heuvelmans + WA_SEMA-COL_TYP = 'STR'. + WA_SEMA-COL_OPS = 'DFT'. " dependent field * incase numeric, ex '00120' -> display as '12' - when 'NUMC'. - wa_sema-col_typ = 'STR'. - wa_sema-col_ops = 'DFT'. + when 'NUMC'. + WA_SEMA-COL_TYP = 'STR'. + WA_SEMA-COL_OPS = 'DFT'. - when others. - wa_sema-col_typ = 'NUM'. + when others. + WA_SEMA-COL_TYP = 'NUM'. - if -no_sum ne 'X'. - wa_sema-col_ops = 'ADD'. - else. - wa_sema-col_ops = 'NOP'. - endif. - endcase. - endif. + if -NO_SUM ne 'X'. + WA_SEMA-COL_OPS = 'ADD'. + else. + WA_SEMA-COL_OPS = 'NOP'. + endif. + endcase. + endif. - l_counter = l_counter + 1. - l_n_att_cols = l_n_att_cols + 1. + L_COUNTER = L_COUNTER + 1. + L_N_ATT_COLS = L_N_ATT_COLS + 1. - wa_sema-col_no = l_counter. + WA_SEMA-COL_NO = L_COUNTER. - read table lt_column_index into wa_column_index with key - fieldname = -fieldname - tabname = -tabname. + read table LT_COLUMN_INDEX into WA_COLUMN_INDEX with key + FIELDNAME = -FIELDNAME + TABNAME = -TABNAME. - if sy-subrc = 0. - wa_sema-col_src = wa_column_index-col. - else. - raise fatal_error. - endif. + if SY-SUBRC = 0. + WA_SEMA-COL_SRC = WA_COLUMN_INDEX-COL. + else. + raise FATAL_ERROR. + endif. * columns index of ref currency field in table - if not -cfieldname is initial. - read table lt_column_index into wa_column_index with key - fieldname = -cfieldname - tabname = -ctabname. + if not -CFIELDNAME is initial. + read table LT_COLUMN_INDEX into WA_COLUMN_INDEX with key + FIELDNAME = -CFIELDNAME + TABNAME = -CTABNAME. - if sy-subrc = 0. - wa_sema-col_cur = wa_column_index-col. - endif. + if SY-SUBRC = 0. + WA_SEMA-COL_CUR = WA_COLUMN_INDEX-COL. + endif. * quantities fields * treat as currency when display on excel - elseif not -qfieldname is initial. - read table lt_column_index into wa_column_index with key - fieldname = -qfieldname - tabname = -qtabname. - if sy-subrc = 0. - wa_sema-col_cur = wa_column_index-col. - endif. + elseif not -QFIELDNAME is initial. + read table LT_COLUMN_INDEX into WA_COLUMN_INDEX with key + FIELDNAME = -QFIELDNAME + TABNAME = -QTABNAME. + if SY-SUBRC = 0. + WA_SEMA-COL_CUR = WA_COLUMN_INDEX-COL. + endif. - endif. + endif. * Treat of fixed currency in the fieldcatalog for column - data: l_num_help(2) type n. + data: L_NUM_HELP(2) type N. - if not -currency is initial. + if not -CURRENCY is initial. + + select * from TCURX into table LT_TCURX. + sort LT_TCURX. + read table LT_TCURX into WA_TCURX + with key CURRKEY = -CURRENCY. + if SY-SUBRC = 0. + L_NUM_HELP = WA_TCURX-CURRDEC. + concatenate 'N' L_NUM_HELP into WA_SEMA-COL_TYP. + WA_SEMA-COL_CUR = SY-TABIX * ( -1 ). + endif. - select * from tcurx into table lt_tcurx. - sort lt_tcurx. - read table lt_tcurx into wa_tcurx - with key currkey = -currency. - if sy-subrc = 0. - l_num_help = wa_tcurx-currdec. - concatenate 'N' l_num_help into wa_sema-col_typ. - wa_sema-col_cur = sy-tabix * ( -1 ). endif. - endif. + WA_HKEY-COL_NO = L_N_ATT_COLS. + WA_HKEY-ROW_NO = L_N_HRZ_KEYS. + WA_HKEY-COL_NAME = -REPTEXT. + append WA_HKEY to LT_HKEY. + append WA_SEMA to LT_SEMA. - wa_hkey-col_no = l_n_att_cols. - wa_hkey-row_no = l_n_hrz_keys. - wa_hkey-col_name = -reptext. - append wa_hkey to lt_hkey. - append wa_sema to lt_sema. - - endloop. + endloop. * free local data - clear: - lt_column_index, - wa_column_index, - lt_fieldcat_depf, - wa_fieldcat_depf, - lt_tcurx, - wa_tcurx, - l_num, - l_typ, - wa, - l_int, - l_counter. + clear: + LT_COLUMN_INDEX, + WA_COLUMN_INDEX, + LT_FIELDCAT_DEPF, + WA_FIELDCAT_DEPF, + LT_TCURX, + WA_TCURX, + L_NUM, + L_TYP, + WA, + L_INT, + L_COUNTER. - unassign: - , - , - , - . + unassign: + , + , + , + . *--------------------------------------------------------------------* * SESSION 4: WRITE TO EXCEL *--------------------------------------------------------------------* - clear: wa_tcurx. - refresh: lt_tcurx. + clear: WA_TCURX. + refresh: LT_TCURX. * if spreadsheet dun have proxy yet - if li_has is initial. - l_retcode = c_oi_errors=>ret_interface_not_supported. - call method c_oi_errors=>create_error_for_retcode - EXPORTING - retcode = l_retcode - no_flush = no_flush - IMPORTING - error = lo_error_w. - exit. - endif. + if LI_HAS is initial. + L_RETCODE = C_OI_ERRORS=>RET_INTERFACE_NOT_SUPPORTED. + call method C_OI_ERRORS=>CREATE_ERROR_FOR_RETCODE + exporting + RETCODE = L_RETCODE + NO_FLUSH = NO_FLUSH + importing + ERROR = LO_ERROR_W. + exit. + endif. - create object l_error - EXPORTING - object_name = 'OLE_DOCUMENT_PROXY' - method_name = 'get_ranges_names'. + create object L_ERROR + exporting + OBJECT_NAME = 'OLE_DOCUMENT_PROXY' + METHOD_NAME = 'get_ranges_names'. - call method c_oi_errors=>add_error - EXPORTING - error = l_error. + call method C_OI_ERRORS=>ADD_ERROR + exporting + ERROR = L_ERROR. - describe table lt_sema lines datareal. - describe table lines datac. - describe table lt_vkey lines vkeycount. + describe table LT_SEMA lines DATAREAL. + describe table lines DATAC. + describe table LT_VKEY lines VKEYCOUNT. - if datac = 0. - raise inv_data_range. - endif. + if DATAC = 0. + raise INV_DATA_RANGE. + endif. - if vkeycount ne l_n_vrt_keys. - raise dim_mismatch_vkey. - endif. + if VKEYCOUNT ne L_N_VRT_KEYS. + raise DIM_MISMATCH_VKEY. + endif. - all = l_n_vrt_keys + l_n_att_cols. + ALL = L_N_VRT_KEYS + L_N_ATT_COLS. - if datareal ne all. - raise dim_mismatch_sema. - endif. + if DATAREAL ne ALL. + raise DIM_MISMATCH_SEMA. + endif. - data: decimal type c. + data: DECIMAL type C. * get decimal separator format ('.', ',', ...) in Office config - call method lo_proxy->get_application_property - EXPORTING - property_name = 'INTERNATIONAL' - subproperty_name = 'DECIMAL_SEPARATOR' - CHANGING - retvalue = decimal. + call method LO_PROXY->GET_APPLICATION_PROPERTY + exporting + PROPERTY_NAME = 'INTERNATIONAL' + SUBPROPERTY_NAME = 'DECIMAL_SEPARATOR' + changing + RETVALUE = DECIMAL. - data: wa_usr type usr01. - select * from usr01 into wa_usr where bname = sy-uname. - endselect. + data: WA_USR type USR01. + select * from USR01 into WA_USR where BNAME = SY-UNAME. + endselect. - data: comma_elim(4) type c. - field-symbols type any. - data search_item(4) value ' #'. + data: COMMA_ELIM(4) type C. + field-symbols type ANY. + data SEARCH_ITEM(4) value ' #'. - concatenate ',' decimal '.' decimal into comma_elim. + concatenate ',' DECIMAL '.' DECIMAL into COMMA_ELIM. - data help type i. " table (with subtotal) line number + data HELP type I. " table (with subtotal) line number - help = datac. + HELP = DATAC. - data: rowmax type i value 1. " header row number - data: columnmax type i value 0. " header columns number + data: ROWMAX type I value 1. " header row number + data: COLUMNMAX type I value 0. " header columns number - loop at lt_hkey into hkeyitem. - if hkeyitem-col_no > columnmax. - columnmax = hkeyitem-col_no. + loop at LT_HKEY into HKEYITEM. + if HKEYITEM-COL_NO > COLUMNMAX. + COLUMNMAX = HKEYITEM-COL_NO. + endif. + + if HKEYITEM-ROW_NO > ROWMAX. + ROWMAX = HKEYITEM-ROW_NO. + endif. + endloop. + + data: HKEYCOLUMNS type I. " header columns no + + HKEYCOLUMNS = COLUMNMAX. + + if HKEYCOLUMNS < L_N_ATT_COLS. + HKEYCOLUMNS = L_N_ATT_COLS. endif. - if hkeyitem-row_no > rowmax. - rowmax = hkeyitem-row_no. - endif. - endloop. + COLUMNMAX = 0. - data: hkeycolumns type i. " header columns no + loop at LT_VKEY into VKEYITEM. + if VKEYITEM-COL_NO > COLUMNMAX. + COLUMNMAX = VKEYITEM-COL_NO. + endif. + endloop. - hkeycolumns = columnmax. + data OVERFLOW type I value 1. + data TESTNAME(10) type C. + data TEMP2 type I. " 1st item row position in excel + data REALMIT type I value 1. + data REALOVERFLOW type I value 1. " row index in content - if hkeycolumns < l_n_att_cols. - hkeycolumns = l_n_att_cols. - endif. + call method LO_SPREADSHEET->SCREEN_UPDATE + exporting + UPDATING = ''. - columnmax = 0. + call method LO_SPREADSHEET->LOAD_LIB. - loop at lt_vkey into vkeyitem. - if vkeyitem-col_no > columnmax. - columnmax = vkeyitem-col_no. - endif. - endloop. - - data overflow type i value 1. - data testname(10) type c. - data temp2 type i. " 1st item row position in excel - data realmit type i value 1. - data realoverflow type i value 1. " row index in content - - call method lo_spreadsheet->screen_update - EXPORTING - updating = ''. - - call method lo_spreadsheet->load_lib. - - data: str(40) type c. " range names of columns range (w/o col header) - data: rows type i. " row postion of 1st item line in ecxel + data: STR(40) type C. " range names of columns range (w/o col header) + data: ROWS type I. " row postion of 1st item line in ecxel * calculate row position of data table - describe table iT_LISTHEADER lines li_commentary_rows. + describe table IT_LISTHEADER lines LI_COMMENTARY_ROWS. * if grid had title, add 1 empy line between title and table - if li_commentary_rows ne 0. - add 1 to li_commentary_rows. - endif. + if LI_COMMENTARY_ROWS ne 0. + add 1 to LI_COMMENTARY_ROWS. + endif. * add top position of block data - li_commentary_rows = li_commentary_rows + i_top - 1. + LI_COMMENTARY_ROWS = LI_COMMENTARY_ROWS + I_TOP - 1. * write header (commentary rows) - data: li_commentary_row_index type i value 1. - data: li_content_index type i value 1. - data: ls_index(10) type c. - data ls_commentary_range(40) type c value 'TITLE'. - data: li_font_bold type i. - data: li_font_italic type i. - data: li_font_size type i. + data: LI_COMMENTARY_ROW_INDEX type I value 1. + data: LI_CONTENT_INDEX type I value 1. + data: LS_INDEX(10) type C. + data LS_COMMENTARY_RANGE(40) type C value 'TITLE'. + data: LI_FONT_BOLD type I. + data: LI_FONT_ITALIC type I. + data: LI_FONT_SIZE type I. - loop at iT_LISTHEADER into wa_listheader. - li_commentary_row_index = i_top + li_content_index - 1. - ls_index = li_content_index. - condense ls_index. - concatenate ls_commentary_range(5) ls_index - into ls_commentary_range. - condense ls_commentary_range. + loop at IT_LISTHEADER into WA_LISTHEADER. + LI_COMMENTARY_ROW_INDEX = I_TOP + LI_CONTENT_INDEX - 1. + LS_INDEX = LI_CONTENT_INDEX. + condense LS_INDEX. + concatenate LS_COMMENTARY_RANGE(5) LS_INDEX + into LS_COMMENTARY_RANGE. + condense LS_COMMENTARY_RANGE. * insert title range - call method lo_spreadsheet->insert_range_dim - EXPORTING - name = ls_commentary_range - top = li_commentary_row_index - left = i_left - rows = 1 - columns = 1 - no_flush = no_flush. + call method LO_SPREADSHEET->INSERT_RANGE_DIM + exporting + NAME = LS_COMMENTARY_RANGE + TOP = LI_COMMENTARY_ROW_INDEX + LEFT = I_LEFT + ROWS = 1 + COLUMNS = 1 + NO_FLUSH = NO_FLUSH. * format range - case wa_listheader-typ. - when 'H'. "title - li_font_size = 16. - li_font_bold = 1. - li_font_italic = -1. - when 'S'. "subtile - li_font_size = -1. - li_font_bold = 1. - li_font_italic = -1. - when others. "'A' comment - li_font_size = -1. - li_font_bold = -1. - li_font_italic = 1. - endcase. + case WA_LISTHEADER-TYP. + when 'H'. "title + LI_FONT_SIZE = 16. + LI_FONT_BOLD = 1. + LI_FONT_ITALIC = -1. + when 'S'. "subtile + LI_FONT_SIZE = -1. + LI_FONT_BOLD = 1. + LI_FONT_ITALIC = -1. + when others. "'A' comment + LI_FONT_SIZE = -1. + LI_FONT_BOLD = -1. + LI_FONT_ITALIC = 1. + endcase. - call method lo_spreadsheet->set_font - EXPORTING - rangename = ls_commentary_range - family = '' - size = li_font_size - bold = li_font_bold - italic = li_font_italic - align = 0 - no_flush = no_flush. + call method LO_SPREADSHEET->SET_FONT + exporting + RANGENAME = LS_COMMENTARY_RANGE + FAMILY = '' + SIZE = LI_FONT_SIZE + BOLD = LI_FONT_BOLD + ITALIC = LI_FONT_ITALIC + ALIGN = 0 + NO_FLUSH = NO_FLUSH. * title: range content - rangeitem-name = ls_commentary_range. - rangeitem-columns = 1. - rangeitem-rows = 1. - append rangeitem to ranges. + RANGEITEM-NAME = LS_COMMENTARY_RANGE. + RANGEITEM-COLUMNS = 1. + RANGEITEM-ROWS = 1. + append RANGEITEM to RANGES. - contentsitem-row = li_content_index. - contentsitem-column = 1. - concatenate wa_listheader-key - wa_listheader-info - into contentsitem-value - separated by space. - condense contentsitem-value. - append contentsitem to contents. + CONTENTSITEM-ROW = LI_CONTENT_INDEX. + CONTENTSITEM-COLUMN = 1. + concatenate WA_LISTHEADER-KEY + WA_LISTHEADER-INFO + into CONTENTSITEM-VALUE + separated by SPACE. + condense CONTENTSITEM-VALUE. + append CONTENTSITEM to CONTENTS. - add 1 to li_content_index. + add 1 to LI_CONTENT_INDEX. - clear: - rangeitem, - contentsitem, - ls_index. + clear: + RANGEITEM, + CONTENTSITEM, + LS_INDEX. - endloop. + endloop. * set range data title - call method lo_spreadsheet->set_ranges_data - EXPORTING - ranges = ranges - contents = contents - no_flush = no_flush. + call method LO_SPREADSHEET->SET_RANGES_DATA + exporting + RANGES = RANGES + CONTENTS = CONTENTS + NO_FLUSH = NO_FLUSH. - refresh: - ranges, - contents. + refresh: + RANGES, + CONTENTS. - rows = rowmax + li_commentary_rows + 1. + ROWS = ROWMAX + LI_COMMENTARY_ROWS + 1. - all = wa_usr-datfm. - all = all + 3. + ALL = WA_USR-DATFM. + ALL = ALL + 3. - loop at lt_sema into semaitem. - if semaitem-col_typ = 'DAT' or semaitem-col_typ = 'MON' or - semaitem-col_typ = 'N00' or semaitem-col_typ = 'N01' or - semaitem-col_typ = 'N01' or semaitem-col_typ = 'N02' or - semaitem-col_typ = 'N03' or semaitem-col_typ = 'PCT' or - semaitem-col_typ = 'STR' or semaitem-col_typ = 'NUM'. - clear str. - str = semaitem-col_no. - condense str. - concatenate 'DATA' str into str. - mit = semaitem-col_no. - li_col_pos = semaitem-col_no + i_left - 1. + loop at LT_SEMA into SEMAITEM. + if SEMAITEM-COL_TYP = 'DAT' or SEMAITEM-COL_TYP = 'MON' or + SEMAITEM-COL_TYP = 'N00' or SEMAITEM-COL_TYP = 'N01' or + SEMAITEM-COL_TYP = 'N01' or SEMAITEM-COL_TYP = 'N02' or + SEMAITEM-COL_TYP = 'N03' or SEMAITEM-COL_TYP = 'PCT' or + SEMAITEM-COL_TYP = 'STR' or SEMAITEM-COL_TYP = 'NUM'. + clear STR. + STR = SEMAITEM-COL_NO. + condense STR. + concatenate 'DATA' STR into STR. + MIT = SEMAITEM-COL_NO. + LI_COL_POS = SEMAITEM-COL_NO + I_LEFT - 1. * range from data1 to data(n), for each columns of table - call method lo_spreadsheet->insert_range_dim - EXPORTING - name = str - top = rows - left = li_col_pos - rows = help - columns = 1 - no_flush = no_flush. + call method LO_SPREADSHEET->INSERT_RANGE_DIM + exporting + NAME = STR + TOP = ROWS + LEFT = LI_COL_POS + ROWS = HELP + COLUMNS = 1 + NO_FLUSH = NO_FLUSH. - data dec type i value -1. - data typeinfo type sydes_typeinfo. - loop at assigning . - assign component semaitem-col_no of structure to . - describe field into td. - read table td-types index 1 into typeinfo. - if typeinfo-type = 'P'. - dec = typeinfo-decimals. - elseif typeinfo-type = 'I'. - dec = 0. - endif. - - describe field type typ components count. - mit = 1. - do count times. - if mit = semaitem-col_src. - assign component sy-index of structure to . - describe field into td. - read table td-types index 1 into typeinfo. - if typeinfo-type = 'P'. - dec = typeinfo-decimals. - endif. - exit. + data DEC type I value -1. + data TYPEINFO type SYDES_TYPEINFO. + loop at assigning . + assign component SEMAITEM-COL_NO of structure to . + describe field into TD. + read table TD-TYPES index 1 into TYPEINFO. + if TYPEINFO-TYPE = 'P'. + DEC = TYPEINFO-DECIMALS. + elseif TYPEINFO-TYPE = 'I'. + DEC = 0. endif. - mit = mit + 1. - enddo. - exit. - endloop. + + describe field type TYP components COUNT. + MIT = 1. + do COUNT times. + if MIT = SEMAITEM-COL_SRC. + assign component SY-INDEX of structure to . + describe field into TD. + read table TD-TYPES index 1 into TYPEINFO. + if TYPEINFO-TYPE = 'P'. + DEC = TYPEINFO-DECIMALS. + endif. + exit. + endif. + MIT = MIT + 1. + enddo. + exit. + endloop. * format for each columns of table (w/o columns headers) - if semaitem-col_typ = 'DAT'. - if semaitem-col_no > vkeycount. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = all - no_flush = no_flush. - else. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 0 - no_flush = no_flush. + if SEMAITEM-COL_TYP = 'DAT'. + if SEMAITEM-COL_NO > VKEYCOUNT. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = ALL + NO_FLUSH = NO_FLUSH. + else. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 0 + NO_FLUSH = NO_FLUSH. + endif. + elseif SEMAITEM-COL_TYP = 'STR'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 0 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'MON'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 10 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'N00'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = 0 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'N01'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = 1 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'N02'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = 2 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'N03'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = 3 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'N04'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = 4 + NO_FLUSH = NO_FLUSH. + elseif SEMAITEM-COL_TYP = 'NUM'. + if DEC eq -1. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = 2 + NO_FLUSH = NO_FLUSH. + else. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 1 + DECIMALS = DEC + NO_FLUSH = NO_FLUSH. + endif. + elseif SEMAITEM-COL_TYP = 'PCT'. + call method LO_SPREADSHEET->SET_FORMAT + exporting + RANGENAME = STR + CURRENCY = '' + TYP = 3 + DECIMALS = 0 + NO_FLUSH = NO_FLUSH. endif. - elseif semaitem-col_typ = 'STR'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 0 - no_flush = no_flush. - elseif semaitem-col_typ = 'MON'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 10 - no_flush = no_flush. - elseif semaitem-col_typ = 'N00'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = 0 - no_flush = no_flush. - elseif semaitem-col_typ = 'N01'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = 1 - no_flush = no_flush. - elseif semaitem-col_typ = 'N02'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = 2 - no_flush = no_flush. - elseif semaitem-col_typ = 'N03'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = 3 - no_flush = no_flush. - elseif semaitem-col_typ = 'N04'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = 4 - no_flush = no_flush. - elseif semaitem-col_typ = 'NUM'. - if dec eq -1. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = 2 - no_flush = no_flush. - else. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 1 - decimals = dec - no_flush = no_flush. - endif. - elseif semaitem-col_typ = 'PCT'. - call method lo_spreadsheet->set_format - EXPORTING - rangename = str - currency = '' - typ = 3 - decimals = 0 - no_flush = no_flush. - endif. - endif. - endloop. + endif. + endloop. * get item contents for set_range_data method * get currency cell also - mit = 1. + MIT = 1. - data: currcells type soi_cell_table. - data: curritem type soi_cell_item. + data: CURRCELLS type SOI_CELL_TABLE. + data: CURRITEM type SOI_CELL_ITEM. - curritem-rows = 1. - curritem-columns = 1. - curritem-front = -1. - curritem-back = -1. - curritem-font = ''. - curritem-size = -1. - curritem-bold = -1. - curritem-italic = -1. - curritem-align = -1. - curritem-frametyp = -1. - curritem-framecolor = -1. - curritem-currency = ''. - curritem-number = 1. - curritem-input = -1. + CURRITEM-ROWS = 1. + CURRITEM-COLUMNS = 1. + CURRITEM-FRONT = -1. + CURRITEM-BACK = -1. + CURRITEM-FONT = ''. + CURRITEM-SIZE = -1. + CURRITEM-BOLD = -1. + CURRITEM-ITALIC = -1. + CURRITEM-ALIGN = -1. + CURRITEM-FRAMETYP = -1. + CURRITEM-FRAMECOLOR = -1. + CURRITEM-CURRENCY = ''. + CURRITEM-NUMBER = 1. + CURRITEM-INPUT = -1. - data: const type i. + data: CONST type I. * Change for Correction request * Initial 10000 lines are missing in Excel Export * if there are only 2 columns in exported List object. - if datareal gt 2. - const = 20000 / datareal. - else. - const = 20000 / ( datareal + 2 ). - endif. + if DATAREAL gt 2. + CONST = 20000 / DATAREAL. + else. + CONST = 20000 / ( DATAREAL + 2 ). + endif. - data: lines type i. - data: innerlines type i. - data: counter type i. - data: curritem2 like curritem. - data: curritem3 like curritem. - data: length type i. - data: found. + data: LINES type I. + data: INNERLINES type I. + data: COUNTER type I. + data: CURRITEM2 like CURRITEM. + data: CURRITEM3 like CURRITEM. + data: LENGTH type I. + data: FOUND. * append content table (for method set_range_content) - loop at assigning . + loop at assigning . * save line index to compare with lt_subtot_indexs, * to discover line is a subtotal / totale line or not * ex use to set 'dun display zero in subtotal / total line' - l_save_index = sy-tabix. + L_SAVE_INDEX = SY-TABIX. - do datareal times. - read table lt_sema into semaitem with key col_no = sy-index. - if semaitem-col_src ne 0. - assign component semaitem-col_src - of structure to . - else. - assign component sy-index - of structure to . - endif. - - contentsitem-row = realoverflow. - - if sy-subrc = 0. - move semaitem-col_ops to search_item(3). - search 'ADD#CNT#MIN#MAX#AVG#NOP#DFT#' - for search_item. - if sy-subrc ne 0. - raise error_in_sema. + do DATAREAL times. + read table LT_SEMA into SEMAITEM with key COL_NO = SY-INDEX. + if SEMAITEM-COL_SRC ne 0. + assign component SEMAITEM-COL_SRC + of structure to . + else. + assign component SY-INDEX + of structure to . endif. - move semaitem-col_typ to search_item(3). - search 'NUM#N00#N01#N02#N03#N04#PCT#DAT#MON#STR#' - for search_item. - if sy-subrc ne 0. - raise error_in_sema. - endif. - contentsitem-column = sy-index. - if semaitem-col_typ eq 'DAT' or semaitem-col_typ eq 'MON'. - if semaitem-col_no > vkeycount. - " Hinweis 512418 - " EXCEL bezieht Datumsangaben - " auf den 31.12.1899, behandelt - " aber 1900 als ein Schaltjahr - " d.h. ab 1.3.1900 korrekt - " 1.3.1900 als Zahl = 61 + CONTENTSITEM-ROW = REALOVERFLOW. - data: genesis type d value '18991230'. - data: number_of_days type p. + if SY-SUBRC = 0. + move SEMAITEM-COL_OPS to SEARCH_ITEM(3). + search 'ADD#CNT#MIN#MAX#AVG#NOP#DFT#' + for SEARCH_ITEM. + if SY-SUBRC ne 0. + raise ERROR_IN_SEMA. + endif. + move SEMAITEM-COL_TYP to SEARCH_ITEM(3). + search 'NUM#N00#N01#N02#N03#N04#PCT#DAT#MON#STR#' + for SEARCH_ITEM. + if SY-SUBRC ne 0. + raise ERROR_IN_SEMA. + endif. + CONTENTSITEM-COLUMN = SY-INDEX. + if SEMAITEM-COL_TYP eq 'DAT' or SEMAITEM-COL_TYP eq 'MON'. + if SEMAITEM-COL_NO > VKEYCOUNT. + + " Hinweis 512418 + " EXCEL bezieht Datumsangaben + " auf den 31.12.1899, behandelt + " aber 1900 als ein Schaltjahr + " d.h. ab 1.3.1900 korrekt + " 1.3.1900 als Zahl = 61 + + data: GENESIS type D value '18991230'. + data: NUMBER_OF_DAYS type P. * change for date in char format & sema_type = X - data: temp_date type d. + data: TEMP_DATE type D. - if not is initial and not co ' ' and not - co '0'. + if not is initial and not co ' ' and not + co '0'. * change for date in char format & sema_type = X starts - if sema_type = 'X'. - describe field type typ. - if typ = 'C'. - temp_date = . - number_of_days = temp_date - genesis. + if SEMA_TYPE = 'X'. + describe field type TYP. + if TYP = 'C'. + TEMP_DATE = . + NUMBER_OF_DAYS = TEMP_DATE - GENESIS. + else. + NUMBER_OF_DAYS = - GENESIS. + endif. else. - number_of_days = - genesis. + NUMBER_OF_DAYS = - GENESIS. + endif. +* change for date in char format & sema_type = X ends + if NUMBER_OF_DAYS < 61. + NUMBER_OF_DAYS = NUMBER_OF_DAYS - 1. + endif. + + set country 'DE'. + write NUMBER_OF_DAYS to CONTENTSITEM-VALUE + no-grouping + left-justified. + set country SPACE. + translate CONTENTSITEM-VALUE using COMMA_ELIM. + else. + clear CONTENTSITEM-VALUE. + endif. + else. + move to CONTENTSITEM-VALUE. + endif. + elseif SEMAITEM-COL_TYP eq 'NUM' or + SEMAITEM-COL_TYP eq 'N00' or + SEMAITEM-COL_TYP eq 'N01' or + SEMAITEM-COL_TYP eq 'N02' or + SEMAITEM-COL_TYP eq 'N03' or + SEMAITEM-COL_TYP eq 'N04' or + SEMAITEM-COL_TYP eq 'PCT'. + set country 'DE'. + describe field type TYP. + + if SEMAITEM-COL_CUR is initial. + if TYP ne 'F'. + write to CONTENTSITEM-VALUE no-grouping + no-sign decimals 14. + else. + write to CONTENTSITEM-VALUE no-grouping + no-sign. + endif. + else. +* Treat of fixed curreny for column >>Y9CK007319 + if SEMAITEM-COL_CUR < 0. + SEMAITEM-COL_CUR = SEMAITEM-COL_CUR * ( -1 ). + select * from TCURX into table LT_TCURX. + sort LT_TCURX. + read table LT_TCURX into + WA_TCURX index SEMAITEM-COL_CUR. + if SY-SUBRC = 0. + if TYP ne 'F'. + write to CONTENTSITEM-VALUE no-grouping + currency WA_TCURX-CURRKEY no-sign decimals 14. + else. + write to CONTENTSITEM-VALUE no-grouping + currency WA_TCURX-CURRKEY no-sign. + endif. endif. else. - number_of_days = - genesis. - endif. -* change for date in char format & sema_type = X ends - if number_of_days < 61. - number_of_days = number_of_days - 1. - endif. - - set country 'DE'. - write number_of_days to contentsitem-value - no-grouping - left-justified. - set country space. - translate contentsitem-value using comma_elim. - else. - clear contentsitem-value. - endif. - else. - move to contentsitem-value. - endif. - elseif semaitem-col_typ eq 'NUM' or - semaitem-col_typ eq 'N00' or - semaitem-col_typ eq 'N01' or - semaitem-col_typ eq 'N02' or - semaitem-col_typ eq 'N03' or - semaitem-col_typ eq 'N04' or - semaitem-col_typ eq 'PCT'. - set country 'DE'. - describe field type typ. - - if semaitem-col_cur is initial. - if typ ne 'F'. - write to contentsitem-value no-grouping - no-sign decimals 14. - else. - write to contentsitem-value no-grouping - no-sign. - endif. - else. -* Treat of fixed curreny for column >>Y9CK007319 - if semaitem-col_cur < 0. - semaitem-col_cur = semaitem-col_cur * ( -1 ). - select * from tcurx into table lt_tcurx. - sort lt_tcurx. - read table lt_tcurx into - wa_tcurx index semaitem-col_cur. - if sy-subrc = 0. - if typ ne 'F'. - write to contentsitem-value no-grouping - currency wa_tcurx-currkey no-sign decimals 14. - else. - write to contentsitem-value no-grouping - currency wa_tcurx-currkey no-sign. - endif. - endif. - else. - assign component semaitem-col_cur - of structure to . + assign component SEMAITEM-COL_CUR + of structure to . * mit = index of recent row - curritem-top = rowmax + mit + li_commentary_rows. + CURRITEM-TOP = ROWMAX + MIT + LI_COMMENTARY_ROWS. - li_col_pos = sy-index + i_left - 1. - curritem-left = li_col_pos. + LI_COL_POS = SY-INDEX + I_LEFT - 1. + CURRITEM-LEFT = LI_COL_POS. * if filed is quantity field (qfieldname ne space) * or amount field (cfieldname ne space), then format decimal place * corresponding with config - clear: l_def. - read table LT_FIELDCAT_KKBLO assigning - with key tabname = l_tabname - tech = space - no_out = space - col_pos = semaitem-col_no. - IF sy-subrc = 0. - IF -cfieldname is not initial. - l_def = 'C'. - else."if -qfieldname is not initial. - l_def = 'Q'. - ENDIF. - ENDIF. + clear: L_DEF. + read table LT_FIELDCAT_KKBLO assigning + with key TABNAME = L_TABNAME + TECH = SPACE + NO_OUT = SPACE + COL_POS = SEMAITEM-COL_NO. + if SY-SUBRC = 0. + if -CFIELDNAME is not initial. + L_DEF = 'C'. + else."if -qfieldname is not initial. + L_DEF = 'Q'. + endif. + endif. * if field is amount field * exporting of amount field base on currency decimal table: TCURX - IF l_def = 'C'. "field is amount field - select single * from tcurx into wa_tcurx - where currkey = . + if L_DEF = 'C'. "field is amount field + select single * from TCURX into WA_TCURX + where CURRKEY = . * if amount ref to un-know currency -> default decimal = 2 - if sy-subrc eq 0. - curritem-decimals = wa_tcurx-currdec. - else. - curritem-decimals = 2. - endif. + if SY-SUBRC eq 0. + CURRITEM-DECIMALS = WA_TCURX-CURRDEC. + else. + CURRITEM-DECIMALS = 2. + endif. - append curritem to currcells. - if typ ne 'F'. - write to contentsitem-value - currency - no-sign no-grouping. - else. - write to contentsitem-value - decimals 14 currency - no-sign no-grouping. - endif. + append CURRITEM to CURRCELLS. + if TYP ne 'F'. + write to CONTENTSITEM-VALUE + currency + no-sign no-grouping. + else. + write to CONTENTSITEM-VALUE + decimals 14 currency + no-sign no-grouping. + endif. * if field is quantity field * exporting of quantity field base on quantity decimal table: T006 - else."if l_def = 'Q'. " field is quantity field - clear: wa_t006. - select single * from t006 into wa_t006 - where MSEHI = . + else."if l_def = 'Q'. " field is quantity field + clear: WA_T006. + select single * from T006 into WA_T006 + where MSEHI = . * if quantity ref to un-know unit-> default decimal = 2 - if sy-subrc eq 0. - curritem-decimals = wa_t006-decan. - else. - curritem-decimals = 2. + if SY-SUBRC eq 0. + CURRITEM-DECIMALS = WA_T006-DECAN. + else. + CURRITEM-DECIMALS = 2. + endif. + append CURRITEM to CURRCELLS. + + write to CONTENTSITEM-VALUE + unit + no-sign no-grouping. + condense CONTENTSITEM-VALUE. + endif. - append curritem to currcells. - write to contentsitem-value - unit - no-sign no-grouping. - condense contentsitem-value. - - ENDIF. - - endif. "Y9CK007319 - endif. - condense contentsitem-value. + endif. "Y9CK007319 + endif. + condense CONTENTSITEM-VALUE. * add function fieldcat-no zero display - loop at LT_FIELDCAT_KKBLO assigning - where tabname = l_tabname - and tech ne 'X' - and no_out ne 'X'. - if -col_pos = semaitem-col_no. - if -no_zero = 'X'. - if = '0'. - clear: contentsitem-value. - endif. + loop at LT_FIELDCAT_KKBLO assigning + where TABNAME = L_TABNAME + and TECH ne 'X' + and NO_OUT ne 'X'. + if -COL_POS = SEMAITEM-COL_NO. + if -NO_ZERO = 'X'. + if = '0'. + clear: CONTENTSITEM-VALUE. + endif. * dun display zero in total/subtotal line too - else. - clear: wa_subtot_indexs. - read table lt_subtot_indexs into wa_subtot_indexs - with key index = l_save_index. - IF sy-subrc = 0 AND = '0'. - clear: contentsitem-value. - ENDIF. + else. + clear: WA_SUBTOT_INDEXS. + read table LT_SUBTOT_INDEXS into WA_SUBTOT_INDEXS + with key INDEX = L_SAVE_INDEX. + if SY-SUBRC = 0 and = '0'. + clear: CONTENTSITEM-VALUE. + endif. + endif. endif. - endif. - endloop. - unassign: . + endloop. + unassign: . - if lt 0. - search contentsitem-value for 'E'. - if sy-fdpos eq 0. + if lt 0. + search CONTENTSITEM-VALUE for 'E'. + if SY-FDPOS eq 0. * use prefix notation for signed numbers - translate contentsitem-value using '- '. - condense contentsitem-value no-gaps. - concatenate '-' contentsitem-value - into contentsitem-value. - else. - concatenate '-' contentsitem-value - into contentsitem-value. + translate CONTENTSITEM-VALUE using '- '. + condense CONTENTSITEM-VALUE no-gaps. + concatenate '-' CONTENTSITEM-VALUE + into CONTENTSITEM-VALUE. + else. + concatenate '-' CONTENTSITEM-VALUE + into CONTENTSITEM-VALUE. + endif. endif. - endif. - set country space. + set country SPACE. * Hier wird nur die korrekte Kommaseparatierung gemacht, wenn die * Zeichen einer * Zahl enthalten sind. Das ist für Timestamps, die auch ":" enthalten. * Für die * darf keine Kommaseparierung stattfinden. * Changing for correction request - Y6BK041073 - if contentsitem-value co '0123456789.,-+E '. - translate contentsitem-value using comma_elim. - endif. - else. - clear contentsitem-value. + if CONTENTSITEM-VALUE co '0123456789.,-+E '. + translate CONTENTSITEM-VALUE using COMMA_ELIM. + endif. + else. + clear CONTENTSITEM-VALUE. * if type is not numeric -> dun display with zero - write to contentsitem-value no-zero. + write to CONTENTSITEM-VALUE no-zero. - shift contentsitem-value left deleting leading space. + shift CONTENTSITEM-VALUE left deleting leading SPACE. + endif. + append CONTENTSITEM to CONTENTS. endif. - append contentsitem to contents. - endif. - enddo. + enddo. - realmit = realmit + 1. - realoverflow = realoverflow + 1. + REALMIT = REALMIT + 1. + REALOVERFLOW = REALOVERFLOW + 1. - mit = mit + 1. + MIT = MIT + 1. * overflow = current row index in content table - overflow = overflow + 1. - endloop. + OVERFLOW = OVERFLOW + 1. + endloop. - unassign: . + unassign: . * set item range for set_range_data method - testname = mit / const. - condense testname. + TESTNAME = MIT / CONST. + condense TESTNAME. - concatenate 'TEST' testname into testname. + concatenate 'TEST' TESTNAME into TESTNAME. - realoverflow = realoverflow - 1. - realmit = realmit - 1. - help = realoverflow. + REALOVERFLOW = REALOVERFLOW - 1. + REALMIT = REALMIT - 1. + HELP = REALOVERFLOW. - rangeitem-name = testname. - rangeitem-columns = datareal. - rangeitem-rows = help. - append rangeitem to ranges. + RANGEITEM-NAME = TESTNAME. + RANGEITEM-COLUMNS = DATAREAL. + RANGEITEM-ROWS = HELP. + append RANGEITEM to RANGES. * insert item range dim - temp2 = rowmax + 1 + li_commentary_rows + realmit - realoverflow. + TEMP2 = ROWMAX + 1 + LI_COMMENTARY_ROWS + REALMIT - REALOVERFLOW. * items data - call method lo_spreadsheet->insert_range_dim - EXPORTING - name = testname - top = temp2 - left = i_left - rows = help - columns = datareal - no_flush = no_flush. + call method LO_SPREADSHEET->INSERT_RANGE_DIM + exporting + NAME = TESTNAME + TOP = TEMP2 + LEFT = I_LEFT + ROWS = HELP + COLUMNS = DATAREAL + NO_FLUSH = NO_FLUSH. * get columns header contents for set_range_data method * export columns header only if no columns header option = space - data: rowcount type i. - data: columncount type i. + data: ROWCOUNT type I. + data: COLUMNCOUNT type I. - if i_columns_header = 'X'. + if I_COLUMNS_HEADER = 'X'. * append columns header to contents: hkey - rowcount = 1. - do rowmax times. - columncount = 1. - do hkeycolumns times. - loop at lt_hkey into hkeyitem where col_no = columncount - and row_no = rowcount. - endloop. - if sy-subrc = 0. - str = hkeyitem-col_name. - contentsitem-value = hkeyitem-col_name. - else. - contentsitem-value = str. - endif. - contentsitem-column = columncount. - contentsitem-row = rowcount. - append contentsitem to contents. - columncount = columncount + 1. + ROWCOUNT = 1. + do ROWMAX times. + COLUMNCOUNT = 1. + do HKEYCOLUMNS times. + loop at LT_HKEY into HKEYITEM where COL_NO = COLUMNCOUNT + and ROW_NO = ROWCOUNT. + endloop. + if SY-SUBRC = 0. + STR = HKEYITEM-COL_NAME. + CONTENTSITEM-VALUE = HKEYITEM-COL_NAME. + else. + CONTENTSITEM-VALUE = STR. + endif. + CONTENTSITEM-COLUMN = COLUMNCOUNT. + CONTENTSITEM-ROW = ROWCOUNT. + append CONTENTSITEM to CONTENTS. + COLUMNCOUNT = COLUMNCOUNT + 1. + enddo. + ROWCOUNT = ROWCOUNT + 1. enddo. - rowcount = rowcount + 1. - enddo. * incase columns header in multiline - data: rowmaxtemp type i. - if rowmax > 1. - rowmaxtemp = rowmax - 1. - rowcount = 1. - do rowmaxtemp times. - columncount = 1. - do columnmax times. - contentsitem-column = columncount. - contentsitem-row = rowcount. - contentsitem-value = ''. - append contentsitem to contents. - columncount = columncount + 1. + data: ROWMAXTEMP type I. + if ROWMAX > 1. + ROWMAXTEMP = ROWMAX - 1. + ROWCOUNT = 1. + do ROWMAXTEMP times. + COLUMNCOUNT = 1. + do COLUMNMAX times. + CONTENTSITEM-COLUMN = COLUMNCOUNT. + CONTENTSITEM-ROW = ROWCOUNT. + CONTENTSITEM-VALUE = ''. + append CONTENTSITEM to CONTENTS. + COLUMNCOUNT = COLUMNCOUNT + 1. + enddo. + ROWCOUNT = ROWCOUNT + 1. enddo. - rowcount = rowcount + 1. - enddo. - endif. + endif. * append columns header to contents: vkey - columncount = 1. - do columnmax times. - loop at lt_vkey into vkeyitem where col_no = columncount. - endloop. - contentsitem-value = vkeyitem-col_name. - contentsitem-row = rowmax. - contentsitem-column = columncount. - append contentsitem to contents. - columncount = columncount + 1. - enddo. + COLUMNCOUNT = 1. + do COLUMNMAX times. + loop at LT_VKEY into VKEYITEM where COL_NO = COLUMNCOUNT. + endloop. + CONTENTSITEM-VALUE = VKEYITEM-COL_NAME. + CONTENTSITEM-ROW = ROWMAX. + CONTENTSITEM-COLUMN = COLUMNCOUNT. + append CONTENTSITEM to CONTENTS. + COLUMNCOUNT = COLUMNCOUNT + 1. + enddo. *--------------------------------------------------------------------* * set header range for method set_range_data * insert header keys range dim - li_head_top = li_commentary_rows + 1. - li_col_pos = i_left. + LI_HEAD_TOP = LI_COMMENTARY_ROWS + 1. + LI_COL_POS = I_LEFT. * insert range headers - if hkeycolumns ne 0. - rangeitem-name = 'TESTHKEY'. - rangeitem-rows = rowmax. - rangeitem-columns = hkeycolumns. - append rangeitem to ranges. - clear: rangeitem. + if HKEYCOLUMNS ne 0. + RANGEITEM-NAME = 'TESTHKEY'. + RANGEITEM-ROWS = ROWMAX. + RANGEITEM-COLUMNS = HKEYCOLUMNS. + append RANGEITEM to RANGES. + clear: RANGEITEM. - call method lo_spreadsheet->insert_range_dim - EXPORTING - name = 'TESTHKEY' - top = li_head_top - left = li_col_pos - rows = rowmax - columns = hkeycolumns - no_flush = no_flush. + call method LO_SPREADSHEET->INSERT_RANGE_DIM + exporting + NAME = 'TESTHKEY' + TOP = LI_HEAD_TOP + LEFT = LI_COL_POS + ROWS = ROWMAX + COLUMNS = HKEYCOLUMNS + NO_FLUSH = NO_FLUSH. + endif. endif. - endif. * format for columns header + total + subtotal * ------------------------------------------ - help = rowmax + realmit. " table + header lines + HELP = ROWMAX + REALMIT. " table + header lines - data: lt_format type soi_format_table. - data: wa_format like line of lt_format. - data: wa_format_temp like line of lt_format. + data: LT_FORMAT type SOI_FORMAT_TABLE. + data: WA_FORMAT like line of LT_FORMAT. + data: WA_FORMAT_TEMP like line of LT_FORMAT. - field-symbols: type any. - field-symbols: type any. + field-symbols: type ANY. + field-symbols: type ANY. * columns header format - wa_format-front = -1. - wa_format-back = 15. "grey - wa_format-font = space. - wa_format-size = -1. - wa_format-bold = 1. - wa_format-align = 0. - wa_format-frametyp = -1. - wa_format-framecolor = -1. + WA_FORMAT-FRONT = -1. + WA_FORMAT-BACK = 15. "grey + WA_FORMAT-FONT = SPACE. + WA_FORMAT-SIZE = -1. + WA_FORMAT-BOLD = 1. + WA_FORMAT-ALIGN = 0. + WA_FORMAT-FRAMETYP = -1. + WA_FORMAT-FRAMECOLOR = -1. * get column header format from input record * -> map input format - if i_columns_header = 'X'. - wa_format-name = 'TESTHKEY'. - if i_format_col_header is not initial. - describe field i_format_col_header type l_typ components - li_col_num. - do li_col_num times. - if sy-index ne 1. " dun map range name - assign component sy-index of structure i_format_col_header - to . - if is not initial. - assign component sy-index of structure wa_format to . - = . - unassign: . + if I_COLUMNS_HEADER = 'X'. + WA_FORMAT-NAME = 'TESTHKEY'. + if I_FORMAT_COL_HEADER is not initial. + describe field I_FORMAT_COL_HEADER type L_TYP components + LI_COL_NUM. + do LI_COL_NUM times. + if SY-INDEX ne 1. " dun map range name + assign component SY-INDEX of structure I_FORMAT_COL_HEADER + to . + if is not initial. + assign component SY-INDEX of structure WA_FORMAT to . + = . + unassign: . + endif. + unassign: . endif. - unassign: . - endif. - enddo. + enddo. - clear: li_col_num. + clear: LI_COL_NUM. + endif. + + append WA_FORMAT to LT_FORMAT. endif. - append wa_format to lt_format. - endif. - * Zusammenfassen der Spalten mit gleicher Nachkommastellenzahl * collect vertical cells (col) with the same number of decimal places * to increase perfomance in currency cell format - describe table currcells lines lines. - lines = lines - 1. - do lines times. - describe table currcells lines innerlines. - innerlines = innerlines - 1. - sort currcells by left top. - clear found. - do innerlines times. - read table currcells index sy-index into curritem. - counter = sy-index + 1. - read table currcells index counter into curritem2. - if curritem-left eq curritem2-left. - length = curritem-top + curritem-rows. - if length eq curritem2-top and curritem-decimals eq curritem2-decimals. - move curritem to curritem3. - curritem3-rows = curritem3-rows + curritem2-rows. - curritem-left = -1. - modify currcells index sy-index from curritem. - curritem2-left = -1. - modify currcells index counter from curritem2. - append curritem3 to currcells. - found = 'X'. + describe table CURRCELLS lines LINES. + LINES = LINES - 1. + do LINES times. + describe table CURRCELLS lines INNERLINES. + INNERLINES = INNERLINES - 1. + sort CURRCELLS by LEFT TOP. + clear FOUND. + do INNERLINES times. + read table CURRCELLS index SY-INDEX into CURRITEM. + COUNTER = SY-INDEX + 1. + read table CURRCELLS index COUNTER into CURRITEM2. + if CURRITEM-LEFT eq CURRITEM2-LEFT. + LENGTH = CURRITEM-TOP + CURRITEM-ROWS. + if LENGTH eq CURRITEM2-TOP and CURRITEM-DECIMALS eq CURRITEM2-DECIMALS. + move CURRITEM to CURRITEM3. + CURRITEM3-ROWS = CURRITEM3-ROWS + CURRITEM2-ROWS. + CURRITEM-LEFT = -1. + modify CURRCELLS index SY-INDEX from CURRITEM. + CURRITEM2-LEFT = -1. + modify CURRCELLS index COUNTER from CURRITEM2. + append CURRITEM3 to CURRCELLS. + FOUND = 'X'. + endif. endif. + enddo. + if FOUND is initial. + exit. endif. + delete CURRCELLS where LEFT = -1. enddo. - if found is initial. - exit. - endif. - delete currcells where left = -1. - enddo. * Zusammenfassen der Zeilen mit gleicher Nachkommastellenzahl * collect horizontal cells (row) with the same number of decimal places * to increase perfomance in currency cell format - describe table currcells lines lines. - lines = lines - 1. - do lines times. - describe table currcells lines innerlines. - innerlines = innerlines - 1. - sort currcells by top left. - clear found. - do innerlines times. - read table currcells index sy-index into curritem. - counter = sy-index + 1. - read table currcells index counter into curritem2. - if curritem-top eq curritem2-top and curritem-rows eq - curritem2-rows. - length = curritem-left + curritem-columns. - if length eq curritem2-left and curritem-decimals eq curritem2-decimals. - move curritem to curritem3. - curritem3-columns = curritem3-columns + curritem2-columns. - curritem-left = -1. - modify currcells index sy-index from curritem. - curritem2-left = -1. - modify currcells index counter from curritem2. - append curritem3 to currcells. - found = 'X'. + describe table CURRCELLS lines LINES. + LINES = LINES - 1. + do LINES times. + describe table CURRCELLS lines INNERLINES. + INNERLINES = INNERLINES - 1. + sort CURRCELLS by TOP LEFT. + clear FOUND. + do INNERLINES times. + read table CURRCELLS index SY-INDEX into CURRITEM. + COUNTER = SY-INDEX + 1. + read table CURRCELLS index COUNTER into CURRITEM2. + if CURRITEM-TOP eq CURRITEM2-TOP and CURRITEM-ROWS eq + CURRITEM2-ROWS. + LENGTH = CURRITEM-LEFT + CURRITEM-COLUMNS. + if LENGTH eq CURRITEM2-LEFT and CURRITEM-DECIMALS eq CURRITEM2-DECIMALS. + move CURRITEM to CURRITEM3. + CURRITEM3-COLUMNS = CURRITEM3-COLUMNS + CURRITEM2-COLUMNS. + CURRITEM-LEFT = -1. + modify CURRCELLS index SY-INDEX from CURRITEM. + CURRITEM2-LEFT = -1. + modify CURRCELLS index COUNTER from CURRITEM2. + append CURRITEM3 to CURRCELLS. + FOUND = 'X'. + endif. endif. + enddo. + if FOUND is initial. + exit. endif. + delete CURRCELLS where LEFT = -1. enddo. - if found is initial. - exit. - endif. - delete currcells where left = -1. - enddo. * Ende der Zusammenfassung * item data: format for currency cell, corresponding with currency - call method lo_spreadsheet->cell_format - EXPORTING - cells = currcells - no_flush = no_flush. + call method LO_SPREADSHEET->CELL_FORMAT + exporting + CELLS = CURRCELLS + NO_FLUSH = NO_FLUSH. * item data: write item table content - call method lo_spreadsheet->set_ranges_data - EXPORTING - ranges = ranges - contents = contents - no_flush = no_flush. + call method LO_SPREADSHEET->SET_RANGES_DATA + exporting + RANGES = RANGES + CONTENTS = CONTENTS + NO_FLUSH = NO_FLUSH. * whole table range to format all table - if i_columns_header = 'X'. - li_head_top = li_commentary_rows + 1. - else. - li_head_top = li_commentary_rows + 2. - help = help - 1. - endif. + if I_COLUMNS_HEADER = 'X'. + LI_HEAD_TOP = LI_COMMENTARY_ROWS + 1. + else. + LI_HEAD_TOP = LI_COMMENTARY_ROWS + 2. + HELP = HELP - 1. + endif. - call method lo_spreadsheet->insert_range_dim - EXPORTING - name = 'WHOLE_TABLE' - top = li_head_top - left = i_left - rows = help - columns = datareal - no_flush = no_flush. + call method LO_SPREADSHEET->INSERT_RANGE_DIM + exporting + NAME = 'WHOLE_TABLE' + TOP = LI_HEAD_TOP + LEFT = I_LEFT + ROWS = HELP + COLUMNS = DATAREAL + NO_FLUSH = NO_FLUSH. * columns width auto fix * this parameter = space in case use with exist template - IF i_columns_autofit = 'X'. - call method lo_spreadsheet->fit_widest - EXPORTING - name = 'WHOLE_TABLE' - no_flush = no_flush. - ENDIF. + if I_COLUMNS_AUTOFIT = 'X'. + call method LO_SPREADSHEET->FIT_WIDEST + exporting + NAME = 'WHOLE_TABLE' + NO_FLUSH = NO_FLUSH. + endif. * frame * The parameter has 8 bits @@ -2543,171 +2543,171 @@ method BIND_ALV_OLE2. * ( final DOI method call, set no_flush = space * equal to call method CL_GUI_CFW=>FLUSH ) - call method lo_spreadsheet->set_frame - EXPORTING - rangename = 'WHOLE_TABLE' - typ = 127 - color = 1 - no_flush = space - IMPORTING - error = lo_error - retcode = lc_retcode. + call method LO_SPREADSHEET->SET_FRAME + exporting + RANGENAME = 'WHOLE_TABLE' + TYP = 127 + COLOR = 1 + NO_FLUSH = SPACE + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE. - error_doi. + ERROR_DOI. * reformat subtotal / total line after format wholw table - loop at subranges into subrangeitem. - l_sub_index = subrangeitem-rows + li_commentary_rows + rowmax. + loop at SUBRANGES into SUBRANGEITEM. + L_SUB_INDEX = SUBRANGEITEM-ROWS + LI_COMMENTARY_ROWS + ROWMAX. - call method lo_spreadsheet->insert_range_dim - EXPORTING - name = subrangeitem-name - left = i_left - top = l_sub_index - rows = 1 - columns = datareal - no_flush = no_flush. + call method LO_SPREADSHEET->INSERT_RANGE_DIM + exporting + NAME = SUBRANGEITEM-NAME + LEFT = I_LEFT + TOP = L_SUB_INDEX + ROWS = 1 + COLUMNS = DATAREAL + NO_FLUSH = NO_FLUSH. - wa_format-name = subrangeitem-name. + WA_FORMAT-NAME = SUBRANGEITEM-NAME. * default format: * - clolor: subtotal = light yellow, subtotal = yellow * - frame: box - IF subrangeitem-name(3) = 'SUB'. - wa_format-back = 36. "subtotal line - wa_format_temp = i_format_subtotal. - else. - wa_format-back = 27. "total line - wa_format_temp = i_format_total. - endif. - wa_format-FRAMETYP = 79. - wa_format-FRAMEcolor = 1. - wa_format-number = -1. - wa_format-align = -1. + if SUBRANGEITEM-NAME(3) = 'SUB'. + WA_FORMAT-BACK = 36. "subtotal line + WA_FORMAT_TEMP = I_FORMAT_SUBTOTAL. + else. + WA_FORMAT-BACK = 27. "total line + WA_FORMAT_TEMP = I_FORMAT_TOTAL. + endif. + WA_FORMAT-FRAMETYP = 79. + WA_FORMAT-FRAMECOLOR = 1. + WA_FORMAT-NUMBER = -1. + WA_FORMAT-ALIGN = -1. * get subtoal + total format from intput parameter * overwrite default format - if wa_format_temp is not initial. - describe field wa_format_temp type l_typ components li_col_num. - do li_col_num times. - if sy-index ne 1. " dun map range name - assign component sy-index of structure wa_format_temp - to . - if is not initial. - assign component sy-index of structure wa_format to . - = . - unassign: . + if WA_FORMAT_TEMP is not initial. + describe field WA_FORMAT_TEMP type L_TYP components LI_COL_NUM. + do LI_COL_NUM times. + if SY-INDEX ne 1. " dun map range name + assign component SY-INDEX of structure WA_FORMAT_TEMP + to . + if is not initial. + assign component SY-INDEX of structure WA_FORMAT to . + = . + unassign: . + endif. + unassign: . endif. - unassign: . - endif. - enddo. + enddo. - clear: li_col_num. + clear: LI_COL_NUM. + endif. + + append WA_FORMAT to LT_FORMAT. + clear: WA_FORMAT-NAME. + clear: L_SUB_INDEX. + clear: WA_FORMAT_TEMP. + + endloop. + + if LT_FORMAT[] is not initial. + call method LO_SPREADSHEET->SET_RANGES_FORMAT + exporting + FORMATTABLE = LT_FORMAT + NO_FLUSH = NO_FLUSH. + refresh: LT_FORMAT. endif. - - append wa_format to lt_format. - clear: wa_format-name. - clear: l_sub_index. - clear: wa_format_temp. - - endloop. - - if lt_format[] is not initial. - call method lo_spreadsheet->set_ranges_format - EXPORTING - formattable = lt_format - no_flush = no_flush. - refresh: lt_format. - endif. *--------------------------------------------------------------------* - call method lo_spreadsheet->screen_update - EXPORTING - updating = 'X'. + call method LO_SPREADSHEET->SCREEN_UPDATE + exporting + UPDATING = 'X'. - call method c_oi_errors=>flush_errors. + call method C_OI_ERRORS=>FLUSH_ERRORS. - lo_error_w = l_error. - lc_retcode = lo_error_w->error_code. + LO_ERROR_W = L_ERROR. + LC_RETCODE = LO_ERROR_W->ERROR_CODE. ** catch no_flush -> led to dump ( optional ) * go_error = l_error. * gc_retcode = go_error->error_code. * error_doi. - clear: - lt_sema, - wa_sema, - lt_hkey, - wa_hkey, - lt_vkey, - wa_vkey, - l_n_hrz_keys, - l_n_att_cols, - l_n_vrt_keys, - count, - datac, - datareal, - vkeycount, - all, - mit, - li_col_pos, - li_col_num, - ranges, - rangeitem, - contents, - contentsitem, - semaitem, - hkeyitem, - vkeyitem, - li_commentary_rows, - l_retcode, - li_head_top, - . + clear: + LT_SEMA, + WA_SEMA, + LT_HKEY, + WA_HKEY, + LT_VKEY, + WA_VKEY, + L_N_HRZ_KEYS, + L_N_ATT_COLS, + L_N_VRT_KEYS, + COUNT, + DATAC, + DATAREAL, + VKEYCOUNT, + ALL, + MIT, + LI_COL_POS, + LI_COL_NUM, + RANGES, + RANGEITEM, + CONTENTS, + CONTENTSITEM, + SEMAITEM, + HKEYITEM, + VKEYITEM, + LI_COMMENTARY_ROWS, + L_RETCODE, + LI_HEAD_TOP, + . - clear: - lo_error_w. + clear: + LO_ERROR_W. - unassign: - , - , - . + unassign: + , + , + . *--------------------------------------------------------------------* * SESSION 5: SAVE AND CLOSE FILE *--------------------------------------------------------------------* * ex of save path: 'FILE://C:\temp\test.xlsx' - concatenate 'FILE://' I_save_path - into ls_path. + concatenate 'FILE://' I_SAVE_PATH + into LS_PATH. - call method lo_proxy->save_document_to_url - EXPORTING - no_flush = 'X' - url = ls_path - IMPORTING - error = lo_error - retcode = lc_retcode - CHANGING - document_size = li_document_size. + call method LO_PROXY->SAVE_DOCUMENT_TO_URL + exporting + NO_FLUSH = 'X' + URL = LS_PATH + importing + ERROR = LO_ERROR + RETCODE = LC_RETCODE + changing + DOCUMENT_SIZE = LI_DOCUMENT_SIZE. - error_doi. + ERROR_DOI. * if save successfully -> raise successful message * message i499(sy) with 'Document is Exported to ' p_path. - message i499(sy) with 'Data has been exported successfully'. + message I499(SY) with 'Data has been exported successfully'. - clear: - ls_path, - li_document_size. + clear: + LS_PATH, + LI_DOCUMENT_SIZE. - close_document. + CLOSE_DOCUMENT. endmethod. -METHOD bind_table. + method BIND_TABLE. *--------------------------------------------------------------------* * issue #230 - Pimp my Code * - Stefan Schmöcker, (wi p) 2012-12-01 @@ -2720,312 +2720,312 @@ METHOD bind_table. * changes: - Added raise if overlaps are detected *--------------------------------------------------------------------* - CONSTANTS: - lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'A', - lc_top_left_row TYPE zexcel_cell_row VALUE 1. + constants: + LC_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA value 'A', + LC_TOP_LEFT_ROW type ZEXCEL_CELL_ROW value 1. - DATA: - lv_row_int TYPE zexcel_cell_row, - lv_first_row TYPE zexcel_cell_row, - lv_last_row TYPE zexcel_cell_row, - lv_column_int TYPE zexcel_cell_column, - lv_column_alpha TYPE zexcel_cell_column_alpha, - lt_field_catalog TYPE zexcel_t_fieldcatalog, - lv_id TYPE i, - lv_rows TYPE i, - lv_formula TYPE string, - ls_settings TYPE zexcel_s_table_settings, - lo_table TYPE REF TO zcl_excel_table, - lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line, - lv_value TYPE string, - lv_value_lowercase TYPE string, - lv_syindex TYPE char3, - lv_errormessage TYPE string, "ins issue #237 + data: + LV_ROW_INT type ZEXCEL_CELL_ROW, + LV_FIRST_ROW type ZEXCEL_CELL_ROW, + LV_LAST_ROW type ZEXCEL_CELL_ROW, + LV_COLUMN_INT type ZEXCEL_CELL_COLUMN, + LV_COLUMN_ALPHA type ZEXCEL_CELL_COLUMN_ALPHA, + LT_FIELD_CATALOG type ZEXCEL_T_FIELDCATALOG, + LV_ID type I, + LV_ROWS type I, + LV_FORMULA type STRING, + LS_SETTINGS type ZEXCEL_S_TABLE_SETTINGS, + LO_TABLE type ref to ZCL_EXCEL_TABLE, + LT_COLUMN_NAME_BUFFER type sorted table of STRING with unique key TABLE_LINE, + LV_VALUE type STRING, + LV_VALUE_LOWERCASE type STRING, + LV_SYINDEX type CHAR3, + LV_ERRORMESSAGE type STRING, "ins issue #237 - lv_columns TYPE i, - lt_columns TYPE zexcel_t_fieldcatalog, - lv_maxcol TYPE i, - lv_maxrow TYPE i, - lo_iterator TYPE REF TO cl_object_collection_iterator, - lo_style_cond TYPE REF TO zcl_excel_style_cond, - lo_curtable TYPE REF TO zcl_excel_table. + LV_COLUMNS type I, + LT_COLUMNS type ZEXCEL_T_FIELDCATALOG, + LV_MAXCOL type I, + LV_MAXROW type I, + LO_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_STYLE_COND type ref to ZCL_EXCEL_STYLE_COND, + LO_CURTABLE type ref to ZCL_EXCEL_TABLE. - FIELD-SYMBOLS: - TYPE zexcel_s_fieldcatalog, - TYPE zexcel_s_fieldcatalog, - TYPE any, - TYPE any. + field-symbols: + type ZEXCEL_S_FIELDCATALOG, + type ZEXCEL_S_FIELDCATALOG, + type ANY, + type ANY. - ls_settings = is_table_settings. + LS_SETTINGS = IS_TABLE_SETTINGS. - IF ls_settings-top_left_column IS INITIAL. - ls_settings-top_left_column = lc_top_left_column. - ENDIF. + if LS_SETTINGS-TOP_LEFT_COLUMN is initial. + LS_SETTINGS-TOP_LEFT_COLUMN = LC_TOP_LEFT_COLUMN. + endif. - IF ls_settings-table_style IS INITIAL. - ls_settings-table_style = zcl_excel_table=>builtinstyle_medium2. - ENDIF. + if LS_SETTINGS-TABLE_STYLE is initial. + LS_SETTINGS-TABLE_STYLE = ZCL_EXCEL_TABLE=>BUILTINSTYLE_MEDIUM2. + endif. - IF ls_settings-top_left_row IS INITIAL. - ls_settings-top_left_row = lc_top_left_row. - ENDIF. + if LS_SETTINGS-TOP_LEFT_ROW is initial. + LS_SETTINGS-TOP_LEFT_ROW = LC_TOP_LEFT_ROW. + endif. - IF it_field_catalog IS NOT SUPPLIED. - lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = ip_table ). - ELSE. - lt_field_catalog = it_field_catalog. - ENDIF. + if IT_FIELD_CATALOG is not supplied. + LT_FIELD_CATALOG = ZCL_EXCEL_COMMON=>GET_FIELDCATALOG( IP_TABLE = IP_TABLE ). + else. + LT_FIELD_CATALOG = IT_FIELD_CATALOG. + endif. - SORT lt_field_catalog BY position. + sort LT_FIELD_CATALOG by POSITION. *--------------------------------------------------------------------* * issue #237 Check if overlapping areas exist Start *--------------------------------------------------------------------* - "Get the number of columns for the current table - lt_columns = lt_field_catalog. - DELETE lt_columns WHERE dynpfld NE abap_true. - DESCRIBE TABLE lt_columns LINES lv_columns. + "Get the number of columns for the current table + LT_COLUMNS = LT_FIELD_CATALOG. + delete LT_COLUMNS where DYNPFLD ne ABAP_TRUE. + describe table LT_COLUMNS lines LV_COLUMNS. - "Calculate the top left row of the current table - lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ). - lv_row_int = ls_settings-top_left_row. + "Calculate the top left row of the current table + LV_COLUMN_INT = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LS_SETTINGS-TOP_LEFT_COLUMN ). + LV_ROW_INT = LS_SETTINGS-TOP_LEFT_ROW. - "Get number of row for the current table - DESCRIBE TABLE ip_table LINES lv_rows. + "Get number of row for the current table + describe table IP_TABLE lines LV_ROWS. - "Calculate the bottom right row for the current table - lv_maxcol = lv_column_int + lv_columns - 1. - lv_maxrow = lv_row_int + lv_rows - 1. - ls_settings-bottom_right_column = zcl_excel_common=>convert_column2alpha( lv_maxcol ). - ls_settings-bottom_right_row = lv_maxrow. + "Calculate the bottom right row for the current table + LV_MAXCOL = LV_COLUMN_INT + LV_COLUMNS - 1. + LV_MAXROW = LV_ROW_INT + LV_ROWS - 1. + LS_SETTINGS-BOTTOM_RIGHT_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( LV_MAXCOL ). + LS_SETTINGS-BOTTOM_RIGHT_ROW = LV_MAXROW. - lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ). + LV_COLUMN_INT = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LS_SETTINGS-TOP_LEFT_COLUMN ). - lo_iterator = me->tables->if_object_collection~get_iterator( ). - WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + LO_ITERATOR = ME->TABLES->IF_OBJECT_COLLECTION~GET_ITERATOR( ). + while LO_ITERATOR->IF_OBJECT_COLLECTION_ITERATOR~HAS_NEXT( ) eq ABAP_TRUE. - lo_curtable ?= lo_iterator->if_object_collection_iterator~get_next( ). - IF ( ( ls_settings-top_left_row GE lo_curtable->settings-top_left_row AND ls_settings-top_left_row LE lo_curtable->settings-bottom_right_row ) - OR - ( ls_settings-bottom_right_row GE lo_curtable->settings-top_left_row AND ls_settings-bottom_right_row LE lo_curtable->settings-bottom_right_row ) - ) - AND - ( ( lv_column_int GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_column_int LE zcl_excel_common=>convert_column2int( lo_curtable->settings-bottom_right_column ) ) - OR - ( lv_maxcol GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_maxcol LE zcl_excel_common=>convert_column2int( lo_curtable->settings-bottom_right_column ) ) - ). - lv_errormessage = 'Table overlaps with previously bound table and will not be added to worksheet.'(400). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + LO_CURTABLE ?= LO_ITERATOR->IF_OBJECT_COLLECTION_ITERATOR~GET_NEXT( ). + if ( ( LS_SETTINGS-TOP_LEFT_ROW ge LO_CURTABLE->SETTINGS-TOP_LEFT_ROW and LS_SETTINGS-TOP_LEFT_ROW le LO_CURTABLE->SETTINGS-BOTTOM_RIGHT_ROW ) + or + ( LS_SETTINGS-BOTTOM_RIGHT_ROW ge LO_CURTABLE->SETTINGS-TOP_LEFT_ROW and LS_SETTINGS-BOTTOM_RIGHT_ROW le LO_CURTABLE->SETTINGS-BOTTOM_RIGHT_ROW ) + ) + and + ( ( LV_COLUMN_INT ge ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-TOP_LEFT_COLUMN ) and LV_COLUMN_INT le ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-BOTTOM_RIGHT_COLUMN ) ) + or + ( LV_MAXCOL ge ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-TOP_LEFT_COLUMN ) and LV_MAXCOL le ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-BOTTOM_RIGHT_COLUMN ) ) + ). + LV_ERRORMESSAGE = 'Table overlaps with previously bound table and will not be added to worksheet.'(400). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - ENDWHILE. + endwhile. *--------------------------------------------------------------------* * issue #237 Check if overlapping areas exist End *--------------------------------------------------------------------* - CREATE OBJECT lo_table. - lo_table->settings = ls_settings. - lo_table->set_data( ir_data = ip_table ). - lv_id = me->excel->get_next_table_id( ). - lo_table->set_id( iv_id = lv_id ). + create object LO_TABLE. + LO_TABLE->SETTINGS = LS_SETTINGS. + LO_TABLE->SET_DATA( IR_DATA = IP_TABLE ). + LV_ID = ME->EXCEL->GET_NEXT_TABLE_ID( ). + LO_TABLE->SET_ID( IV_ID = LV_ID ). * lo_table->fieldcat = lt_field_catalog[]. - me->tables->add( lo_table ). + ME->TABLES->ADD( LO_TABLE ). * It is better to loop column by column (only visible column) - LOOP AT lt_field_catalog ASSIGNING WHERE dynpfld EQ abap_true. + loop at LT_FIELD_CATALOG assigning where DYNPFLD eq ABAP_TRUE. - lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + LV_COLUMN_ALPHA = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( LV_COLUMN_INT ). - " Due restrinction of new table object we cannot have two column with the same name - " Check if a column with the same name exists, if exists add a counter - " If no medium description is provided we try to use small or long + " Due restrinction of new table object we cannot have two column with the same name + " Check if a column with the same name exists, if exists add a counter + " If no medium description is provided we try to use small or long * lv_value = -scrtext_m. - FIELD-SYMBOLS: TYPE any, - TYPE any, - TYPE any. + field-symbols: type ANY, + type ANY, + type ANY. - CASE iv_default_descr. - WHEN 'M'. - ASSIGN -scrtext_m TO . - ASSIGN -scrtext_s TO . - ASSIGN -scrtext_l TO . - WHEN 'S'. - ASSIGN -scrtext_s TO . - ASSIGN -scrtext_m TO . - ASSIGN -scrtext_l TO . - WHEN 'L'. - ASSIGN -scrtext_l TO . - ASSIGN -scrtext_m TO . - ASSIGN -scrtext_s TO . - WHEN OTHERS. - ASSIGN -scrtext_m TO . - ASSIGN -scrtext_s TO . - ASSIGN -scrtext_l TO . - ENDCASE. + case IV_DEFAULT_DESCR. + when 'M'. + assign -SCRTEXT_M to . + assign -SCRTEXT_S to . + assign -SCRTEXT_L to . + when 'S'. + assign -SCRTEXT_S to . + assign -SCRTEXT_M to . + assign -SCRTEXT_L to . + when 'L'. + assign -SCRTEXT_L to . + assign -SCRTEXT_M to . + assign -SCRTEXT_S to . + when others. + assign -SCRTEXT_M to . + assign -SCRTEXT_S to . + assign -SCRTEXT_L to . + endcase. - IF IS NOT INITIAL. - lv_value = . - -scrtext_l = lv_value. - ELSEIF IS NOT INITIAL. - lv_value = . - -scrtext_l = lv_value. - ELSEIF IS NOT INITIAL. - lv_value = . - -scrtext_l = lv_value. - ELSE. - lv_value = 'Column'. " default value as Excel does - -scrtext_l = lv_value. - ENDIF. - WHILE 1 = 1. - lv_value_lowercase = lv_value. - TRANSLATE lv_value_lowercase TO LOWER CASE. - READ TABLE lt_column_name_buffer TRANSPORTING NO FIELDS WITH KEY table_line = lv_value_lowercase BINARY SEARCH. - IF sy-subrc <> 0. - -scrtext_l = lv_value. - INSERT lv_value_lowercase INTO TABLE lt_column_name_buffer. - EXIT. - ELSE. - lv_syindex = sy-index. - CONCATENATE -scrtext_l lv_syindex INTO lv_value. - ENDIF. + if is not initial. + LV_VALUE = . + -SCRTEXT_L = LV_VALUE. + elseif is not initial. + LV_VALUE = . + -SCRTEXT_L = LV_VALUE. + elseif is not initial. + LV_VALUE = . + -SCRTEXT_L = LV_VALUE. + else. + LV_VALUE = 'Column'. " default value as Excel does + -SCRTEXT_L = LV_VALUE. + endif. + while 1 = 1. + LV_VALUE_LOWERCASE = LV_VALUE. + translate LV_VALUE_LOWERCASE to lower case. + read table LT_COLUMN_NAME_BUFFER transporting no fields with key TABLE_LINE = LV_VALUE_LOWERCASE binary search. + if SY-SUBRC <> 0. + -SCRTEXT_L = LV_VALUE. + insert LV_VALUE_LOWERCASE into table LT_COLUMN_NAME_BUFFER. + exit. + else. + LV_SYINDEX = SY-INDEX. + concatenate -SCRTEXT_L LV_SYINDEX into LV_VALUE. + endif. - ENDWHILE. - " First of all write column header - IF -style_header IS NOT INITIAL. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_value = lv_value - ip_style = -style_header ). - ELSE. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_value = lv_value ). - ENDIF. + endwhile. + " First of all write column header + if -STYLE_HEADER is not initial. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_VALUE = LV_VALUE + IP_STYLE = -STYLE_HEADER ). + else. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_VALUE = LV_VALUE ). + endif. - ADD 1 TO lv_row_int. - LOOP AT ip_table ASSIGNING . + add 1 to LV_ROW_INT. + loop at IP_TABLE assigning . - ASSIGN COMPONENT -fieldname OF STRUCTURE TO . - " issue #290 Add formula support in table - IF -formula EQ abap_true. - IF -style IS NOT INITIAL. - IF -abap_type IS NOT INITIAL. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_formula = - ip_abap_type = -abap_type - ip_style = -style ). - ELSE. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_formula = - ip_style = -style ). - ENDIF. - ELSEIF -abap_type IS NOT INITIAL. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_formula = - ip_abap_type = -abap_type ). - ELSE. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_formula = ). - ENDIF. - ELSE. - IF -style IS NOT INITIAL. - IF -abap_type IS NOT INITIAL. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_value = - ip_abap_type = -abap_type - ip_style = -style ). - ELSE. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_value = - ip_style = -style ). - ENDIF. - ELSE. - IF -abap_type IS NOT INITIAL. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_abap_type = -abap_type - ip_value = ). - ELSE. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_value = ). - ENDIF. - ENDIF. - ENDIF. - ADD 1 TO lv_row_int. + assign component -FIELDNAME of structure to . + " issue #290 Add formula support in table + if -FORMULA eq ABAP_TRUE. + if -STYLE is not initial. + if -ABAP_TYPE is not initial. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_FORMULA = + IP_ABAP_TYPE = -ABAP_TYPE + IP_STYLE = -STYLE ). + else. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_FORMULA = + IP_STYLE = -STYLE ). + endif. + elseif -ABAP_TYPE is not initial. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_FORMULA = + IP_ABAP_TYPE = -ABAP_TYPE ). + else. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_FORMULA = ). + endif. + else. + if -STYLE is not initial. + if -ABAP_TYPE is not initial. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_VALUE = + IP_ABAP_TYPE = -ABAP_TYPE + IP_STYLE = -STYLE ). + else. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_VALUE = + IP_STYLE = -STYLE ). + endif. + else. + if -ABAP_TYPE is not initial. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_ABAP_TYPE = -ABAP_TYPE + IP_VALUE = ). + else. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_VALUE = ). + endif. + endif. + endif. + add 1 to LV_ROW_INT. - ENDLOOP. - IF sy-subrc <> 0. "create empty row if table has no data - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_value = space ). - ADD 1 TO lv_row_int. - ENDIF. + endloop. + if SY-SUBRC <> 0. "create empty row if table has no data + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_VALUE = SPACE ). + add 1 to LV_ROW_INT. + endif. *--------------------------------------------------------------------* - " totals + " totals *--------------------------------------------------------------------* - IF -totals_function IS NOT INITIAL. - lv_formula = lo_table->get_totals_formula( ip_column = -scrtext_l ip_function = -totals_function ). - IF -style_total IS NOT INITIAL. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_formula = lv_formula - ip_style = -style_total ). - ELSE. - me->set_cell( ip_column = lv_column_alpha - ip_row = lv_row_int - ip_formula = lv_formula ). - ENDIF. - ENDIF. + if -TOTALS_FUNCTION is not initial. + LV_FORMULA = LO_TABLE->GET_TOTALS_FORMULA( IP_COLUMN = -SCRTEXT_L IP_FUNCTION = -TOTALS_FUNCTION ). + if -STYLE_TOTAL is not initial. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_FORMULA = LV_FORMULA + IP_STYLE = -STYLE_TOTAL ). + else. + ME->SET_CELL( IP_COLUMN = LV_COLUMN_ALPHA + IP_ROW = LV_ROW_INT + IP_FORMULA = LV_FORMULA ). + endif. + endif. - lv_row_int = ls_settings-top_left_row. - ADD 1 TO lv_column_int. + LV_ROW_INT = LS_SETTINGS-TOP_LEFT_ROW. + add 1 to LV_COLUMN_INT. *--------------------------------------------------------------------* - " conditional formatting + " conditional formatting *--------------------------------------------------------------------* - IF -style_cond IS NOT INITIAL. - lv_first_row = ls_settings-top_left_row + 1. " +1 to exclude header - lv_last_row = ls_settings-top_left_row + lv_rows. - lo_style_cond = me->get_style_cond( -style_cond ). - lo_style_cond->set_range( ip_start_column = lv_column_alpha - ip_start_row = lv_first_row - ip_stop_column = lv_column_alpha - ip_stop_row = lv_last_row ). - ENDIF. + if -STYLE_COND is not initial. + LV_FIRST_ROW = LS_SETTINGS-TOP_LEFT_ROW + 1. " +1 to exclude header + LV_LAST_ROW = LS_SETTINGS-TOP_LEFT_ROW + LV_ROWS. + LO_STYLE_COND = ME->GET_STYLE_COND( -STYLE_COND ). + LO_STYLE_COND->SET_RANGE( IP_START_COLUMN = LV_COLUMN_ALPHA + IP_START_ROW = LV_FIRST_ROW + IP_STOP_COLUMN = LV_COLUMN_ALPHA + IP_STOP_ROW = LV_LAST_ROW ). + endif. - ENDLOOP. + endloop. *--------------------------------------------------------------------* - " Set field catalog + " Set field catalog *--------------------------------------------------------------------* - lo_table->fieldcat = lt_field_catalog[]. + LO_TABLE->FIELDCAT = LT_FIELD_CATALOG[]. - es_table_settings = ls_settings. - es_table_settings-bottom_right_column = lv_column_alpha. - " >> Issue #291 - IF ip_table IS INITIAL. - es_table_settings-bottom_right_row = ls_settings-top_left_row + 2. "Last rows - ELSE. - es_table_settings-bottom_right_row = ls_settings-top_left_row + lv_rows + 1. "Last rows - ENDIF. - " << Issue #291 + ES_TABLE_SETTINGS = LS_SETTINGS. + ES_TABLE_SETTINGS-BOTTOM_RIGHT_COLUMN = LV_COLUMN_ALPHA. + " >> Issue #291 + if IP_TABLE is initial. + ES_TABLE_SETTINGS-BOTTOM_RIGHT_ROW = LS_SETTINGS-TOP_LEFT_ROW + 2. "Last rows + else. + ES_TABLE_SETTINGS-BOTTOM_RIGHT_ROW = LS_SETTINGS-TOP_LEFT_ROW + LV_ROWS + 1. "Last rows + endif. + " << Issue #291 -ENDMETHOD. + endmethod. -METHOD calculate_cell_width. + method CALCULATE_CELL_WIDTH. *--------------------------------------------------------------------* * issue #293 - Roberto Bianco * - Christian Assig 2014-03-14 @@ -3037,1134 +3037,1115 @@ METHOD calculate_cell_width. * - Add cell padding to simulate Excel behavior *--------------------------------------------------------------------* - CONSTANTS: - lc_default_font_name TYPE zexcel_style_font_name VALUE 'Calibri', "#EC NOTEXT - lc_default_font_height TYPE tdfontsize VALUE '110', - lc_excel_cell_padding TYPE float VALUE '0.75'. + constants: + LC_DEFAULT_FONT_NAME type ZEXCEL_STYLE_FONT_NAME value 'Calibri', "#EC NOTEXT + LC_DEFAULT_FONT_HEIGHT type TDFONTSIZE value '110', + LC_EXCEL_CELL_PADDING type FLOAT value '0.75'. - DATA: ld_cell_value TYPE zexcel_cell_value, - ld_current_character TYPE c LENGTH 1, - ld_style_guid TYPE zexcel_cell_style, - ls_stylemapping TYPE zexcel_s_stylemapping, - lo_table_object TYPE REF TO object, - lo_table TYPE REF TO zcl_excel_table, - ld_table_top_left_column TYPE zexcel_cell_column, - ld_table_bottom_right_column TYPE zexcel_cell_column, - ld_flag_contains_auto_filter TYPE abap_bool VALUE abap_false, - ld_flag_bold TYPE abap_bool VALUE abap_false, - ld_flag_italic TYPE abap_bool VALUE abap_false, - ld_date TYPE d, - ld_date_char TYPE c LENGTH 50, - ld_font_height TYPE tdfontsize VALUE lc_default_font_height, - lt_itcfc TYPE STANDARD TABLE OF itcfc, - ld_offset TYPE i, - ld_length TYPE i, - ld_uccp TYPE i, - ls_font_metric TYPE mty_s_font_metric, - ld_width_from_font_metrics TYPE i, - ld_font_family TYPE itcfh-tdfamily, - ld_font_name TYPE zexcel_style_font_name VALUE lc_default_font_name, - lt_font_families LIKE STANDARD TABLE OF ld_font_family, - ls_font_cache TYPE mty_s_font_cache. + data: LD_CELL_VALUE type ZEXCEL_CELL_VALUE, + LD_CURRENT_CHARACTER type C length 1, + LD_STYLE_GUID type ZEXCEL_CELL_STYLE, + LS_STYLEMAPPING type ZEXCEL_S_STYLEMAPPING, + LO_TABLE_OBJECT type ref to OBJECT, + LO_TABLE type ref to ZCL_EXCEL_TABLE, + LD_TABLE_TOP_LEFT_COLUMN type ZEXCEL_CELL_COLUMN, + LD_TABLE_BOTTOM_RIGHT_COLUMN type ZEXCEL_CELL_COLUMN, + LD_FLAG_CONTAINS_AUTO_FILTER type ABAP_BOOL value ABAP_FALSE, + LD_FLAG_BOLD type ABAP_BOOL value ABAP_FALSE, + LD_FLAG_ITALIC type ABAP_BOOL value ABAP_FALSE, + LD_DATE type D, + LD_DATE_CHAR type C length 50, + LD_FONT_HEIGHT type TDFONTSIZE value LC_DEFAULT_FONT_HEIGHT, + LT_ITCFC type standard table of ITCFC, + LD_OFFSET type I, + LD_LENGTH type I, + LD_UCCP type I, + LS_FONT_METRIC type MTY_S_FONT_METRIC, + LD_WIDTH_FROM_FONT_METRICS type I, + LD_FONT_FAMILY type ITCFH-TDFAMILY, + LD_FONT_NAME type ZEXCEL_STYLE_FONT_NAME value LC_DEFAULT_FONT_NAME, + LT_FONT_FAMILIES like standard table of LD_FONT_FAMILY, + LS_FONT_CACHE type MTY_S_FONT_CACHE. - FIELD-SYMBOLS: TYPE mty_s_font_cache, - TYPE mty_s_font_metric, - TYPE itcfc. + field-symbols: type MTY_S_FONT_CACHE, + type MTY_S_FONT_METRIC, + type ITCFC. - " Determine cell content and cell style - me->get_cell( EXPORTING ip_column = ip_column - ip_row = ip_row - IMPORTING ep_value = ld_cell_value - ep_guid = ld_style_guid ). + " Determine cell content and cell style + ME->GET_CELL( exporting IP_COLUMN = IP_COLUMN + IP_ROW = IP_ROW + importing EP_VALUE = LD_CELL_VALUE + EP_GUID = LD_STYLE_GUID ). - " ABAP2XLSX uses tables to define areas containing headers and - " auto-filters. Find out if the current cell is in the header - " of one of these tables. - LOOP AT me->tables->collection INTO lo_table_object. - " Downcast: OBJECT -> ZCL_EXCEL_TABLE - lo_table ?= lo_table_object. + " ABAP2XLSX uses tables to define areas containing headers and + " auto-filters. Find out if the current cell is in the header + " of one of these tables. + loop at ME->TABLES->COLLECTION into LO_TABLE_OBJECT. + " Downcast: OBJECT -> ZCL_EXCEL_TABLE + LO_TABLE ?= LO_TABLE_OBJECT. - " Convert column letters to corresponding integer values - ld_table_top_left_column = - zcl_excel_common=>convert_column2int( - lo_table->settings-top_left_column ). + " Convert column letters to corresponding integer values + LD_TABLE_TOP_LEFT_COLUMN = + ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( + LO_TABLE->SETTINGS-TOP_LEFT_COLUMN ). - ld_table_bottom_right_column = - zcl_excel_common=>convert_column2int( - lo_table->settings-bottom_right_column ). + LD_TABLE_BOTTOM_RIGHT_COLUMN = + ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( + LO_TABLE->SETTINGS-BOTTOM_RIGHT_COLUMN ). - " Is the current cell part of the table header? - IF ip_column BETWEEN ld_table_top_left_column AND - ld_table_bottom_right_column AND - ip_row EQ lo_table->settings-top_left_row. - " Current cell is part of the table header - " -> Assume that an auto filter is present and that the font is - " bold - ld_flag_contains_auto_filter = abap_true. - ld_flag_bold = abap_true. - ENDIF. - ENDLOOP. + " Is the current cell part of the table header? + if IP_COLUMN between LD_TABLE_TOP_LEFT_COLUMN and + LD_TABLE_BOTTOM_RIGHT_COLUMN and + IP_ROW eq LO_TABLE->SETTINGS-TOP_LEFT_ROW. + " Current cell is part of the table header + " -> Assume that an auto filter is present and that the font is + " bold + LD_FLAG_CONTAINS_AUTO_FILTER = ABAP_TRUE. + LD_FLAG_BOLD = ABAP_TRUE. + endif. + endloop. - " If a style GUID is present, read style attributes - IF ld_style_guid IS NOT INITIAL. - TRY. - " Read style attributes - ls_stylemapping = me->excel->get_style_to_guid( ld_style_guid ). + " If a style GUID is present, read style attributes + if LD_STYLE_GUID is not initial. + try. + " Read style attributes + LS_STYLEMAPPING = ME->EXCEL->GET_STYLE_TO_GUID( LD_STYLE_GUID ). - " If the current cell contains the default date format, - " convert the cell value to a date and calculate its length - IF ls_stylemapping-complete_style-number_format-format_code = - zcl_excel_style_number_format=>c_format_date_std. + " If the current cell contains the default date format, + " convert the cell value to a date and calculate its length + if LS_STYLEMAPPING-COMPLETE_STYLE-NUMBER_FORMAT-FORMAT_CODE = + ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_STD. - " Convert excel date to ABAP date - ld_date = - zcl_excel_common=>excel_string_to_date( ld_cell_value ). + " Convert excel date to ABAP date + LD_DATE = + ZCL_EXCEL_COMMON=>EXCEL_STRING_TO_DATE( LD_CELL_VALUE ). - " Format ABAP date using user's formatting settings - WRITE ld_date TO ld_date_char. + " Format ABAP date using user's formatting settings + write LD_DATE to LD_DATE_CHAR. - " Remember the formatted date to calculate the cell size - ld_cell_value = ld_date_char. + " Remember the formatted date to calculate the cell size + LD_CELL_VALUE = LD_DATE_CHAR. - ENDIF. + endif. - " Read the font size and convert it to the font height - " used by SAPscript (multiplication by 10) - IF ls_stylemapping-complete_stylex-font-size = abap_true. - ld_font_height = ls_stylemapping-complete_style-font-size * 10. - ENDIF. + " Read the font size and convert it to the font height + " used by SAPscript (multiplication by 10) + if LS_STYLEMAPPING-COMPLETE_STYLEX-FONT-SIZE = ABAP_TRUE. + LD_FONT_HEIGHT = LS_STYLEMAPPING-COMPLETE_STYLE-FONT-SIZE * 10. + endif. - " If set, remember the font name - IF ls_stylemapping-complete_stylex-font-name = abap_true. - ld_font_name = ls_stylemapping-complete_style-font-name. - ENDIF. + " If set, remember the font name + if LS_STYLEMAPPING-COMPLETE_STYLEX-FONT-NAME = ABAP_TRUE. + LD_FONT_NAME = LS_STYLEMAPPING-COMPLETE_STYLE-FONT-NAME. + endif. - " If set, remember whether font is bold and italic. - IF ls_stylemapping-complete_stylex-font-bold = abap_true. - ld_flag_bold = ls_stylemapping-complete_style-font-bold. - ENDIF. + " If set, remember whether font is bold and italic. + if LS_STYLEMAPPING-COMPLETE_STYLEX-FONT-BOLD = ABAP_TRUE. + LD_FLAG_BOLD = LS_STYLEMAPPING-COMPLETE_STYLE-FONT-BOLD. + endif. - IF ls_stylemapping-complete_stylex-font-italic = abap_true. - ld_flag_italic = ls_stylemapping-complete_style-font-italic. - ENDIF. + if LS_STYLEMAPPING-COMPLETE_STYLEX-FONT-ITALIC = ABAP_TRUE. + LD_FLAG_ITALIC = LS_STYLEMAPPING-COMPLETE_STYLE-FONT-ITALIC. + endif. - CATCH zcx_excel. "#EC NO_HANDLER - " Style GUID is present, but style was not found - " Continue with default values + catch ZCX_EXCEL. "#EC NO_HANDLER + " Style GUID is present, but style was not found + " Continue with default values - ENDTRY. - ENDIF. + endtry. + endif. - " Check if the same font (font name and font attributes) was already - " used before - READ TABLE mth_font_cache - WITH TABLE KEY - font_name = ld_font_name - font_height = ld_font_height - flag_bold = ld_flag_bold - flag_italic = ld_flag_italic - ASSIGNING . + " Check if the same font (font name and font attributes) was already + " used before + read table MTH_FONT_CACHE + with table key + FONT_NAME = LD_FONT_NAME + FONT_HEIGHT = LD_FONT_HEIGHT + FLAG_BOLD = LD_FLAG_BOLD + FLAG_ITALIC = LD_FLAG_ITALIC + assigning . - IF sy-subrc <> 0. - " Font is used for the first time - " Add the font to our local font cache - ls_font_cache-font_name = ld_font_name. - ls_font_cache-font_height = ld_font_height. - ls_font_cache-flag_bold = ld_flag_bold. - ls_font_cache-flag_italic = ld_flag_italic. - INSERT ls_font_cache INTO TABLE mth_font_cache - ASSIGNING . + if SY-SUBRC <> 0. + " Font is used for the first time + " Add the font to our local font cache + LS_FONT_CACHE-FONT_NAME = LD_FONT_NAME. + LS_FONT_CACHE-FONT_HEIGHT = LD_FONT_HEIGHT. + LS_FONT_CACHE-FLAG_BOLD = LD_FLAG_BOLD. + LS_FONT_CACHE-FLAG_ITALIC = LD_FLAG_ITALIC. + insert LS_FONT_CACHE into table MTH_FONT_CACHE + assigning . - " Determine the SAPscript font family name from the Excel - " font name - SELECT tdfamily - FROM tfo01 - INTO TABLE lt_font_families - UP TO 1 ROWS - WHERE tdtext = ld_font_name - ORDER BY PRIMARY KEY. + " Determine the SAPscript font family name from the Excel + " font name + select TDFAMILY + from TFO01 + into table LT_FONT_FAMILIES + up to 1 rows + where TDTEXT = LD_FONT_NAME + order by primary key. - " Check if a matching font family was found - " Fonts can be uploaded from TTF files using transaction SE73 - IF lines( lt_font_families ) > 0. - READ TABLE lt_font_families INDEX 1 INTO ld_font_family. + " Check if a matching font family was found + " Fonts can be uploaded from TTF files using transaction SE73 + if LINES( LT_FONT_FAMILIES ) > 0. + read table LT_FONT_FAMILIES index 1 into LD_FONT_FAMILY. - " Load font metrics (returns a table with the size of each letter - " in the font) - CALL FUNCTION 'LOAD_FONT' - EXPORTING - family = ld_font_family - height = ld_font_height - printer = 'SWIN' - bold = ld_flag_bold - italic = ld_flag_italic - TABLES - metric = lt_itcfc - EXCEPTIONS - font_family = 1 - codepage = 2 - device_type = 3 - OTHERS = 4. - IF sy-subrc <> 0. - CLEAR lt_itcfc. - ENDIF. + " Load font metrics (returns a table with the size of each letter + " in the font) + call function 'LOAD_FONT' + exporting + FAMILY = LD_FONT_FAMILY + HEIGHT = LD_FONT_HEIGHT + PRINTER = 'SWIN' + BOLD = LD_FLAG_BOLD + ITALIC = LD_FLAG_ITALIC + tables + METRIC = LT_ITCFC + exceptions + FONT_FAMILY = 1 + CODEPAGE = 2 + DEVICE_TYPE = 3 + others = 4. + if SY-SUBRC <> 0. + clear LT_ITCFC. + endif. - " For faster access, convert each character number to the actual - " character, and store the characters and their sizes in a hash - " table - LOOP AT lt_itcfc ASSIGNING . - ld_uccp = -cpcharno. - ls_font_metric-char = - cl_abap_conv_in_ce=>uccpi( ld_uccp ). - ls_font_metric-char_width = -tdcwidths. - INSERT ls_font_metric - INTO TABLE -th_font_metrics. - ENDLOOP. + " For faster access, convert each character number to the actual + " character, and store the characters and their sizes in a hash + " table + loop at LT_ITCFC assigning . + LD_UCCP = -CPCHARNO. + LS_FONT_METRIC-CHAR = + CL_ABAP_CONV_IN_CE=>UCCPI( LD_UCCP ). + LS_FONT_METRIC-CHAR_WIDTH = -TDCWIDTHS. + insert LS_FONT_METRIC + into table -TH_FONT_METRICS. + endloop. - ENDIF. - ENDIF. + endif. + endif. - " Calculate the cell width - " If available, use font metrics - IF lines( -th_font_metrics ) = 0. - " Font metrics are not available - " -> Calculate the cell width using only the font size - ld_length = strlen( ld_cell_value ). - ep_width = ld_length * ld_font_height / lc_default_font_height + lc_excel_cell_padding. + " Calculate the cell width + " If available, use font metrics + if LINES( -TH_FONT_METRICS ) = 0. + " Font metrics are not available + " -> Calculate the cell width using only the font size + LD_LENGTH = STRLEN( LD_CELL_VALUE ). + EP_WIDTH = LD_LENGTH * LD_FONT_HEIGHT / LC_DEFAULT_FONT_HEIGHT + LC_EXCEL_CELL_PADDING. - ELSE. - " Font metrics are available + else. + " Font metrics are available - " Calculate the size of the text by adding the sizes of each - " letter - ld_length = strlen( ld_cell_value ). - DO ld_length TIMES. - " Subtract 1, because the first character is at offset 0 - ld_offset = sy-index - 1. + " Calculate the size of the text by adding the sizes of each + " letter + LD_LENGTH = STRLEN( LD_CELL_VALUE ). + do LD_LENGTH times. + " Subtract 1, because the first character is at offset 0 + LD_OFFSET = SY-INDEX - 1. - " Read the current character from the cell value - ld_current_character = ld_cell_value+ld_offset(1). + " Read the current character from the cell value + LD_CURRENT_CHARACTER = LD_CELL_VALUE+LD_OFFSET(1). - " Look up the size of the current letter - READ TABLE -th_font_metrics - WITH TABLE KEY char = ld_current_character - ASSIGNING . - IF sy-subrc = 0. - " The size of the letter is known - " -> Add the actual size of the letter - ADD -char_width TO ld_width_from_font_metrics. - ELSE. - " The size of the letter is unknown - " -> Add the font height as the default letter size - ADD ld_font_height TO ld_width_from_font_metrics. - ENDIF. - ENDDO. + " Look up the size of the current letter + read table -TH_FONT_METRICS + with table key CHAR = LD_CURRENT_CHARACTER + assigning . + if SY-SUBRC = 0. + " The size of the letter is known + " -> Add the actual size of the letter + add -CHAR_WIDTH to LD_WIDTH_FROM_FONT_METRICS. + else. + " The size of the letter is unknown + " -> Add the font height as the default letter size + add LD_FONT_HEIGHT to LD_WIDTH_FROM_FONT_METRICS. + endif. + enddo. - " Add cell padding (Excel makes columns a bit wider than the space - " that is needed for the text itself) and convert unit - " (division by 100) - ep_width = ld_width_from_font_metrics / 100 + lc_excel_cell_padding. - ENDIF. + " Add cell padding (Excel makes columns a bit wider than the space + " that is needed for the text itself) and convert unit + " (division by 100) + EP_WIDTH = LD_WIDTH_FROM_FONT_METRICS / 100 + LC_EXCEL_CELL_PADDING. + endif. - " If the current cell contains an auto filter, make it a bit wider. - " The size used by the auto filter button does not depend on the font - " size. - IF ld_flag_contains_auto_filter = abap_true. - ADD 2 TO ep_width. - ENDIF. + " If the current cell contains an auto filter, make it a bit wider. + " The size used by the auto filter button does not depend on the font + " size. + if LD_FLAG_CONTAINS_AUTO_FILTER = ABAP_TRUE. + add 2 to EP_WIDTH. + endif. -ENDMETHOD. + endmethod. -METHOD calculate_column_widths. - TYPES: - BEGIN OF t_auto_size, - col_index TYPE int4, - width TYPE float, - END OF t_auto_size. - TYPES: tt_auto_size TYPE TABLE OF t_auto_size. + method CALCULATE_COLUMN_WIDTHS. + types: + begin of T_AUTO_SIZE, + COL_INDEX type INT4, + WIDTH type FLOAT, + end of T_AUTO_SIZE. + types: TT_AUTO_SIZE type table of T_AUTO_SIZE. - DATA: lo_column_iterator TYPE REF TO cl_object_collection_iterator, - lo_column TYPE REF TO zcl_excel_column. + data: LO_COLUMN_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_COLUMN type ref to ZCL_EXCEL_COLUMN. - DATA: auto_size TYPE flag. - DATA: auto_sizes TYPE tt_auto_size. - DATA: count TYPE int4. - DATA: highest_row TYPE int4. - DATA: width TYPE float. + data: AUTO_SIZE type FLAG. + data: AUTO_SIZES type TT_AUTO_SIZE. + data: COUNT type INT4. + data: HIGHEST_ROW type INT4. + data: WIDTH type FLOAT. - FIELD-SYMBOLS: LIKE LINE OF auto_sizes. + field-symbols: like line of AUTO_SIZES. - lo_column_iterator = me->get_columns_iterator( ). - WHILE lo_column_iterator->has_next( ) = abap_true. - lo_column ?= lo_column_iterator->get_next( ). - auto_size = lo_column->get_auto_size( ). - IF auto_size = abap_true. - APPEND INITIAL LINE TO auto_sizes ASSIGNING . - -col_index = lo_column->get_column_index( ). - -width = -1. - ENDIF. - ENDWHILE. + LO_COLUMN_ITERATOR = ME->GET_COLUMNS_ITERATOR( ). + while LO_COLUMN_ITERATOR->HAS_NEXT( ) = ABAP_TRUE. + LO_COLUMN ?= LO_COLUMN_ITERATOR->GET_NEXT( ). + AUTO_SIZE = LO_COLUMN->GET_AUTO_SIZE( ). + if AUTO_SIZE = ABAP_TRUE. + append initial line to AUTO_SIZES assigning . + -COL_INDEX = LO_COLUMN->GET_COLUMN_INDEX( ). + -WIDTH = -1. + endif. + endwhile. - " There is only something to do if there are some auto-size columns - IF NOT auto_sizes IS INITIAL. - highest_row = me->get_highest_row( ). - LOOP AT auto_sizes ASSIGNING . - count = 1. - WHILE count <= highest_row. + " There is only something to do if there are some auto-size columns + if not AUTO_SIZES is initial. + HIGHEST_ROW = ME->GET_HIGHEST_ROW( ). + loop at AUTO_SIZES assigning . + COUNT = 1. + while COUNT <= HIGHEST_ROW. * Do not check merged cells - IF is_cell_merged( - ip_column = -col_index - ip_row = count ) = abap_false. - width = calculate_cell_width( ip_column = -col_index " issue #155 - less restrictive typing for ip_column - ip_row = count ). - IF width > -width. - -width = width. - ENDIF. - ENDIF. - count = count + 1. - ENDWHILE. - lo_column = me->get_column( -col_index ). " issue #155 - less restrictive typing for ip_column - lo_column->set_width( -width ). - ENDLOOP. - ENDIF. + if IS_CELL_MERGED( + IP_COLUMN = -COL_INDEX + IP_ROW = COUNT ) = ABAP_FALSE. + WIDTH = CALCULATE_CELL_WIDTH( IP_COLUMN = -COL_INDEX " issue #155 - less restrictive typing for ip_column + IP_ROW = COUNT ). + if WIDTH > -WIDTH. + -WIDTH = WIDTH. + endif. + endif. + COUNT = COUNT + 1. + endwhile. + LO_COLUMN = ME->GET_COLUMN( -COL_INDEX ). " issue #155 - less restrictive typing for ip_column + LO_COLUMN->SET_WIDTH( -WIDTH ). + endloop. + endif. -ENDMETHOD. + endmethod. -METHOD change_cell_style. - " issue # 139 - DATA: stylemapping TYPE zexcel_s_stylemapping, + method CHANGE_CELL_STYLE. + " issue # 139 + data: STYLEMAPPING type ZEXCEL_S_STYLEMAPPING, - complete_style TYPE zexcel_s_cstyle_complete, - complete_stylex TYPE zexcel_s_cstylex_complete, + COMPLETE_STYLE type ZEXCEL_S_CSTYLE_COMPLETE, + COMPLETE_STYLEX type ZEXCEL_S_CSTYLEX_COMPLETE, - borderx TYPE zexcel_s_cstylex_border, - l_guid TYPE zexcel_cell_style. "issue # 177 + BORDERX type ZEXCEL_S_CSTYLEX_BORDER, + L_GUID type ZEXCEL_CELL_STYLE. "issue # 177 * We have a lot of parameters. Use some macros to make the coding more structured - DEFINE clear_initial_colorxfields. - if &1-rgb is initial. - clear &2-rgb. - endif. - if &1-indexed is initial. - clear &2-indexed. - endif. - if &1-theme is initial. - clear &2-theme. - endif. - if &1-tint is initial. - clear &2-tint. - endif. - END-OF-DEFINITION. - - DEFINE move_supplied_borders. - if ip_&1 is supplied. " only act if parameter was supplied - if ip_x&1 is supplied. " - borderx = ip_x&1. " use supplied x-parameter - else. - clear borderx with 'X'. -* clear in a way that would be expected to work easily - if ip_&1-border_style is initial. - clear borderx-border_style. - endif. - clear_initial_colorxfields ip_&1-border_color borderx-border_color. + define CLEAR_INITIAL_COLORXFIELDS. + if &1-RGB is initial. + clear &2-RGB. endif. - move-corresponding ip_&1 to complete_style-&2. - move-corresponding borderx to complete_stylex-&2. - endif. - END-OF-DEFINITION. + if &1-INDEXED is initial. + clear &2-INDEXED. + endif. + if &1-THEME is initial. + clear &2-THEME. + endif. + if &1-TINT is initial. + clear &2-TINT. + endif. + end-of-definition. + + define MOVE_SUPPLIED_BORDERS. + if IP_&1 is supplied. " only act if parameter was supplied + if IP_X&1 is supplied. " + BORDERX = IP_X&1. " use supplied x-parameter + else. + clear BORDERX with 'X'. +* clear in a way that would be expected to work easily + if IP_&1-BORDER_STYLE is initial. + clear BORDERX-BORDER_STYLE. + endif. + CLEAR_INITIAL_COLORXFIELDS IP_&1-BORDER_COLOR BORDERX-BORDER_COLOR. + endif. + move-corresponding IP_&1 to COMPLETE_STYLE-&2. + move-corresponding BORDERX to COMPLETE_STYLEX-&2. + endif. + end-of-definition. * First get current stylsettings - TRY. - me->get_cell( EXPORTING ip_column = ip_column " Cell Column - ip_row = ip_row " Cell Row - IMPORTING ep_guid = l_guid )." Cell Value ). "issue # 177 + try. + ME->GET_CELL( exporting IP_COLUMN = IP_COLUMN " Cell Column + IP_ROW = IP_ROW " Cell Row + importing EP_GUID = L_GUID )." Cell Value ). "issue # 177 - stylemapping = me->excel->get_style_to_guid( l_guid ). "issue # 177 - complete_style = stylemapping-complete_style. - complete_stylex = stylemapping-complete_stylex. - CATCH zcx_excel. + STYLEMAPPING = ME->EXCEL->GET_STYLE_TO_GUID( L_GUID ). "issue # 177 + COMPLETE_STYLE = STYLEMAPPING-COMPLETE_STYLE. + COMPLETE_STYLEX = STYLEMAPPING-COMPLETE_STYLEX. + catch ZCX_EXCEL. * Error --> use submitted style - ENDTRY. + endtry. * move_supplied_multistyles: complete. - IF ip_complete IS SUPPLIED. - IF ip_xcomplete IS NOT SUPPLIED. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Complete styleinfo has to be supplied with corresponding X-field'. - ENDIF. - MOVE-CORRESPONDING ip_complete TO complete_style. - MOVE-CORRESPONDING ip_xcomplete TO complete_stylex. - ENDIF. - - - - IF ip_font IS SUPPLIED. - DATA: fontx LIKE ip_xfont. - IF ip_xfont IS SUPPLIED. - fontx = ip_xfont. - ELSE. -* Only supplied values should be used - exception: Flags bold and italic strikethrough underline - MOVE 'X' TO: fontx-bold, - fontx-italic, - fontx-strikethrough, - fontx-underline_mode. - CLEAR fontx-color WITH 'X'. - clear_initial_colorxfields ip_font-color fontx-color. - IF ip_font-family IS NOT INITIAL. - fontx-family = 'X'. - ENDIF. - IF ip_font-name IS NOT INITIAL. - fontx-name = 'X'. - ENDIF. - IF ip_font-scheme IS NOT INITIAL. - fontx-scheme = 'X'. - ENDIF. - IF ip_font-size IS NOT INITIAL. - fontx-size = 'X'. - ENDIF. - IF ip_font-underline_mode IS NOT INITIAL. - fontx-underline_mode = 'X'. - ENDIF. - ENDIF. - MOVE-CORRESPONDING ip_font TO complete_style-font. - MOVE-CORRESPONDING fontx TO complete_stylex-font. -* Correction for undeline mode - ENDIF. - - IF ip_fill IS SUPPLIED. - DATA: fillx LIKE ip_xfill. - IF ip_xfill IS SUPPLIED. - fillx = ip_xfill. - ELSE. - CLEAR fillx WITH 'X'. - IF ip_fill-filltype IS INITIAL. - CLEAR fillx-filltype. - ENDIF. - clear_initial_colorxfields ip_fill-fgcolor fillx-fgcolor. - clear_initial_colorxfields ip_fill-bgcolor fillx-bgcolor. - - ENDIF. - MOVE-CORRESPONDING ip_fill TO complete_style-fill. - MOVE-CORRESPONDING fillx TO complete_stylex-fill. - ENDIF. - - - IF ip_borders IS SUPPLIED. - DATA: bordersx LIKE ip_xborders. - IF ip_xborders IS SUPPLIED. - bordersx = ip_xborders. - ELSE. - CLEAR bordersx WITH 'X'. - IF ip_borders-allborders-border_style IS INITIAL. - CLEAR bordersx-allborders-border_style. - ENDIF. - IF ip_borders-diagonal-border_style IS INITIAL. - CLEAR bordersx-diagonal-border_style. - ENDIF. - IF ip_borders-down-border_style IS INITIAL. - CLEAR bordersx-down-border_style. - ENDIF. - IF ip_borders-left-border_style IS INITIAL. - CLEAR bordersx-left-border_style. - ENDIF. - IF ip_borders-right-border_style IS INITIAL. - CLEAR bordersx-right-border_style. - ENDIF. - IF ip_borders-top-border_style IS INITIAL. - CLEAR bordersx-top-border_style. - ENDIF. - clear_initial_colorxfields ip_borders-allborders-border_color bordersx-allborders-border_color. - clear_initial_colorxfields ip_borders-diagonal-border_color bordersx-diagonal-border_color. - clear_initial_colorxfields ip_borders-down-border_color bordersx-down-border_color. - clear_initial_colorxfields ip_borders-left-border_color bordersx-left-border_color. - clear_initial_colorxfields ip_borders-right-border_color bordersx-right-border_color. - clear_initial_colorxfields ip_borders-top-border_color bordersx-top-border_color. - - ENDIF. - MOVE-CORRESPONDING ip_borders TO complete_style-borders. - MOVE-CORRESPONDING bordersx TO complete_stylex-borders. - ENDIF. - - IF ip_alignment IS SUPPLIED. - DATA: alignmentx LIKE ip_xalignment. - IF ip_xalignment IS SUPPLIED. - alignmentx = ip_xalignment. - ELSE. - CLEAR alignmentx WITH 'X'. - IF ip_alignment-horizontal IS INITIAL. - CLEAR alignmentx-horizontal. - ENDIF. - IF ip_alignment-vertical IS INITIAL. - CLEAR alignmentx-vertical. - ENDIF. - ENDIF. - MOVE-CORRESPONDING ip_alignment TO complete_style-alignment. - MOVE-CORRESPONDING alignmentx TO complete_stylex-alignment. - ENDIF. - - IF ip_protection IS SUPPLIED. - MOVE-CORRESPONDING ip_protection TO complete_style-protection. - IF ip_xprotection IS SUPPLIED. - MOVE-CORRESPONDING ip_xprotection TO complete_stylex-protection. - ELSE. - IF ip_protection-hidden IS NOT INITIAL. - complete_stylex-protection-hidden = 'X'. - ENDIF. - IF ip_protection-locked IS NOT INITIAL. - complete_stylex-protection-locked = 'X'. - ENDIF. - ENDIF. - ENDIF. - - - move_supplied_borders : borders_allborders borders-allborders, - borders_diagonal borders-diagonal , - borders_down borders-down , - borders_left borders-left , - borders_right borders-right , - borders_top borders-top . - - DEFINE move_supplied_singlestyles. - if ip_&1 is supplied. - complete_style-&2 = ip_&1. - complete_stylex-&2 = 'X'. + if IP_COMPLETE is supplied. + if IP_XCOMPLETE is not supplied. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Complete styleinfo has to be supplied with corresponding X-field'. + endif. + move-corresponding IP_COMPLETE to COMPLETE_STYLE. + move-corresponding IP_XCOMPLETE to COMPLETE_STYLEX. endif. - END-OF-DEFINITION. - - move_supplied_singlestyles: number_format_format_code number_format-format_code, - font_bold font-bold, - font_color font-color, - font_color_rgb font-color-rgb, - font_color_indexed font-color-indexed, - font_color_theme font-color-theme, - font_color_tint font-color-tint, - - font_family font-family, - font_italic font-italic, - font_name font-name, - font_scheme font-scheme, - font_size font-size, - font_strikethrough font-strikethrough, - font_underline font-underline, - font_underline_mode font-underline_mode, - fill_filltype fill-filltype, - fill_rotation fill-rotation, - fill_fgcolor fill-fgcolor, - fill_fgcolor_rgb fill-fgcolor-rgb, - fill_fgcolor_indexed fill-fgcolor-indexed, - fill_fgcolor_theme fill-fgcolor-theme, - fill_fgcolor_tint fill-fgcolor-tint, - - fill_bgcolor fill-bgcolor, - fill_bgcolor_rgb fill-bgcolor-rgb, - fill_bgcolor_indexed fill-bgcolor-indexed, - fill_bgcolor_theme fill-bgcolor-theme, - fill_bgcolor_tint fill-bgcolor-tint, - - fill_gradtype_type fill-gradtype-TYPE, - fill_gradtype_degree fill-gradtype-DEGREE, - fill_gradtype_bottom fill-gradtype-BOTTOM, - fill_gradtype_left fill-gradtype-LEFT, - fill_gradtype_top fill-gradtype-TOP, - fill_gradtype_right fill-gradtype-RIGHT, - fill_gradtype_position1 fill-gradtype-POSITION1, - fill_gradtype_position2 fill-gradtype-POSITION2, - fill_gradtype_position3 fill-gradtype-POSITION3, - borders_diagonal_mode borders-diagonal_mode, - alignment_horizontal alignment-horizontal, - alignment_vertical alignment-vertical, - alignment_textrotation alignment-textrotation, - alignment_wraptext alignment-wraptext, - alignment_shrinktofit alignment-shrinktofit, - alignment_indent alignment-indent, - protection_hidden protection-hidden, - protection_locked protection-locked, + if IP_FONT is supplied. + data: FONTX like IP_XFONT. + if IP_XFONT is supplied. + FONTX = IP_XFONT. + else. +* Only supplied values should be used - exception: Flags bold and italic strikethrough underline + move 'X' to: FONTX-BOLD, + FONTX-ITALIC, + FONTX-STRIKETHROUGH, + FONTX-UNDERLINE_MODE. + clear FONTX-COLOR with 'X'. + CLEAR_INITIAL_COLORXFIELDS IP_FONT-COLOR FONTX-COLOR. + if IP_FONT-FAMILY is not initial. + FONTX-FAMILY = 'X'. + endif. + if IP_FONT-NAME is not initial. + FONTX-NAME = 'X'. + endif. + if IP_FONT-SCHEME is not initial. + FONTX-SCHEME = 'X'. + endif. + if IP_FONT-SIZE is not initial. + FONTX-SIZE = 'X'. + endif. + if IP_FONT-UNDERLINE_MODE is not initial. + FONTX-UNDERLINE_MODE = 'X'. + endif. + endif. + move-corresponding IP_FONT to COMPLETE_STYLE-FONT. + move-corresponding FONTX to COMPLETE_STYLEX-FONT. +* Correction for undeline mode + endif. - borders_allborders_style borders-allborders-border_style, - borders_allborders_color borders-allborders-border_color, - borders_allbo_color_rgb borders-allborders-border_color-rgb, - borders_allbo_color_indexed borders-allborders-border_color-indexed, - borders_allbo_color_theme borders-allborders-border_color-theme, - borders_allbo_color_tint borders-allborders-border_color-tint, + if IP_FILL is supplied. + data: FILLX like IP_XFILL. + if IP_XFILL is supplied. + FILLX = IP_XFILL. + else. + clear FILLX with 'X'. + if IP_FILL-FILLTYPE is initial. + clear FILLX-FILLTYPE. + endif. + CLEAR_INITIAL_COLORXFIELDS IP_FILL-FGCOLOR FILLX-FGCOLOR. + CLEAR_INITIAL_COLORXFIELDS IP_FILL-BGCOLOR FILLX-BGCOLOR. - borders_diagonal_style borders-diagonal-border_style, - borders_diagonal_color borders-diagonal-border_color, - borders_diagonal_color_rgb borders-diagonal-border_color-rgb, - borders_diagonal_color_inde borders-diagonal-border_color-indexed, - borders_diagonal_color_them borders-diagonal-border_color-theme, - borders_diagonal_color_tint borders-diagonal-border_color-tint, + endif. + move-corresponding IP_FILL to COMPLETE_STYLE-FILL. + move-corresponding FILLX to COMPLETE_STYLEX-FILL. + endif. - borders_down_style borders-down-border_style, - borders_down_color borders-down-border_color, - borders_down_color_rgb borders-down-border_color-rgb, - borders_down_color_indexed borders-down-border_color-indexed, - borders_down_color_theme borders-down-border_color-theme, - borders_down_color_tint borders-down-border_color-tint, - borders_left_style borders-left-border_style, - borders_left_color borders-left-border_color, - borders_left_color_rgb borders-left-border_color-rgb, - borders_left_color_indexed borders-left-border_color-indexed, - borders_left_color_theme borders-left-border_color-theme, - borders_left_color_tint borders-left-border_color-tint, + if IP_BORDERS is supplied. + data: BORDERSX like IP_XBORDERS. + if IP_XBORDERS is supplied. + BORDERSX = IP_XBORDERS. + else. + clear BORDERSX with 'X'. + if IP_BORDERS-ALLBORDERS-BORDER_STYLE is initial. + clear BORDERSX-ALLBORDERS-BORDER_STYLE. + endif. + if IP_BORDERS-DIAGONAL-BORDER_STYLE is initial. + clear BORDERSX-DIAGONAL-BORDER_STYLE. + endif. + if IP_BORDERS-DOWN-BORDER_STYLE is initial. + clear BORDERSX-DOWN-BORDER_STYLE. + endif. + if IP_BORDERS-LEFT-BORDER_STYLE is initial. + clear BORDERSX-LEFT-BORDER_STYLE. + endif. + if IP_BORDERS-RIGHT-BORDER_STYLE is initial. + clear BORDERSX-RIGHT-BORDER_STYLE. + endif. + if IP_BORDERS-TOP-BORDER_STYLE is initial. + clear BORDERSX-TOP-BORDER_STYLE. + endif. + CLEAR_INITIAL_COLORXFIELDS IP_BORDERS-ALLBORDERS-BORDER_COLOR BORDERSX-ALLBORDERS-BORDER_COLOR. + CLEAR_INITIAL_COLORXFIELDS IP_BORDERS-DIAGONAL-BORDER_COLOR BORDERSX-DIAGONAL-BORDER_COLOR. + CLEAR_INITIAL_COLORXFIELDS IP_BORDERS-DOWN-BORDER_COLOR BORDERSX-DOWN-BORDER_COLOR. + CLEAR_INITIAL_COLORXFIELDS IP_BORDERS-LEFT-BORDER_COLOR BORDERSX-LEFT-BORDER_COLOR. + CLEAR_INITIAL_COLORXFIELDS IP_BORDERS-RIGHT-BORDER_COLOR BORDERSX-RIGHT-BORDER_COLOR. + CLEAR_INITIAL_COLORXFIELDS IP_BORDERS-TOP-BORDER_COLOR BORDERSX-TOP-BORDER_COLOR. - borders_right_style borders-right-border_style, - borders_right_color borders-right-border_color, - borders_right_color_rgb borders-right-border_color-rgb, - borders_right_color_indexed borders-right-border_color-indexed, - borders_right_color_theme borders-right-border_color-theme, - borders_right_color_tint borders-right-border_color-tint, + endif. + move-corresponding IP_BORDERS to COMPLETE_STYLE-BORDERS. + move-corresponding BORDERSX to COMPLETE_STYLEX-BORDERS. + endif. - borders_top_style borders-top-border_style, - borders_top_color borders-top-border_color, - borders_top_color_rgb borders-top-border_color-rgb, - borders_top_color_indexed borders-top-border_color-indexed, - borders_top_color_theme borders-top-border_color-theme, - borders_top_color_tint borders-top-border_color-tint. + if IP_ALIGNMENT is supplied. + data: ALIGNMENTX like IP_XALIGNMENT. + if IP_XALIGNMENT is supplied. + ALIGNMENTX = IP_XALIGNMENT. + else. + clear ALIGNMENTX with 'X'. + if IP_ALIGNMENT-HORIZONTAL is initial. + clear ALIGNMENTX-HORIZONTAL. + endif. + if IP_ALIGNMENT-VERTICAL is initial. + clear ALIGNMENTX-VERTICAL. + endif. + endif. + move-corresponding IP_ALIGNMENT to COMPLETE_STYLE-ALIGNMENT. + move-corresponding ALIGNMENTX to COMPLETE_STYLEX-ALIGNMENT. + endif. + + if IP_PROTECTION is supplied. + move-corresponding IP_PROTECTION to COMPLETE_STYLE-PROTECTION. + if IP_XPROTECTION is supplied. + move-corresponding IP_XPROTECTION to COMPLETE_STYLEX-PROTECTION. + else. + if IP_PROTECTION-HIDDEN is not initial. + COMPLETE_STYLEX-PROTECTION-HIDDEN = 'X'. + endif. + if IP_PROTECTION-LOCKED is not initial. + COMPLETE_STYLEX-PROTECTION-LOCKED = 'X'. + endif. + endif. + endif. + + + MOVE_SUPPLIED_BORDERS : BORDERS_ALLBORDERS BORDERS-ALLBORDERS, + BORDERS_DIAGONAL BORDERS-DIAGONAL , + BORDERS_DOWN BORDERS-DOWN , + BORDERS_LEFT BORDERS-LEFT , + BORDERS_RIGHT BORDERS-RIGHT , + BORDERS_TOP BORDERS-TOP . + + define MOVE_SUPPLIED_SINGLESTYLES. + if IP_&1 is supplied. + COMPLETE_STYLE-&2 = IP_&1. + COMPLETE_STYLEX-&2 = 'X'. + endif. + end-of-definition. + + MOVE_SUPPLIED_SINGLESTYLES: NUMBER_FORMAT_FORMAT_CODE NUMBER_FORMAT-FORMAT_CODE, + FONT_BOLD FONT-BOLD, + FONT_COLOR FONT-COLOR, + FONT_COLOR_RGB FONT-COLOR-RGB, + FONT_COLOR_INDEXED FONT-COLOR-INDEXED, + FONT_COLOR_THEME FONT-COLOR-THEME, + FONT_COLOR_TINT FONT-COLOR-TINT, + + FONT_FAMILY FONT-FAMILY, + FONT_ITALIC FONT-ITALIC, + FONT_NAME FONT-NAME, + FONT_SCHEME FONT-SCHEME, + FONT_SIZE FONT-SIZE, + FONT_STRIKETHROUGH FONT-STRIKETHROUGH, + FONT_UNDERLINE FONT-UNDERLINE, + FONT_UNDERLINE_MODE FONT-UNDERLINE_MODE, + FILL_FILLTYPE FILL-FILLTYPE, + FILL_ROTATION FILL-ROTATION, + FILL_FGCOLOR FILL-FGCOLOR, + FILL_FGCOLOR_RGB FILL-FGCOLOR-RGB, + FILL_FGCOLOR_INDEXED FILL-FGCOLOR-INDEXED, + FILL_FGCOLOR_THEME FILL-FGCOLOR-THEME, + FILL_FGCOLOR_TINT FILL-FGCOLOR-TINT, + + FILL_BGCOLOR FILL-BGCOLOR, + FILL_BGCOLOR_RGB FILL-BGCOLOR-RGB, + FILL_BGCOLOR_INDEXED FILL-BGCOLOR-INDEXED, + FILL_BGCOLOR_THEME FILL-BGCOLOR-THEME, + FILL_BGCOLOR_TINT FILL-BGCOLOR-TINT, + + FILL_GRADTYPE_TYPE FILL-GRADTYPE-TYPE, + FILL_GRADTYPE_DEGREE FILL-GRADTYPE-DEGREE, + FILL_GRADTYPE_BOTTOM FILL-GRADTYPE-BOTTOM, + FILL_GRADTYPE_LEFT FILL-GRADTYPE-LEFT, + FILL_GRADTYPE_TOP FILL-GRADTYPE-TOP, + FILL_GRADTYPE_RIGHT FILL-GRADTYPE-RIGHT, + FILL_GRADTYPE_POSITION1 FILL-GRADTYPE-POSITION1, + FILL_GRADTYPE_POSITION2 FILL-GRADTYPE-POSITION2, + FILL_GRADTYPE_POSITION3 FILL-GRADTYPE-POSITION3, + + + + BORDERS_DIAGONAL_MODE BORDERS-DIAGONAL_MODE, + ALIGNMENT_HORIZONTAL ALIGNMENT-HORIZONTAL, + ALIGNMENT_VERTICAL ALIGNMENT-VERTICAL, + ALIGNMENT_TEXTROTATION ALIGNMENT-TEXTROTATION, + ALIGNMENT_WRAPTEXT ALIGNMENT-WRAPTEXT, + ALIGNMENT_SHRINKTOFIT ALIGNMENT-SHRINKTOFIT, + ALIGNMENT_INDENT ALIGNMENT-INDENT, + PROTECTION_HIDDEN PROTECTION-HIDDEN, + PROTECTION_LOCKED PROTECTION-LOCKED, + + BORDERS_ALLBORDERS_STYLE BORDERS-ALLBORDERS-BORDER_STYLE, + BORDERS_ALLBORDERS_COLOR BORDERS-ALLBORDERS-BORDER_COLOR, + BORDERS_ALLBO_COLOR_RGB BORDERS-ALLBORDERS-BORDER_COLOR-RGB, + BORDERS_ALLBO_COLOR_INDEXED BORDERS-ALLBORDERS-BORDER_COLOR-INDEXED, + BORDERS_ALLBO_COLOR_THEME BORDERS-ALLBORDERS-BORDER_COLOR-THEME, + BORDERS_ALLBO_COLOR_TINT BORDERS-ALLBORDERS-BORDER_COLOR-TINT, + + BORDERS_DIAGONAL_STYLE BORDERS-DIAGONAL-BORDER_STYLE, + BORDERS_DIAGONAL_COLOR BORDERS-DIAGONAL-BORDER_COLOR, + BORDERS_DIAGONAL_COLOR_RGB BORDERS-DIAGONAL-BORDER_COLOR-RGB, + BORDERS_DIAGONAL_COLOR_INDE BORDERS-DIAGONAL-BORDER_COLOR-INDEXED, + BORDERS_DIAGONAL_COLOR_THEM BORDERS-DIAGONAL-BORDER_COLOR-THEME, + BORDERS_DIAGONAL_COLOR_TINT BORDERS-DIAGONAL-BORDER_COLOR-TINT, + + BORDERS_DOWN_STYLE BORDERS-DOWN-BORDER_STYLE, + BORDERS_DOWN_COLOR BORDERS-DOWN-BORDER_COLOR, + BORDERS_DOWN_COLOR_RGB BORDERS-DOWN-BORDER_COLOR-RGB, + BORDERS_DOWN_COLOR_INDEXED BORDERS-DOWN-BORDER_COLOR-INDEXED, + BORDERS_DOWN_COLOR_THEME BORDERS-DOWN-BORDER_COLOR-THEME, + BORDERS_DOWN_COLOR_TINT BORDERS-DOWN-BORDER_COLOR-TINT, + + BORDERS_LEFT_STYLE BORDERS-LEFT-BORDER_STYLE, + BORDERS_LEFT_COLOR BORDERS-LEFT-BORDER_COLOR, + BORDERS_LEFT_COLOR_RGB BORDERS-LEFT-BORDER_COLOR-RGB, + BORDERS_LEFT_COLOR_INDEXED BORDERS-LEFT-BORDER_COLOR-INDEXED, + BORDERS_LEFT_COLOR_THEME BORDERS-LEFT-BORDER_COLOR-THEME, + BORDERS_LEFT_COLOR_TINT BORDERS-LEFT-BORDER_COLOR-TINT, + + BORDERS_RIGHT_STYLE BORDERS-RIGHT-BORDER_STYLE, + BORDERS_RIGHT_COLOR BORDERS-RIGHT-BORDER_COLOR, + BORDERS_RIGHT_COLOR_RGB BORDERS-RIGHT-BORDER_COLOR-RGB, + BORDERS_RIGHT_COLOR_INDEXED BORDERS-RIGHT-BORDER_COLOR-INDEXED, + BORDERS_RIGHT_COLOR_THEME BORDERS-RIGHT-BORDER_COLOR-THEME, + BORDERS_RIGHT_COLOR_TINT BORDERS-RIGHT-BORDER_COLOR-TINT, + + BORDERS_TOP_STYLE BORDERS-TOP-BORDER_STYLE, + BORDERS_TOP_COLOR BORDERS-TOP-BORDER_COLOR, + BORDERS_TOP_COLOR_RGB BORDERS-TOP-BORDER_COLOR-RGB, + BORDERS_TOP_COLOR_INDEXED BORDERS-TOP-BORDER_COLOR-INDEXED, + BORDERS_TOP_COLOR_THEME BORDERS-TOP-BORDER_COLOR-THEME, + BORDERS_TOP_COLOR_TINT BORDERS-TOP-BORDER_COLOR-TINT. * Now we have a completly filled styles. * This can be used to get the guid * Return guid if requested. Might be used if copy&paste of styles is requested - ep_guid = me->excel->get_static_cellstyle_guid( ip_cstyle_complete = complete_style - ip_cstylex_complete = complete_stylex ). - me->set_cell_style( ip_column = ip_column - ip_row = ip_row - ip_style = ep_guid ). + EP_GUID = ME->EXCEL->GET_STATIC_CELLSTYLE_GUID( IP_CSTYLE_COMPLETE = COMPLETE_STYLE + IP_CSTYLEX_COMPLETE = COMPLETE_STYLEX ). + ME->SET_CELL_STYLE( IP_COLUMN = IP_COLUMN + IP_ROW = IP_ROW + IP_STYLE = EP_GUID ). -ENDMETHOD. + endmethod. -METHOD constructor. - DATA: lv_title TYPE zexcel_sheet_title. + method CONSTRUCTOR. + data: LV_TITLE type ZEXCEL_SHEET_TITLE. - me->excel = ip_excel. + ME->EXCEL = IP_EXCEL. * CALL FUNCTION 'GUID_CREATE' " del issue #379 - function is outdated in newer releases * IMPORTING * ev_guid_16 = me->guid. - me->guid = zcl_excel_obsolete_func_wrap=>guid_create( ). " ins issue #379 - replacement for outdated function call + ME->GUID = ZCL_EXCEL_OBSOLETE_FUNC_WRAP=>GUID_CREATE( ). " ins issue #379 - replacement for outdated function call - IF ip_title IS NOT INITIAL. - lv_title = ip_title. - ELSE. + if IP_TITLE is not initial. + LV_TITLE = IP_TITLE. + else. * lv_title = me->guid. " del issue #154 - Names of worksheets - lv_title = me->generate_title( ). " ins issue #154 - Names of worksheets - ENDIF. + LV_TITLE = ME->GENERATE_TITLE( ). " ins issue #154 - Names of worksheets + endif. - me->set_title( ip_title = lv_title ). + ME->SET_TITLE( IP_TITLE = LV_TITLE ). - CREATE OBJECT sheet_setup. - CREATE OBJECT styles_cond. - CREATE OBJECT data_validations. - CREATE OBJECT tables. - CREATE OBJECT columns. - CREATE OBJECT rows. - CREATE OBJECT ranges. " issue #163 - CREATE OBJECT mo_pagebreaks. - CREATE OBJECT drawings - EXPORTING - ip_type = zcl_excel_drawing=>type_image. - CREATE OBJECT charts - EXPORTING - ip_type = zcl_excel_drawing=>type_chart. - me->zif_excel_sheet_protection~initialize( ). - me->zif_excel_sheet_properties~initialize( ). - CREATE OBJECT hyperlinks. + create object SHEET_SETUP. + create object STYLES_COND. + create object DATA_VALIDATIONS. + create object TABLES. + create object COLUMNS. + create object ROWS. + create object RANGES. " issue #163 + create object MO_PAGEBREAKS. + create object DRAWINGS + exporting + IP_TYPE = ZCL_EXCEL_DRAWING=>TYPE_IMAGE. + create object CHARTS + exporting + IP_TYPE = ZCL_EXCEL_DRAWING=>TYPE_CHART. + ME->ZIF_EXCEL_SHEET_PROTECTION~INITIALIZE( ). + ME->ZIF_EXCEL_SHEET_PROPERTIES~INITIALIZE( ). + create object HYPERLINKS. * initialize active cell coordinates - active_cell-cell_row = 1. - active_cell-cell_column = 1. + 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. + LOWER_CELL-CELL_ROW = 1. + LOWER_CELL-CELL_COLUMN = 1. + UPPER_CELL-CELL_ROW = 1. + UPPER_CELL-CELL_COLUMN = 1. -ENDMETHOD. + endmethod. -METHOD delete_merge. + method DELETE_MERGE. - DATA: lv_column TYPE i. + data: LV_COLUMN type I. *--------------------------------------------------------------------* * If cell information is passed delete merge including this cell, * otherwise delete all merges *--------------------------------------------------------------------* - IF ip_cell_column IS INITIAL - OR ip_cell_row IS INITIAL. - CLEAR me->mt_merged_cells. - ELSE. - lv_column = zcl_excel_common=>convert_column2int( ip_cell_column ). + if IP_CELL_COLUMN is initial + or IP_CELL_ROW is initial. + clear ME->MT_MERGED_CELLS. + else. + LV_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_CELL_COLUMN ). - LOOP AT me->mt_merged_cells TRANSPORTING NO FIELDS - WHERE - ( row_from <= ip_cell_row and row_to >= ip_cell_row ) - AND - ( col_from <= lv_column and col_to >= lv_column ). + loop at ME->MT_MERGED_CELLS transporting no fields + where + ( ROW_FROM <= IP_CELL_ROW and ROW_TO >= IP_CELL_ROW ) + and + ( COL_FROM <= LV_COLUMN and COL_TO >= LV_COLUMN ). - DELETE me->mt_merged_cells. - EXIT. - ENDLOOP. - ENDIF. + delete ME->MT_MERGED_CELLS. + exit. + endloop. + endif. -ENDMETHOD. - - -METHOD delete_row_outline. - - DELETE me->mt_row_outlines WHERE row_from = iv_row_from - AND row_to = iv_row_to. - IF sy-subrc <> 0. " didn't find outline that was to be deleted - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Row outline to be deleted does not exist'. - ENDIF. - -ENDMETHOD. - - -method FREEZE_PANES. - - IF ip_num_columns IS NOT SUPPLIED AND ip_num_rows IS NOT SUPPLIED. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Pleas provide number of rows and/or columns to freeze'. - ENDIF. - - IF ip_num_columns IS SUPPLIED AND ip_num_columns <= 0. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Number of columns to freeze should be positive'. - ENDIF. - - IF ip_num_rows IS SUPPLIED AND ip_num_rows <= 0. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Number of rows to freeze should be positive'. - ENDIF. - - freeze_pane_cell_column = ip_num_columns + 1. - freeze_pane_cell_row = ip_num_rows + 1. endmethod. -method GENERATE_TITLE. - DATA: lo_worksheets_iterator TYPE REF TO cl_object_collection_iterator, - lo_worksheet TYPE REF TO zcl_excel_worksheet. + method DELETE_ROW_OUTLINE. - DATA: t_titles TYPE HASHED TABLE OF zexcel_sheet_title WITH UNIQUE KEY table_line, - title TYPE zexcel_sheet_title, - sheetnumber TYPE i. + delete ME->MT_ROW_OUTLINES where ROW_FROM = IV_ROW_FROM + and ROW_TO = IV_ROW_TO. + if SY-SUBRC <> 0. " didn't find outline that was to be deleted + raise exception type ZCX_EXCEL + exporting + ERROR = 'Row outline to be deleted does not exist'. + endif. + + endmethod. + + + method FREEZE_PANES. + + if IP_NUM_COLUMNS is not supplied and IP_NUM_ROWS is not supplied. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Pleas provide number of rows and/or columns to freeze'. + endif. + + if IP_NUM_COLUMNS is supplied and IP_NUM_COLUMNS <= 0. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Number of columns to freeze should be positive'. + endif. + + if IP_NUM_ROWS is supplied and IP_NUM_ROWS <= 0. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Number of rows to freeze should be positive'. + endif. + + FREEZE_PANE_CELL_COLUMN = IP_NUM_COLUMNS + 1. + FREEZE_PANE_CELL_ROW = IP_NUM_ROWS + 1. + endmethod. + + + method GENERATE_TITLE. + data: LO_WORKSHEETS_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET. + + data: T_TITLES type hashed table of ZEXCEL_SHEET_TITLE with unique key TABLE_LINE, + TITLE type ZEXCEL_SHEET_TITLE, + SHEETNUMBER type I. * Get list of currently used titles - lo_worksheets_iterator = me->excel->get_worksheets_iterator( ). - WHILE lo_worksheets_iterator->has_next( ) = abap_true. - lo_worksheet ?= lo_worksheets_iterator->get_next( ). - title = lo_worksheet->get_title( ). - INSERT title INTO TABLE t_titles. - ADD 1 TO sheetnumber. - ENDWHILE. + LO_WORKSHEETS_ITERATOR = ME->EXCEL->GET_WORKSHEETS_ITERATOR( ). + while LO_WORKSHEETS_ITERATOR->HAS_NEXT( ) = ABAP_TRUE. + LO_WORKSHEET ?= LO_WORKSHEETS_ITERATOR->GET_NEXT( ). + TITLE = LO_WORKSHEET->GET_TITLE( ). + insert TITLE into table T_TITLES. + add 1 to SHEETNUMBER. + endwhile. * Now build sheetnumber. Increase counter until we hit a number that is not used so far - ADD 1 TO sheetnumber. " Start counting with next number - DO. - title = sheetnumber. - SHIFT title LEFT DELETING LEADING space. - CONCATENATE 'Sheet'(001) title INTO ep_title. - INSERT ep_title INTO TABLE t_titles. - IF sy-subrc = 0. " Title not used so far --> take it - EXIT. - ENDIF. + add 1 to SHEETNUMBER. " Start counting with next number + do. + TITLE = SHEETNUMBER. + shift TITLE left deleting leading SPACE. + concatenate 'Sheet'(001) TITLE into EP_TITLE. + insert EP_TITLE into table T_TITLES. + if SY-SUBRC = 0. " Title not used so far --> take it + exit. + endif. - ADD 1 TO sheetnumber. - ENDDO. + add 1 to SHEETNUMBER. + enddo. endmethod. -method GET_ACTIVE_CELL. + method GET_ACTIVE_CELL. - DATA: lv_active_column TYPE zexcel_cell_column_alpha, - lv_active_row TYPE string. + 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. + 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. + method GET_CELL. - DATA: lv_column TYPE zexcel_cell_column, - ls_sheet_content TYPE zexcel_s_cell_data. + data: LV_COLUMN type ZEXCEL_CELL_COLUMN, + LS_SHEET_CONTENT type ZEXCEL_S_CELL_DATA. - lv_column = zcl_excel_common=>convert_column2int( ip_column ). + 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. + 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. - ep_guid = ls_sheet_content-cell_style. " issue 139 - added this to be used for columnwidth calculation - ep_formula = ls_sheet_content-cell_formula. + EP_RC = SY-SUBRC. + EP_VALUE = LS_SHEET_CONTENT-CELL_VALUE. + EP_GUID = LS_SHEET_CONTENT-CELL_STYLE. " issue 139 - added this to be used for columnwidth calculation + EP_FORMULA = LS_SHEET_CONTENT-CELL_FORMULA. - " Addition to solve issue #120, contribution by Stefan Schmöcker - DATA: style_iterator TYPE REF TO cl_object_collection_iterator, - style TYPE REF TO zcl_excel_style. - IF ep_style IS REQUESTED. - style_iterator = me->excel->get_styles_iterator( ). - WHILE style_iterator->has_next( ) = 'X'. - style ?= style_iterator->get_next( ). - IF style->get_guid( ) = ls_sheet_content-cell_style. - ep_style = style. - EXIT. - ENDIF. - ENDWHILE. - ENDIF. -ENDMETHOD. - - -METHOD get_column. - - DATA: lo_column_iterator TYPE REF TO cl_object_collection_iterator, - lo_column TYPE REF TO zcl_excel_column, - lv_column TYPE zexcel_cell_column. - - lv_column = zcl_excel_common=>convert_column2int( ip_column ). - - lo_column_iterator = me->get_columns_iterator( ). - WHILE lo_column_iterator->has_next( ) = abap_true. - lo_column ?= lo_column_iterator->get_next( ). - IF lo_column->get_column_index( ) = lv_column. - eo_column = lo_column. - EXIT. - ENDIF. - ENDWHILE. - - IF eo_column IS NOT BOUND. - eo_column = me->add_new_column( ip_column ). - ENDIF. - -ENDMETHOD. - - -METHOD get_columns. - eo_columns = me->columns. -ENDMETHOD. - - -METHOD GET_COLUMNS_ITERATOR. - - eo_iterator = me->columns->get_iterator( ). - -ENDMETHOD. - - -method GET_DATA_VALIDATIONS_ITERATOR. - - eo_iterator = me->data_validations->get_iterator( ). + " Addition to solve issue #120, contribution by Stefan Schmöcker + data: STYLE_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + STYLE type ref to ZCL_EXCEL_STYLE. + if EP_STYLE is requested. + STYLE_ITERATOR = ME->EXCEL->GET_STYLES_ITERATOR( ). + while STYLE_ITERATOR->HAS_NEXT( ) = 'X'. + STYLE ?= STYLE_ITERATOR->GET_NEXT( ). + if STYLE->GET_GUID( ) = LS_SHEET_CONTENT-CELL_STYLE. + EP_STYLE = STYLE. + exit. + endif. + endwhile. + endif. endmethod. -method GET_DATA_VALIDATIONS_SIZE. - ep_size = me->data_validations->size( ). + method GET_COLUMN. + + data: LO_COLUMN_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_COLUMN type ref to ZCL_EXCEL_COLUMN, + LV_COLUMN type ZEXCEL_CELL_COLUMN. + + LV_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN ). + + EO_COLUMN = ME->COLUMNS->GET( IP_INDEX = LV_COLUMN ). + + if EO_COLUMN is not bound. + EO_COLUMN = ME->ADD_NEW_COLUMN( IP_COLUMN ). + endif. + endmethod. -METHOD GET_DEFAULT_COLUMN. - IF me->column_default IS NOT BOUND. - CREATE OBJECT me->column_default - EXPORTING - ip_index = 'A' " ???? - ip_worksheet = me - ip_excel = me->excel. - ENDIF. - - eo_column = me->column_default. -ENDMETHOD. - - -method GET_DEFAULT_EXCEL_DATE_FORMAT. - CONSTANTS: c_lang_e TYPE lang VALUE 'E'. - - IF default_excel_date_format IS NOT INITIAL. - ep_default_excel_date_format = default_excel_date_format. - RETURN. - ENDIF. - - "try to get defaults - TRY. - cl_abap_datfm=>get_date_format_des( EXPORTING im_langu = c_lang_e - IMPORTING ex_dateformat = default_excel_date_format ). - CATCH cx_abap_datfm_format_unknown. - - ENDTRY. - - " and fallback to fixed format - IF default_excel_date_format IS INITIAL. - default_excel_date_format = zcl_excel_style_number_format=>c_format_date_ddmmyyyydot. - ENDIF. - - ep_default_excel_date_format = default_excel_date_format. + method GET_COLUMNS. + EO_COLUMNS = ME->COLUMNS. endmethod. -method GET_DEFAULT_EXCEL_TIME_FORMAT. - DATA: l_timefm TYPE xutimefm. + method GET_COLUMNS_ITERATOR. - IF default_excel_time_format IS NOT INITIAL. - ep_default_excel_time_format = default_excel_time_format. - RETURN. - ENDIF. + EO_ITERATOR = ME->COLUMNS->GET_ITERATOR( ). + + endmethod. + + + method GET_DATA_VALIDATIONS_ITERATOR. + + EO_ITERATOR = ME->DATA_VALIDATIONS->GET_ITERATOR( ). + endmethod. + + + method GET_DATA_VALIDATIONS_SIZE. + EP_SIZE = ME->DATA_VALIDATIONS->SIZE( ). + endmethod. + + + method GET_DEFAULT_COLUMN. + if ME->COLUMN_DEFAULT is not bound. + create object ME->COLUMN_DEFAULT + exporting + IP_INDEX = 'A' " ???? + IP_WORKSHEET = ME + IP_EXCEL = ME->EXCEL. + endif. + + EO_COLUMN = ME->COLUMN_DEFAULT. + endmethod. + + + method GET_DEFAULT_EXCEL_DATE_FORMAT. + constants: C_LANG_E type LANG value 'E'. + + if DEFAULT_EXCEL_DATE_FORMAT is not initial. + EP_DEFAULT_EXCEL_DATE_FORMAT = DEFAULT_EXCEL_DATE_FORMAT. + return. + endif. + + "try to get defaults + try. + CL_ABAP_DATFM=>GET_DATE_FORMAT_DES( exporting IM_LANGU = C_LANG_E + importing EX_DATEFORMAT = DEFAULT_EXCEL_DATE_FORMAT ). + catch CX_ABAP_DATFM_FORMAT_UNKNOWN. + + endtry. + + " and fallback to fixed format + if DEFAULT_EXCEL_DATE_FORMAT is initial. + DEFAULT_EXCEL_DATE_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_DDMMYYYYDOT. + endif. + + EP_DEFAULT_EXCEL_DATE_FORMAT = DEFAULT_EXCEL_DATE_FORMAT. + endmethod. + + + method GET_DEFAULT_EXCEL_TIME_FORMAT. + data: L_TIMEFM type XUTIMEFM. + + if DEFAULT_EXCEL_TIME_FORMAT is not initial. + EP_DEFAULT_EXCEL_TIME_FORMAT = DEFAULT_EXCEL_TIME_FORMAT. + return. + endif. * Let's get default - l_timefm = cl_abap_timefm=>get_environment_timefm( ). - CASE l_timefm. - WHEN 0. + L_TIMEFM = CL_ABAP_TIMEFM=>GET_ENVIRONMENT_TIMEFM( ). + case L_TIMEFM. + when 0. *0 24 Hour Format (Example: 12:05:10) - default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time6. - WHEN 1. + DEFAULT_EXCEL_TIME_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME6. + when 1. *1 12 Hour Format (Example: 12:05:10 PM) - default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. - WHEN 2. + DEFAULT_EXCEL_TIME_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME2. + when 2. *2 12 Hour Format (Example: 12:05:10 pm) for now all the same. no chnage upper lower - default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. - WHEN 3. + DEFAULT_EXCEL_TIME_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME2. + when 3. *3 Hours from 0 to 11 (Example: 00:05:10 PM) for now all the same. no chnage upper lower - default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. - WHEN 4. + DEFAULT_EXCEL_TIME_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME2. + when 4. *4 Hours from 0 to 11 (Example: 00:05:10 pm) for now all the same. no chnage upper lower - default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. - WHEN OTHERS. - " and fallback to fixed format - default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time6. - ENDCASE. + DEFAULT_EXCEL_TIME_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME2. + when others. + " and fallback to fixed format + DEFAULT_EXCEL_TIME_FORMAT = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME6. + endcase. - ep_default_excel_time_format = default_excel_time_format. + EP_DEFAULT_EXCEL_TIME_FORMAT = DEFAULT_EXCEL_TIME_FORMAT. endmethod. -METHOD get_default_row. - IF me->row_default IS NOT BOUND. - CREATE OBJECT me->row_default. - ENDIF. + method GET_DEFAULT_ROW. + if ME->ROW_DEFAULT is not bound. + create object ME->ROW_DEFAULT. + endif. - eo_row = me->row_default. -ENDMETHOD. + EO_ROW = ME->ROW_DEFAULT. + endmethod. -method GET_DIMENSION_RANGE. + method GET_DIMENSION_RANGE. - me->update_dimension_range( ). - IF upper_cell EQ lower_cell. "only one cell - " Worksheet not filled + ME->UPDATE_DIMENSION_RANGE( ). + if UPPER_CELL eq LOWER_CELL. "only one cell + " Worksheet not filled * IF upper_cell-cell_coords = '0'. - IF upper_cell-cell_coords IS INITIAL. - ep_dimension_range = 'A1'. - ELSE. - ep_dimension_range = upper_cell-cell_coords. - ENDIF. - ELSE. - CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. - ENDIF. + if UPPER_CELL-CELL_COORDS is initial. + EP_DIMENSION_RANGE = 'A1'. + else. + EP_DIMENSION_RANGE = UPPER_CELL-CELL_COORDS. + endif. + else. + concatenate UPPER_CELL-CELL_COORDS ':' LOWER_CELL-CELL_COORDS into EP_DIMENSION_RANGE. + endif. endmethod. -method GET_DRAWINGS. + method GET_DRAWINGS. - DATA: lo_drawing TYPE REF TO zcl_excel_drawing, - lo_iterator TYPE REF TO cl_object_collection_iterator. + data: LO_DRAWING type ref to ZCL_EXCEL_DRAWING, + LO_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR. - CASE ip_type. - WHEN zcl_excel_drawing=>type_image. - r_drawings = drawings. - WHEN zcl_excel_drawing=>type_chart. - r_drawings = charts. - WHEN space. - CREATE OBJECT r_drawings - EXPORTING - ip_type = ''. + case IP_TYPE. + when ZCL_EXCEL_DRAWING=>TYPE_IMAGE. + R_DRAWINGS = DRAWINGS. + when ZCL_EXCEL_DRAWING=>TYPE_CHART. + R_DRAWINGS = CHARTS. + when SPACE. + create object R_DRAWINGS + exporting + IP_TYPE = ''. - lo_iterator = drawings->get_iterator( ). - WHILE lo_iterator->has_next( ) = abap_true. - lo_drawing ?= lo_iterator->get_next( ). - r_drawings->include( lo_drawing ). - ENDWHILE. - lo_iterator = charts->get_iterator( ). - WHILE lo_iterator->has_next( ) = abap_true. - lo_drawing ?= lo_iterator->get_next( ). - r_drawings->include( lo_drawing ). - ENDWHILE. - WHEN OTHERS. - ENDCASE. + LO_ITERATOR = DRAWINGS->GET_ITERATOR( ). + while LO_ITERATOR->HAS_NEXT( ) = ABAP_TRUE. + LO_DRAWING ?= LO_ITERATOR->GET_NEXT( ). + R_DRAWINGS->INCLUDE( LO_DRAWING ). + endwhile. + LO_ITERATOR = CHARTS->GET_ITERATOR( ). + while LO_ITERATOR->HAS_NEXT( ) = ABAP_TRUE. + LO_DRAWING ?= LO_ITERATOR->GET_NEXT( ). + R_DRAWINGS->INCLUDE( LO_DRAWING ). + endwhile. + when others. + endcase. endmethod. -method GET_DRAWINGS_ITERATOR. - CASE ip_type. - WHEN zcl_excel_drawing=>type_image. - eo_iterator = drawings->get_iterator( ). - WHEN zcl_excel_drawing=>type_chart. - eo_iterator = charts->get_iterator( ). - ENDCASE. + method GET_DRAWINGS_ITERATOR. + case IP_TYPE. + when ZCL_EXCEL_DRAWING=>TYPE_IMAGE. + EO_ITERATOR = DRAWINGS->GET_ITERATOR( ). + when ZCL_EXCEL_DRAWING=>TYPE_CHART. + EO_ITERATOR = CHARTS->GET_ITERATOR( ). + endcase. endmethod. -method GET_FREEZE_CELL. - ep_row = me->freeze_pane_cell_row. - ep_column = me->freeze_pane_cell_column. + method GET_FREEZE_CELL. + EP_ROW = ME->FREEZE_PANE_CELL_ROW. + EP_COLUMN = ME->FREEZE_PANE_CELL_COLUMN. endmethod. -METHOD get_guid. + method GET_GUID. - ep_guid = me->guid. - -ENDMETHOD. - - -method GET_HIGHEST_COLUMN. - me->update_dimension_range( ). - r_highest_column = me->lower_cell-cell_column. - endmethod. - - -METHOD get_highest_row. - me->update_dimension_range( ). - r_highest_row = me->lower_cell-cell_row. -ENDMETHOD. - - -method GET_HYPERLINKS_ITERATOR. - eo_iterator = hyperlinks->get_iterator( ). - endmethod. - - -method GET_HYPERLINKS_SIZE. - ep_size = hyperlinks->size( ). - endmethod. - - -METHOD get_merge. - - FIELD-SYMBOLS: LIKE LINE OF me->mt_merged_cells. - - DATA: lv_col_from TYPE string, - lv_col_to TYPE string, - lv_row_from TYPE string, - lv_row_to TYPE string, - lv_merge_range TYPE string. - - LOOP AT me->mt_merged_cells ASSIGNING . - - lv_col_from = zcl_excel_common=>convert_column2alpha( -col_from ). - lv_col_to = zcl_excel_common=>convert_column2alpha( -col_to ). - lv_row_from = -row_from. - lv_row_to = -row_to . - CONCATENATE lv_col_from lv_row_from ':' lv_col_to lv_row_to - INTO lv_merge_range. - CONDENSE lv_merge_range NO-GAPS. - APPEND lv_merge_range TO merge_range. - - ENDLOOP. - -ENDMETHOD. - - -method GET_PAGEBREAKS. - ro_pagebreaks = mo_pagebreaks. -endmethod. - - -method GET_RANGES_ITERATOR. - - eo_iterator = me->ranges->get_iterator( ). + EP_GUID = ME->GUID. endmethod. -METHOD get_row. - - DATA: lo_row_iterator TYPE REF TO cl_object_collection_iterator, - lo_row TYPE REF TO zcl_excel_row. - - lo_row_iterator = me->get_rows_iterator( ). - WHILE lo_row_iterator->has_next( ) = abap_true. - lo_row ?= lo_row_iterator->get_next( ). - IF lo_row->get_row_index( ) = ip_row. - eo_row = lo_row. - EXIT. - ENDIF. - ENDWHILE. - - IF eo_row IS NOT BOUND. - eo_row = me->add_new_row( ip_row ). - ENDIF. - -ENDMETHOD. - - -METHOD GET_ROWS. - eo_rows = me->rows. -ENDMETHOD. - - -METHOD get_rows_iterator. - - eo_iterator = me->rows->get_iterator( ). - -ENDMETHOD. - - -METHOD get_row_outlines. - - rt_row_outlines = me->mt_row_outlines. - -ENDMETHOD. - - -METHOD get_style_cond. - - DATA: lo_style_iterator TYPE REF TO cl_object_collection_iterator, - lo_style_cond TYPE REF TO zcl_excel_style_cond. - - lo_style_iterator = me->get_style_cond_iterator( ). - WHILE lo_style_iterator->has_next( ) = abap_true. - lo_style_cond ?= lo_style_iterator->get_next( ). - IF lo_style_cond->get_guid( ) = ip_guid. - eo_style_cond = lo_style_cond. - EXIT. - ENDIF. - ENDWHILE. - -ENDMETHOD. - - -METHOD get_style_cond_iterator. - - eo_iterator = styles_cond->get_iterator( ). -ENDMETHOD. - - -method GET_TABCOLOR. - ev_tabcolor = me->tabcolor. + method GET_HIGHEST_COLUMN. + ME->UPDATE_DIMENSION_RANGE( ). + R_HIGHEST_COLUMN = ME->LOWER_CELL-CELL_COLUMN. endmethod. - METHOD get_table. + method GET_HIGHEST_ROW. + ME->UPDATE_DIMENSION_RANGE( ). + R_HIGHEST_ROW = ME->LOWER_CELL-CELL_ROW. + endmethod. + + + method GET_HYPERLINKS_ITERATOR. + EO_ITERATOR = HYPERLINKS->GET_ITERATOR( ). + endmethod. + + + method GET_HYPERLINKS_SIZE. + EP_SIZE = HYPERLINKS->SIZE( ). + endmethod. + + + method GET_MERGE. + + field-symbols: like line of ME->MT_MERGED_CELLS. + + data: LV_COL_FROM type STRING, + LV_COL_TO type STRING, + LV_ROW_FROM type STRING, + LV_ROW_TO type STRING, + LV_MERGE_RANGE type STRING. + + loop at ME->MT_MERGED_CELLS assigning . + + LV_COL_FROM = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( -COL_FROM ). + LV_COL_TO = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( -COL_TO ). + LV_ROW_FROM = -ROW_FROM. + LV_ROW_TO = -ROW_TO . + concatenate LV_COL_FROM LV_ROW_FROM ':' LV_COL_TO LV_ROW_TO + into LV_MERGE_RANGE. + condense LV_MERGE_RANGE no-gaps. + append LV_MERGE_RANGE to MERGE_RANGE. + + endloop. + + endmethod. + + + method GET_PAGEBREAKS. + RO_PAGEBREAKS = MO_PAGEBREAKS. + endmethod. + + + method GET_RANGES_ITERATOR. + + EO_ITERATOR = ME->RANGES->GET_ITERATOR( ). + + endmethod. + + + method GET_ROW. + EO_ROW = ME->ROWS->GET( IP_INDEX = IP_ROW ). + + if EO_ROW is not bound. + EO_ROW = ME->ADD_NEW_ROW( IP_ROW ). + endif. + endmethod. + + + method GET_ROWS. + EO_ROWS = ME->ROWS. + endmethod. + + + method GET_ROWS_ITERATOR. + + EO_ITERATOR = ME->ROWS->GET_ITERATOR( ). + + endmethod. + + + method GET_ROW_OUTLINES. + + RT_ROW_OUTLINES = ME->MT_ROW_OUTLINES. + + endmethod. + + + method GET_STYLE_COND. + + data: LO_STYLE_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_STYLE_COND type ref to ZCL_EXCEL_STYLE_COND. + + LO_STYLE_ITERATOR = ME->GET_STYLE_COND_ITERATOR( ). + while LO_STYLE_ITERATOR->HAS_NEXT( ) = ABAP_TRUE. + LO_STYLE_COND ?= LO_STYLE_ITERATOR->GET_NEXT( ). + if LO_STYLE_COND->GET_GUID( ) = IP_GUID. + EO_STYLE_COND = LO_STYLE_COND. + exit. + endif. + endwhile. + + endmethod. + + + method GET_STYLE_COND_ITERATOR. + + EO_ITERATOR = STYLES_COND->GET_ITERATOR( ). + endmethod. + + + method GET_TABCOLOR. + EV_TABCOLOR = ME->TABCOLOR. + endmethod. + + + method GET_TABLE. *--------------------------------------------------------------------* * Comment D. Rauchenstein * With this method, we get a fully functional Excel Upload, which solves @@ -4177,438 +4158,438 @@ method GET_TABCOLOR. * CL_EXCEL_READER_2007->ZIF_EXCEL_READER~LOAD_FILE() *--------------------------------------------------------------------* - FIELD-SYMBOLS: TYPE data. - FIELD-SYMBOLS: TYPE data. + field-symbols: type DATA. + field-symbols: type DATA. - DATA lv_actual_row TYPE int4. - DATA lv_actual_col TYPE int4. - DATA lv_errormessage TYPE string. - DATA lv_max_col TYPE zexcel_cell_column. - DATA lv_max_row TYPE int4. - DATA lv_delta_col TYPE int4. - DATA lv_value TYPE zexcel_cell_value. - DATA lv_rc TYPE sysubrc. + data LV_ACTUAL_ROW type INT4. + data LV_ACTUAL_COL type INT4. + data LV_ERRORMESSAGE type STRING. + data LV_MAX_COL type ZEXCEL_CELL_COLUMN. + data LV_MAX_ROW type INT4. + data LV_DELTA_COL type INT4. + data LV_VALUE type ZEXCEL_CELL_VALUE. + data LV_RC type SYSUBRC. - lv_max_col = me->get_highest_column( ). - lv_max_row = me->get_highest_row( ). + LV_MAX_COL = ME->GET_HIGHEST_COLUMN( ). + LV_MAX_ROW = ME->GET_HIGHEST_ROW( ). *--------------------------------------------------------------------* * The row counter begins with 1 and should be corrected with the skips *--------------------------------------------------------------------* - lv_actual_row = iv_skipped_rows + 1. - lv_actual_col = iv_skipped_cols + 1. + LV_ACTUAL_ROW = IV_SKIPPED_ROWS + 1. + LV_ACTUAL_COL = IV_SKIPPED_COLS + 1. - TRY. + try. *--------------------------------------------------------------------* * Check if we the basic features are possible with given "any table" *--------------------------------------------------------------------* - APPEND INITIAL LINE TO et_table ASSIGNING . - IF sy-subrc <> 0 OR IS NOT ASSIGNED. + append initial line to ET_TABLE assigning . + if SY-SUBRC <> 0 or is not assigned. - lv_errormessage = 'Error at inserting new Line to internal Table'(002). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. + LV_ERRORMESSAGE = 'Error at inserting new Line to internal Table'(002). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. - ELSE. - lv_delta_col = lv_max_col - iv_skipped_cols. - ASSIGN COMPONENT lv_delta_col OF STRUCTURE TO . - IF sy-subrc <> 0 OR IS NOT ASSIGNED. - lv_errormessage = 'Internal table has less columns than excel'(003). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ELSE. + else. + LV_DELTA_COL = LV_MAX_COL - IV_SKIPPED_COLS. + assign component LV_DELTA_COL of structure to . + if SY-SUBRC <> 0 or is not assigned. + LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + else. *--------------------------------------------------------------------* *now we are ready for handle the table data *--------------------------------------------------------------------* - REFRESH et_table. + refresh ET_TABLE. *--------------------------------------------------------------------* * Handle each Row until end on right side *--------------------------------------------------------------------* - WHILE lv_actual_row <= lv_max_row . + while LV_ACTUAL_ROW <= LV_MAX_ROW . *--------------------------------------------------------------------* * Handle each Column until end on bottom * First step is to step back on first column *--------------------------------------------------------------------* - lv_actual_col = iv_skipped_cols + 1. + LV_ACTUAL_COL = IV_SKIPPED_COLS + 1. - UNASSIGN . - APPEND INITIAL LINE TO et_table ASSIGNING . - IF sy-subrc <> 0 OR IS NOT ASSIGNED. - lv_errormessage = 'Error at inserting new Line to internal Table'(002). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. - WHILE lv_actual_col <= lv_max_col. + unassign . + append initial line to ET_TABLE assigning . + if SY-SUBRC <> 0 or is not assigned. + LV_ERRORMESSAGE = 'Error at inserting new Line to internal Table'(002). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. + while LV_ACTUAL_COL <= LV_MAX_COL. - lv_delta_col = lv_actual_col - iv_skipped_cols. - ASSIGN COMPONENT lv_delta_col OF STRUCTURE TO . - IF sy-subrc <> 0. - lv_errormessage = |{ 'Error at assigning field (Col:'(004) } { lv_actual_col } { ' Row:'(005) } { lv_actual_row }|. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + LV_DELTA_COL = LV_ACTUAL_COL - IV_SKIPPED_COLS. + assign component LV_DELTA_COL of structure to . + if SY-SUBRC <> 0. + LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - me->get_cell( - EXPORTING - ip_column = lv_actual_col " Cell Column - ip_row = lv_actual_row " Cell Row - IMPORTING - ep_value = lv_value " Cell Value - ep_rc = lv_rc " Return Value of ABAP Statements - ). - IF lv_rc <> 0 - AND lv_rc <> 4. "No found error means, zero/no value in cell - lv_errormessage = |{ 'Error at reading field value (Col:'(007) } { lv_actual_col } { ' Row:'(005) } { lv_actual_row }|. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + ME->GET_CELL( + exporting + IP_COLUMN = LV_ACTUAL_COL " Cell Column + IP_ROW = LV_ACTUAL_ROW " Cell Row + importing + EP_VALUE = LV_VALUE " Cell Value + EP_RC = LV_RC " Return Value of ABAP Statements + ). + if LV_RC <> 0 + and LV_RC <> 4. "No found error means, zero/no value in cell + LV_ERRORMESSAGE = |{ 'Error at reading field value (Col:'(007) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - = lv_value. + = LV_VALUE. * CATCH zcx_excel. " - ADD 1 TO lv_actual_col. - ENDWHILE. - ADD 1 TO lv_actual_row. - ENDWHILE. - ENDIF. + add 1 to LV_ACTUAL_COL. + endwhile. + add 1 to LV_ACTUAL_ROW. + endwhile. + endif. - ENDIF. + endif. - CATCH cx_sy_assign_cast_illegal_cast. - lv_errormessage = |{ 'Error at assigning field (Col:'(004) } { lv_actual_col } { ' Row:'(005) } { lv_actual_row }|. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - CATCH cx_sy_assign_cast_unknown_type. - lv_errormessage = |{ 'Error at assigning field (Col:'(004) } { lv_actual_col } { ' Row:'(005) } { lv_actual_row }|. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - CATCH cx_sy_assign_out_of_range. - lv_errormessage = 'Internal table has less columns than excel'(003). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - CATCH cx_sy_conversion_error. - lv_errormessage = |{ 'Error at converting field value (Col:'(006) } { lv_actual_col } { ' Row:'(005) } { lv_actual_row }|. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. + catch CX_SY_ASSIGN_CAST_ILLEGAL_CAST. + LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + catch CX_SY_ASSIGN_CAST_UNKNOWN_TYPE. + LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + catch CX_SY_ASSIGN_OUT_OF_RANGE. + LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + catch CX_SY_CONVERSION_ERROR. + LV_ERRORMESSAGE = |{ 'Error at converting field value (Col:'(006) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. - ENDTRY. - ENDMETHOD. - - -method GET_TABLES_ITERATOR. - eo_iterator = tables->if_object_collection~get_iterator( ). + endtry. endmethod. -method GET_TABLES_SIZE. - ep_size = tables->if_object_collection~size( ). + method GET_TABLES_ITERATOR. + EO_ITERATOR = TABLES->IF_OBJECT_COLLECTION~GET_ITERATOR( ). endmethod. -method GET_TITLE. - DATA lv_value TYPE string. - IF ip_escaped EQ abap_true. - lv_value = me->title. - ep_title = zcl_excel_common=>escape_string( lv_value ). - ELSE. - ep_title = me->title. - ENDIF. + method GET_TABLES_SIZE. + EP_SIZE = TABLES->IF_OBJECT_COLLECTION~SIZE( ). endmethod. -METHOD get_value_type. - DATA: lo_addit TYPE REF TO cl_abap_elemdescr, - ls_dfies TYPE dfies, - l_function TYPE funcname, - l_value(50) TYPE c. + method GET_TITLE. + data LV_VALUE type STRING. + if IP_ESCAPED eq ABAP_TRUE. + LV_VALUE = ME->TITLE. + EP_TITLE = ZCL_EXCEL_COMMON=>ESCAPE_STRING( LV_VALUE ). + else. + EP_TITLE = ME->TITLE. + endif. + endmethod. - ep_value = ip_value. - ep_value_type = cl_abap_typedescr=>typekind_string. " Thats our default if something goes wrong. - TRY. - lo_addit ?= cl_abap_typedescr=>describe_by_data( ip_value ). - CATCH cx_sy_move_cast_error. - CLEAR lo_addit. - ENDTRY. - IF lo_addit IS BOUND. - lo_addit->get_ddic_field( RECEIVING p_flddescr = ls_dfies - EXCEPTIONS not_found = 1 - no_ddic_type = 2 - OTHERS = 3 ) . - IF sy-subrc = 0. - ep_value_type = ls_dfies-inttype. + method GET_VALUE_TYPE. + data: LO_ADDIT type ref to CL_ABAP_ELEMDESCR, + LS_DFIES type DFIES, + L_FUNCTION type FUNCNAME, + L_VALUE(50) type C. - IF ls_dfies-convexit IS NOT INITIAL. + EP_VALUE = IP_VALUE. + EP_VALUE_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_STRING. " Thats our default if something goes wrong. + + try. + LO_ADDIT ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( IP_VALUE ). + catch CX_SY_MOVE_CAST_ERROR. + clear LO_ADDIT. + endtry. + if LO_ADDIT is bound. + LO_ADDIT->GET_DDIC_FIELD( receiving P_FLDDESCR = LS_DFIES + exceptions NOT_FOUND = 1 + NO_DDIC_TYPE = 2 + others = 3 ) . + if SY-SUBRC = 0. + EP_VALUE_TYPE = LS_DFIES-INTTYPE. + + if LS_DFIES-CONVEXIT is not initial. * We need to convert with output conversion function - CONCATENATE 'CONVERSION_EXIT_' ls_dfies-convexit '_OUTPUT' INTO l_function. - SELECT SINGLE funcname INTO l_function - FROM tfdir - WHERE funcname = l_function. - IF sy-subrc = 0. - CALL FUNCTION l_function - EXPORTING - input = ip_value - IMPORTING -* LONG_TEXT = - output = l_value -* SHORT_TEXT = - EXCEPTIONS - OTHERS = 1. - IF sy-subrc <> 0. + concatenate 'CONVERSION_EXIT_' LS_DFIES-CONVEXIT '_OUTPUT' into L_FUNCTION. + select single FUNCNAME into L_FUNCTION + from TFDIR + where FUNCNAME = L_FUNCTION. + if SY-SUBRC = 0. + call function L_FUNCTION + exporting + INPUT = IP_VALUE + importing +* LONG_TEXT = + OUTPUT = L_VALUE +* SHORT_TEXT = + exceptions + others = 1. + if SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. - ELSE. - TRY. - ep_value = l_value. - CATCH cx_root. - ep_value = ip_value. - ENDTRY. - ENDIF. - ENDIF. - ENDIF. - ELSE. - ep_value_type = lo_addit->get_data_type_kind( ip_value ). - ENDIF. - ENDIF. + else. + try. + EP_VALUE = L_VALUE. + catch CX_ROOT. + EP_VALUE = IP_VALUE. + endtry. + endif. + endif. + endif. + else. + EP_VALUE_TYPE = LO_ADDIT->GET_DATA_TYPE_KIND( IP_VALUE ). + endif. + endif. -ENDMETHOD. + endmethod. -METHOD is_cell_merged. + method IS_CELL_MERGED. - DATA: lv_column TYPE i. + data: LV_COLUMN type I. - FIELD-SYMBOLS: LIKE LINE OF me->mt_merged_cells. + field-symbols: like line of ME->MT_MERGED_CELLS. - lv_column = zcl_excel_common=>convert_column2int( ip_column ). + LV_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN ). - rp_is_merged = abap_false. " Assume not in merged area + RP_IS_MERGED = ABAP_FALSE. " Assume not in merged area - LOOP AT me->mt_merged_cells ASSIGNING . + loop at ME->MT_MERGED_CELLS assigning . - IF -col_from <= lv_column - AND -col_to >= lv_column - AND -row_from <= ip_row - AND -row_to >= ip_row. - rp_is_merged = abap_true. " until we are proven different - RETURN. - ENDIF. + if -COL_FROM <= LV_COLUMN + and -COL_TO >= LV_COLUMN + and -ROW_FROM <= IP_ROW + and -ROW_TO >= IP_ROW. + RP_IS_MERGED = ABAP_TRUE. " until we are proven different + return. + endif. - ENDLOOP. + endloop. -ENDMETHOD. + endmethod. -method PRINT_TITLE_SET_RANGE. + method PRINT_TITLE_SET_RANGE. *--------------------------------------------------------------------* * issue#235 - repeat rows/columns * - Stefan Schmoecker, 2012-12-02 *--------------------------------------------------------------------* - DATA: lo_range_iterator TYPE REF TO cl_object_collection_iterator, - lo_range TYPE REF TO zcl_excel_range, - lv_repeat_range_sheetname TYPE string, - lv_repeat_range_col TYPE string, - lv_row_char_from TYPE char10, - lv_row_char_to TYPE char10, - lv_repeat_range_row TYPE string, - lv_repeat_range TYPE string. + data: LO_RANGE_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_RANGE type ref to ZCL_EXCEL_RANGE, + LV_REPEAT_RANGE_SHEETNAME type STRING, + LV_REPEAT_RANGE_COL type STRING, + LV_ROW_CHAR_FROM type CHAR10, + LV_ROW_CHAR_TO type CHAR10, + LV_REPEAT_RANGE_ROW type STRING, + LV_REPEAT_RANGE type STRING. *--------------------------------------------------------------------* * Get range that represents printarea * if non-existant, create it *--------------------------------------------------------------------* - lo_range_iterator = me->get_ranges_iterator( ). - WHILE lo_range_iterator->has_next( ) = abap_true. + LO_RANGE_ITERATOR = ME->GET_RANGES_ITERATOR( ). + while LO_RANGE_ITERATOR->HAS_NEXT( ) = ABAP_TRUE. - lo_range ?= lo_range_iterator->get_next( ). - IF lo_range->name = zif_excel_sheet_printsettings=>gcv_print_title_name. - EXIT. " Found it - ENDIF. - CLEAR lo_range. + LO_RANGE ?= LO_RANGE_ITERATOR->GET_NEXT( ). + if LO_RANGE->NAME = ZIF_EXCEL_SHEET_PRINTSETTINGS=>GCV_PRINT_TITLE_NAME. + exit. " Found it + endif. + clear LO_RANGE. - ENDWHILE. + endwhile. - IF me->print_title_col_from IS INITIAL AND - me->print_title_row_from IS INITIAL. + if ME->PRINT_TITLE_COL_FROM is initial and + ME->PRINT_TITLE_ROW_FROM is initial. *--------------------------------------------------------------------* * No print titles are present, *--------------------------------------------------------------------* - IF lo_range IS BOUND. - me->ranges->remove( lo_range ). - ENDIF. - ELSE. + if LO_RANGE is bound. + ME->RANGES->REMOVE( LO_RANGE ). + endif. + else. *--------------------------------------------------------------------* * Print titles are present, *--------------------------------------------------------------------* - IF lo_range IS NOT BOUND. - lo_range = me->add_new_range( ). - lo_range->name = zif_excel_sheet_printsettings=>gcv_print_title_name. - ENDIF. + if LO_RANGE is not bound. + LO_RANGE = ME->ADD_NEW_RANGE( ). + LO_RANGE->NAME = ZIF_EXCEL_SHEET_PRINTSETTINGS=>GCV_PRINT_TITLE_NAME. + endif. - lv_repeat_range_sheetname = me->get_title( ). - lv_repeat_range_sheetname = zcl_excel_common=>escape_string( lv_repeat_range_sheetname ). + LV_REPEAT_RANGE_SHEETNAME = ME->GET_TITLE( ). + LV_REPEAT_RANGE_SHEETNAME = ZCL_EXCEL_COMMON=>ESCAPE_STRING( LV_REPEAT_RANGE_SHEETNAME ). *--------------------------------------------------------------------* * Repeat-columns *--------------------------------------------------------------------* - IF me->print_title_col_from IS NOT INITIAL. - CONCATENATE lv_repeat_range_sheetname - '!$' me->print_title_col_from - ':$' me->print_title_col_to - INTO lv_repeat_range_col. - ENDIF. + if ME->PRINT_TITLE_COL_FROM is not initial. + concatenate LV_REPEAT_RANGE_SHEETNAME + '!$' ME->PRINT_TITLE_COL_FROM + ':$' ME->PRINT_TITLE_COL_TO + into LV_REPEAT_RANGE_COL. + endif. *--------------------------------------------------------------------* * Repeat-rows *--------------------------------------------------------------------* - IF me->print_title_row_from IS NOT INITIAL. - lv_row_char_from = me->print_title_row_from. - lv_row_char_to = me->print_title_row_to. - CONCATENATE '!$' lv_row_char_from - ':$' lv_row_char_to - INTO lv_repeat_range_row. - CONDENSE lv_repeat_range_row NO-GAPS. - CONCATENATE lv_repeat_range_sheetname - lv_repeat_range_row - INTO lv_repeat_range_row. - ENDIF. + if ME->PRINT_TITLE_ROW_FROM is not initial. + LV_ROW_CHAR_FROM = ME->PRINT_TITLE_ROW_FROM. + LV_ROW_CHAR_TO = ME->PRINT_TITLE_ROW_TO. + concatenate '!$' LV_ROW_CHAR_FROM + ':$' LV_ROW_CHAR_TO + into LV_REPEAT_RANGE_ROW. + condense LV_REPEAT_RANGE_ROW no-gaps. + concatenate LV_REPEAT_RANGE_SHEETNAME + LV_REPEAT_RANGE_ROW + into LV_REPEAT_RANGE_ROW. + endif. *--------------------------------------------------------------------* * Concatenate repeat-rows and columns *--------------------------------------------------------------------* - IF lv_repeat_range_col IS INITIAL. - lv_repeat_range = lv_repeat_range_row. - ELSEIF lv_repeat_range_row IS INITIAL. - lv_repeat_range = lv_repeat_range_col. - ELSE. - CONCATENATE lv_repeat_range_col lv_repeat_range_row - INTO lv_repeat_range SEPARATED BY ','. - ENDIF. + if LV_REPEAT_RANGE_COL is initial. + LV_REPEAT_RANGE = LV_REPEAT_RANGE_ROW. + elseif LV_REPEAT_RANGE_ROW is initial. + LV_REPEAT_RANGE = LV_REPEAT_RANGE_COL. + else. + concatenate LV_REPEAT_RANGE_COL LV_REPEAT_RANGE_ROW + into LV_REPEAT_RANGE separated by ','. + endif. - lo_range->set_range_value( lv_repeat_range ). - ENDIF. + LO_RANGE->SET_RANGE_VALUE( LV_REPEAT_RANGE ). + endif. endmethod. -method SET_CELL. + method SET_CELL. - DATA: lv_column TYPE zexcel_cell_column, - ls_sheet_content TYPE zexcel_s_cell_data, - lv_row_alpha TYPE string, - lv_col_alpha TYPE zexcel_cell_column_alpha, - lv_value TYPE zexcel_cell_value, - lv_data_type TYPE zexcel_cell_data_type, - lv_value_type TYPE abap_typekind, - lv_style_guid TYPE zexcel_cell_style, - lo_addit TYPE REF TO cl_abap_elemdescr, - lo_value TYPE REF TO data, - lo_value_new TYPE REF TO data. + data: LV_COLUMN type ZEXCEL_CELL_COLUMN, + LS_SHEET_CONTENT type ZEXCEL_S_CELL_DATA, + LV_ROW_ALPHA type STRING, + LV_COL_ALPHA type ZEXCEL_CELL_COLUMN_ALPHA, + LV_VALUE type ZEXCEL_CELL_VALUE, + LV_DATA_TYPE type ZEXCEL_CELL_DATA_TYPE, + LV_VALUE_TYPE type ABAP_TYPEKIND, + LV_STYLE_GUID type ZEXCEL_CELL_STYLE, + LO_ADDIT type ref to CL_ABAP_ELEMDESCR, + LO_VALUE type ref to DATA, + LO_VALUE_NEW type ref to DATA. - FIELD-SYMBOLS: TYPE zexcel_s_cell_data, - TYPE numeric, - TYPE d, - TYPE t, - TYPE simple. + field-symbols: type ZEXCEL_S_CELL_DATA, + type NUMERIC, + type D, + type T, + type SIMPLE. - IF ip_value IS NOT SUPPLIED AND ip_formula IS NOT SUPPLIED. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Please provide the value or formula'. - ENDIF. + if IP_VALUE is not supplied and IP_FORMULA is not supplied. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Please provide the value or formula'. + endif. * Begin of change issue #152 - don't touch exisiting style if only value is passed * lv_style_guid = ip_style. - lv_column = zcl_excel_common=>convert_column2int( ip_column ). - READ TABLE sheet_content ASSIGNING WITH TABLE KEY cell_row = ip_row " Changed to access via table key , Stefan Schmöcker, 2013-08-03 - cell_column = lv_column. - IF sy-subrc = 0. - IF ip_style IS INITIAL. - " If no style is provided as method-parameter and cell is found use cell's current style - lv_style_guid = -cell_style. - ELSE. - " Style provided as method-parameter --> use this - lv_style_guid = ip_style. - ENDIF. - ELSE. - " No cell found --> use supplied style even if empty - lv_style_guid = ip_style. - ENDIF. + LV_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN ). + read table SHEET_CONTENT assigning with table key CELL_ROW = IP_ROW " Changed to access via table key , Stefan Schmöcker, 2013-08-03 + CELL_COLUMN = LV_COLUMN. + if SY-SUBRC = 0. + if IP_STYLE is initial. + " If no style is provided as method-parameter and cell is found use cell's current style + LV_STYLE_GUID = -CELL_STYLE. + else. + " Style provided as method-parameter --> use this + LV_STYLE_GUID = IP_STYLE. + endif. + else. + " No cell found --> use supplied style even if empty + LV_STYLE_GUID = IP_STYLE. + endif. * End of change issue #152 - don't touch exisiting style if only value is passed - IF ip_value IS SUPPLIED. - "if data type is passed just write the value. Otherwise map abap type to excel and perform conversion - "IP_DATA_TYPE is passed by excel reader so source types are preserved + if IP_VALUE is supplied. + "if data type is passed just write the value. Otherwise map abap type to excel and perform conversion + "IP_DATA_TYPE is passed by excel reader so source types are preserved *First we get reference into local var. - CREATE DATA lo_value LIKE ip_value. - ASSIGN lo_value->* TO . - = ip_value. - IF ip_data_type IS SUPPLIED. - IF ip_abap_type IS NOT SUPPLIED. - get_value_type( EXPORTING ip_value = ip_value - IMPORTING ep_value = ) . - ENDIF. - lv_value = . - lv_data_type = ip_data_type. - ELSE. - IF ip_abap_type IS SUPPLIED. - lv_value_type = ip_abap_type. - ELSE. - get_value_type( EXPORTING ip_value = ip_value - IMPORTING ep_value = - ep_value_type = lv_value_type ). - ENDIF. - CASE lv_value_type. - WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2. - lo_addit = cl_abap_elemdescr=>get_i( ). - CREATE DATA lo_value_new TYPE HANDLE lo_addit. - ASSIGN lo_value_new->* TO . - IF sy-subrc = 0. - = . - lv_value = zcl_excel_common=>number_to_excel_string( ip_value = ). - ENDIF. + create data LO_VALUE like IP_VALUE. + assign LO_VALUE->* to . + = IP_VALUE. + if IP_DATA_TYPE is supplied. + if IP_ABAP_TYPE is not supplied. + GET_VALUE_TYPE( exporting IP_VALUE = IP_VALUE + importing EP_VALUE = ) . + endif. + LV_VALUE = . + LV_DATA_TYPE = IP_DATA_TYPE. + else. + if IP_ABAP_TYPE is supplied. + LV_VALUE_TYPE = IP_ABAP_TYPE. + else. + GET_VALUE_TYPE( exporting IP_VALUE = IP_VALUE + importing EP_VALUE = + EP_VALUE_TYPE = LV_VALUE_TYPE ). + endif. + case LV_VALUE_TYPE. + when CL_ABAP_TYPEDESCR=>TYPEKIND_INT or CL_ABAP_TYPEDESCR=>TYPEKIND_INT1 or CL_ABAP_TYPEDESCR=>TYPEKIND_INT2. + LO_ADDIT = CL_ABAP_ELEMDESCR=>GET_I( ). + create data LO_VALUE_NEW type handle LO_ADDIT. + assign LO_VALUE_NEW->* to . + if SY-SUBRC = 0. + = . + LV_VALUE = ZCL_EXCEL_COMMON=>NUMBER_TO_EXCEL_STRING( IP_VALUE = ). + endif. - WHEN cl_abap_typedescr=>typekind_float OR cl_abap_typedescr=>typekind_packed. - lo_addit = cl_abap_elemdescr=>get_f( ). - CREATE DATA lo_value_new TYPE HANDLE lo_addit. - ASSIGN lo_value_new->* TO . - IF sy-subrc = 0. - = . - lv_value = zcl_excel_common=>number_to_excel_string( ip_value = ). - ENDIF. + when CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT or CL_ABAP_TYPEDESCR=>TYPEKIND_PACKED. + LO_ADDIT = CL_ABAP_ELEMDESCR=>GET_F( ). + create data LO_VALUE_NEW type handle LO_ADDIT. + assign LO_VALUE_NEW->* to . + if SY-SUBRC = 0. + = . + LV_VALUE = ZCL_EXCEL_COMMON=>NUMBER_TO_EXCEL_STRING( IP_VALUE = ). + endif. - WHEN cl_abap_typedescr=>typekind_char OR cl_abap_typedescr=>typekind_string OR cl_abap_typedescr=>typekind_num OR - cl_abap_typedescr=>typekind_hex. - lv_value = . - lv_data_type = 's'. + when CL_ABAP_TYPEDESCR=>TYPEKIND_CHAR or CL_ABAP_TYPEDESCR=>TYPEKIND_STRING or CL_ABAP_TYPEDESCR=>TYPEKIND_NUM or + CL_ABAP_TYPEDESCR=>TYPEKIND_HEX. + LV_VALUE = . + LV_DATA_TYPE = 's'. - WHEN cl_abap_typedescr=>typekind_date. - lo_addit = cl_abap_elemdescr=>get_d( ). - CREATE DATA lo_value_new TYPE HANDLE lo_addit. - ASSIGN lo_value_new->* TO . - IF sy-subrc = 0. - = . - lv_value = zcl_excel_common=>date_to_excel_string( ip_value = ) . - ENDIF. + when CL_ABAP_TYPEDESCR=>TYPEKIND_DATE. + LO_ADDIT = CL_ABAP_ELEMDESCR=>GET_D( ). + create data LO_VALUE_NEW type handle LO_ADDIT. + assign LO_VALUE_NEW->* to . + if SY-SUBRC = 0. + = . + LV_VALUE = ZCL_EXCEL_COMMON=>DATE_TO_EXCEL_STRING( IP_VALUE = ) . + endif. * Begin of change issue #152 - don't touch exisiting style if only value is passed * Moved to end of routine - apply date-format even if other styleinformation is passed * IF ip_style IS NOT SUPPLIED. "get default date format in case parameter is initial @@ -4618,14 +4599,14 @@ method SET_CELL. * ENDIF. * End of change issue #152 - don't touch exisiting style if only value is passed - WHEN cl_abap_typedescr=>typekind_time. - lo_addit = cl_abap_elemdescr=>get_t( ). - CREATE DATA lo_value_new TYPE HANDLE lo_addit. - ASSIGN lo_value_new->* TO . - IF sy-subrc = 0. - = . - lv_value = zcl_excel_common=>time_to_excel_string( ip_value = ). - ENDIF. + when CL_ABAP_TYPEDESCR=>TYPEKIND_TIME. + LO_ADDIT = CL_ABAP_ELEMDESCR=>GET_T( ). + create data LO_VALUE_NEW type handle LO_ADDIT. + assign LO_VALUE_NEW->* to . + if SY-SUBRC = 0. + = . + LV_VALUE = ZCL_EXCEL_COMMON=>TIME_TO_EXCEL_STRING( IP_VALUE = ). + endif. * Begin of change issue #152 - don't touch exisiting style if only value is passed * Moved to end of routine - apply time-format even if other styleinformation is passed * IF ip_style IS NOT SUPPLIED. "get default time format for user in case parameter is initial @@ -4635,20 +4616,20 @@ method SET_CELL. * ENDIF. * End of change issue #152 - don't touch exisiting style if only value is passed - WHEN OTHERS. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Invalid data type of input value'. - ENDCASE. - ENDIF. + when others. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Invalid data type of input value'. + endcase. + endif. - ENDIF. + endif. - IF ip_hyperlink IS BOUND. - ip_hyperlink->set_cell_reference( ip_column = ip_column - ip_row = ip_row ). - me->hyperlinks->add( ip_hyperlink ). - ENDIF. + if IP_HYPERLINK is bound. + IP_HYPERLINK->SET_CELL_REFERENCE( IP_COLUMN = IP_COLUMN + IP_ROW = IP_ROW ). + ME->HYPERLINKS->ADD( IP_HYPERLINK ). + endif. * Begin of change issue #152 - don't touch exisiting style if only value is passed * Read table moved up, so that current style may be evaluated @@ -4658,393 +4639,393 @@ method SET_CELL. * cell_column = lv_column. * * IF sy-subrc EQ 0. - IF IS ASSIGNED. + if is assigned. * End of change issue #152 - don't touch exisiting style if only value is passed - -cell_value = lv_value. - -cell_formula = ip_formula. - -cell_style = lv_style_guid. - -data_type = lv_data_type. - ELSE. - ls_sheet_content-cell_row = ip_row. - ls_sheet_content-cell_column = lv_column. - ls_sheet_content-cell_value = lv_value. - ls_sheet_content-cell_formula = ip_formula. - ls_sheet_content-cell_style = lv_style_guid. - ls_sheet_content-data_type = lv_data_type. - lv_row_alpha = ip_row. + -CELL_VALUE = LV_VALUE. + -CELL_FORMULA = IP_FORMULA. + -CELL_STYLE = LV_STYLE_GUID. + -DATA_TYPE = LV_DATA_TYPE. + else. + LS_SHEET_CONTENT-CELL_ROW = IP_ROW. + LS_SHEET_CONTENT-CELL_COLUMN = LV_COLUMN. + LS_SHEET_CONTENT-CELL_VALUE = LV_VALUE. + LS_SHEET_CONTENT-CELL_FORMULA = IP_FORMULA. + LS_SHEET_CONTENT-CELL_STYLE = LV_STYLE_GUID. + LS_SHEET_CONTENT-DATA_TYPE = LV_DATA_TYPE. + LV_ROW_ALPHA = IP_ROW. * SHIFT lv_row_alpha RIGHT DELETING TRAILING space."del #152 - replaced with condense - should be faster * SHIFT lv_row_alpha LEFT DELETING LEADING space. "del #152 - replaced with condense - should be faster - CONDENSE lv_row_alpha NO-GAPS. "ins #152 - replaced 2 shifts - should be faster - lv_col_alpha = zcl_excel_common=>convert_column2alpha( ip_column ). " issue #155 - less restrictive typing for ip_column - CONCATENATE lv_col_alpha lv_row_alpha INTO ls_sheet_content-cell_coords. " issue #155 - less restrictive typing for ip_column - INSERT ls_sheet_content INTO TABLE sheet_content ASSIGNING . "ins #152 - Now always holds the data + condense LV_ROW_ALPHA no-gaps. "ins #152 - replaced 2 shifts - should be faster + LV_COL_ALPHA = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( IP_COLUMN ). " issue #155 - less restrictive typing for ip_column + concatenate LV_COL_ALPHA LV_ROW_ALPHA into LS_SHEET_CONTENT-CELL_COORDS. " issue #155 - less restrictive typing for ip_column + insert LS_SHEET_CONTENT into table SHEET_CONTENT assigning . "ins #152 - Now always holds the data * APPEND ls_sheet_content TO sheet_content. * SORT sheet_content BY cell_row cell_column. - " me->update_dimension_range( ). + " me->update_dimension_range( ). - ENDIF. + endif. * Begin of change issue #152 - don't touch exisiting style if only value is passed * For Date- or Timefields change the formatcode if nothing is set yet * Enhancement option: Check if existing formatcode is a date/ or timeformat * If not, use default - DATA: lo_format_code_datetime TYPE zexcel_number_format. - DATA: stylemapping TYPE zexcel_s_stylemapping. - CASE lv_value_type. - WHEN cl_abap_typedescr=>typekind_date. - TRY. - stylemapping = me->excel->get_style_to_guid( -cell_style ). - CATCH zcx_excel . - ENDTRY. - IF stylemapping-complete_stylex-number_format-format_code IS INITIAL OR - stylemapping-complete_style-number_format-format_code IS INITIAL. - lo_format_code_datetime = zcl_excel_style_number_format=>c_format_date_std. - ELSE. - lo_format_code_datetime = stylemapping-complete_style-number_format-format_code. - ENDIF. - me->change_cell_style( ip_column = ip_column - ip_row = ip_row - ip_number_format_format_code = lo_format_code_datetime ). + data: LO_FORMAT_CODE_DATETIME type ZEXCEL_NUMBER_FORMAT. + data: STYLEMAPPING type ZEXCEL_S_STYLEMAPPING. + case LV_VALUE_TYPE. + when CL_ABAP_TYPEDESCR=>TYPEKIND_DATE. + try. + STYLEMAPPING = ME->EXCEL->GET_STYLE_TO_GUID( -CELL_STYLE ). + catch ZCX_EXCEL . + endtry. + if STYLEMAPPING-COMPLETE_STYLEX-NUMBER_FORMAT-FORMAT_CODE is initial or + STYLEMAPPING-COMPLETE_STYLE-NUMBER_FORMAT-FORMAT_CODE is initial. + LO_FORMAT_CODE_DATETIME = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_STD. + else. + LO_FORMAT_CODE_DATETIME = STYLEMAPPING-COMPLETE_STYLE-NUMBER_FORMAT-FORMAT_CODE. + endif. + ME->CHANGE_CELL_STYLE( IP_COLUMN = IP_COLUMN + IP_ROW = IP_ROW + IP_NUMBER_FORMAT_FORMAT_CODE = LO_FORMAT_CODE_DATETIME ). - WHEN cl_abap_typedescr=>typekind_time. - TRY. - stylemapping = me->excel->get_style_to_guid( -cell_style ). - CATCH zcx_excel . - ENDTRY. - IF stylemapping-complete_stylex-number_format-format_code IS INITIAL OR - stylemapping-complete_style-number_format-format_code IS INITIAL. - lo_format_code_datetime = zcl_excel_style_number_format=>c_format_date_time6. - ELSE. - lo_format_code_datetime = stylemapping-complete_style-number_format-format_code. - ENDIF. - me->change_cell_style( ip_column = ip_column - ip_row = ip_row - ip_number_format_format_code = lo_format_code_datetime ). + when CL_ABAP_TYPEDESCR=>TYPEKIND_TIME. + try. + STYLEMAPPING = ME->EXCEL->GET_STYLE_TO_GUID( -CELL_STYLE ). + catch ZCX_EXCEL . + endtry. + if STYLEMAPPING-COMPLETE_STYLEX-NUMBER_FORMAT-FORMAT_CODE is initial or + STYLEMAPPING-COMPLETE_STYLE-NUMBER_FORMAT-FORMAT_CODE is initial. + LO_FORMAT_CODE_DATETIME = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_DATE_TIME6. + else. + LO_FORMAT_CODE_DATETIME = STYLEMAPPING-COMPLETE_STYLE-NUMBER_FORMAT-FORMAT_CODE. + endif. + ME->CHANGE_CELL_STYLE( IP_COLUMN = IP_COLUMN + IP_ROW = IP_ROW + IP_NUMBER_FORMAT_FORMAT_CODE = LO_FORMAT_CODE_DATETIME ). - ENDCASE. + endcase. * End of change issue #152 - don't touch exisiting style if only value is passed * Fix issue #162 - lv_value = ip_value. - IF lv_value CS cl_abap_char_utilities=>cr_lf. - me->change_cell_style( ip_column = ip_column - ip_row = ip_row - ip_alignment_wraptext = abap_true ). - ENDIF. + LV_VALUE = IP_VALUE. + if LV_VALUE cs CL_ABAP_CHAR_UTILITIES=>CR_LF. + ME->CHANGE_CELL_STYLE( IP_COLUMN = IP_COLUMN + IP_ROW = IP_ROW + IP_ALIGNMENT_WRAPTEXT = ABAP_TRUE ). + endif. * End of Fix issue #162 endmethod. -method SET_CELL_FORMULA. - DATA: - lv_column TYPE zexcel_cell_column, - ls_sheet_content LIKE LINE OF me->sheet_content. + method SET_CELL_FORMULA. + data: + LV_COLUMN type ZEXCEL_CELL_COLUMN, + LS_SHEET_CONTENT like line of ME->SHEET_CONTENT. - FIELD-SYMBOLS: - LIKE LINE OF me->sheet_content. + field-symbols: + like line of ME->SHEET_CONTENT. *--------------------------------------------------------------------* * Get cell to set formula into *--------------------------------------------------------------------* - lv_column = zcl_excel_common=>convert_column2int( ip_column ). - READ TABLE me->sheet_content ASSIGNING WITH TABLE KEY cell_row = ip_row - cell_column = lv_column. - IF sy-subrc <> 0. " Create new entry in sheet_content if necessary - CHECK ip_formula IS INITIAL. " no need to create new entry in sheet_content when no formula is passed - ls_sheet_content-cell_row = ip_row. - ls_sheet_content-cell_column = lv_column. - INSERT ls_sheet_content INTO TABLE me->sheet_content ASSIGNING . - ENDIF. + LV_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN ). + read table ME->SHEET_CONTENT assigning with table key CELL_ROW = IP_ROW + CELL_COLUMN = LV_COLUMN. + if SY-SUBRC <> 0. " Create new entry in sheet_content if necessary + check IP_FORMULA is initial. " no need to create new entry in sheet_content when no formula is passed + LS_SHEET_CONTENT-CELL_ROW = IP_ROW. + LS_SHEET_CONTENT-CELL_COLUMN = LV_COLUMN. + insert LS_SHEET_CONTENT into table ME->SHEET_CONTENT assigning . + endif. *--------------------------------------------------------------------* * Fieldsymbol now holds the relevant cell *--------------------------------------------------------------------* - -cell_formula = ip_formula. + -CELL_FORMULA = IP_FORMULA. endmethod. -METHOD set_cell_style. + method SET_CELL_STYLE. - DATA: lv_column TYPE zexcel_cell_column, - lv_style_guid TYPE zexcel_cell_style. + data: LV_COLUMN type ZEXCEL_CELL_COLUMN, + LV_STYLE_GUID type ZEXCEL_CELL_STYLE. - FIELD-SYMBOLS: TYPE zexcel_s_cell_data. + field-symbols: type ZEXCEL_S_CELL_DATA. - lv_style_guid = ip_style. + LV_STYLE_GUID = IP_STYLE. - lv_column = zcl_excel_common=>convert_column2int( ip_column ). + LV_COLUMN = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN ). - READ TABLE sheet_content ASSIGNING WITH KEY cell_row = ip_row - cell_column = lv_column. + read table SHEET_CONTENT assigning with key CELL_ROW = IP_ROW + CELL_COLUMN = LV_COLUMN. - IF sy-subrc EQ 0. - -cell_style = lv_style_guid. - ELSE. - set_cell( ip_column = ip_column ip_row = ip_row ip_value = '' ip_style = ip_style ). - ENDIF. + if SY-SUBRC eq 0. + -CELL_STYLE = LV_STYLE_GUID. + else. + SET_CELL( IP_COLUMN = IP_COLUMN IP_ROW = IP_ROW IP_VALUE = '' IP_STYLE = IP_STYLE ). + endif. -ENDMETHOD. + endmethod. -method SET_COLUMN_WIDTH. - DATA: lo_column TYPE REF TO zcl_excel_column. - DATA: width TYPE float. + method SET_COLUMN_WIDTH. + data: LO_COLUMN type ref to ZCL_EXCEL_COLUMN. + data: WIDTH type FLOAT. - lo_column = me->get_column( ip_column ). + LO_COLUMN = ME->GET_COLUMN( IP_COLUMN ). * if a fix size is supplied use this - IF ip_width_fix IS SUPPLIED. - TRY. - width = ip_width_fix. - IF width <= 0. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Please supply a positive number as column-width'. - ENDIF. - lo_column->set_width( width ). - EXIT. - CATCH cx_sy_conversion_no_number. + if IP_WIDTH_FIX is supplied. + try. + WIDTH = IP_WIDTH_FIX. + if WIDTH <= 0. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Please supply a positive number as column-width'. + endif. + LO_COLUMN->SET_WIDTH( WIDTH ). + exit. + catch CX_SY_CONVERSION_NO_NUMBER. * Strange stuff passed --> raise error - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Unable to interpret supplied input as number'. - ENDTRY. - ENDIF. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Unable to interpret supplied input as number'. + endtry. + endif. * If we get down to here, we have to use whatever is found in autosize. - lo_column->set_auto_size( ip_width_autosize ). + LO_COLUMN->SET_AUTO_SIZE( IP_WIDTH_AUTOSIZE ). endmethod. -method SET_DEFAULT_EXCEL_DATE_FORMAT. + method SET_DEFAULT_EXCEL_DATE_FORMAT. - IF ip_default_excel_date_format IS INITIAL. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Default date format cannot be blank'. - ENDIF. + if IP_DEFAULT_EXCEL_DATE_FORMAT is initial. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Default date format cannot be blank'. + endif. - default_excel_date_format = ip_default_excel_date_format. + DEFAULT_EXCEL_DATE_FORMAT = IP_DEFAULT_EXCEL_DATE_FORMAT. endmethod. -METHOD set_merge. + method SET_MERGE. - DATA: ls_merge TYPE mty_merge, - lv_errormessage TYPE string. + data: LS_MERGE type MTY_MERGE, + LV_ERRORMESSAGE type STRING. *--------------------------------------------------------------------* * Build new range area to insert into range table *--------------------------------------------------------------------* - ls_merge-row_from = ip_row. - IF ip_row IS SUPPLIED AND ip_row IS NOT INITIAL AND ip_row_to IS NOT SUPPLIED. - ls_merge-row_to = ls_merge-row_from. - ELSE. - ls_merge-row_to = ip_row_to. - ENDIF. - IF ls_merge-row_from > ls_merge-row_to. - lv_errormessage = 'Merge: First row larger then last row'(405). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + LS_MERGE-ROW_FROM = IP_ROW. + if IP_ROW is supplied and IP_ROW is not initial and IP_ROW_TO is not supplied. + LS_MERGE-ROW_TO = LS_MERGE-ROW_FROM. + else. + LS_MERGE-ROW_TO = IP_ROW_TO. + endif. + if LS_MERGE-ROW_FROM > LS_MERGE-ROW_TO. + LV_ERRORMESSAGE = 'Merge: First row larger then last row'(405). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - ls_merge-col_from = zcl_excel_common=>convert_column2int( ip_column_start ). - IF ip_column_start IS SUPPLIED AND ip_column_start IS NOT INITIAL AND ip_column_end IS NOT SUPPLIED. - ls_merge-col_to = ls_merge-col_from. - ELSE. - ls_merge-col_to = zcl_excel_common=>convert_column2int( ip_column_end ). - ENDIF. - IF ls_merge-col_from > ls_merge-col_to. - lv_errormessage = 'Merge: First column larger then last column'(406). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + LS_MERGE-COL_FROM = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN_START ). + if IP_COLUMN_START is supplied and IP_COLUMN_START is not initial and IP_COLUMN_END is not supplied. + LS_MERGE-COL_TO = LS_MERGE-COL_FROM. + else. + LS_MERGE-COL_TO = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN_END ). + endif. + if LS_MERGE-COL_FROM > LS_MERGE-COL_TO. + LV_ERRORMESSAGE = 'Merge: First column larger then last column'(406). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. *--------------------------------------------------------------------* * Check merge not overlapping with existing merges *--------------------------------------------------------------------* - LOOP AT me->mt_merged_cells TRANSPORTING NO FIELDS WHERE NOT ( row_from > ls_merge-row_to - OR row_to < ls_merge-row_from - OR col_from > ls_merge-col_to - OR col_to < ls_merge-col_from ). - lv_errormessage = 'Overlapping merges'(404). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. + loop at ME->MT_MERGED_CELLS transporting no fields where not ( ROW_FROM > LS_MERGE-ROW_TO + or ROW_TO < LS_MERGE-ROW_FROM + or COL_FROM > LS_MERGE-COL_TO + or COL_TO < LS_MERGE-COL_FROM ). + LV_ERRORMESSAGE = 'Overlapping merges'(404). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. - ENDLOOP. + endloop. *--------------------------------------------------------------------* * Everything seems ok --> add to merge table *--------------------------------------------------------------------* - INSERT ls_merge INTO TABLE me->mt_merged_cells. + insert LS_MERGE into table ME->MT_MERGED_CELLS. -ENDMETHOD. - - -method SET_PRINT_GRIDLINES. - me->print_gridlines = i_print_gridlines. endmethod. -METHOD set_row_height. - DATA: lo_row TYPE REF TO zcl_excel_row. - DATA: height TYPE float. + method SET_PRINT_GRIDLINES. + ME->PRINT_GRIDLINES = I_PRINT_GRIDLINES. + endmethod. - lo_row = me->get_row( ip_row ). + + method SET_ROW_HEIGHT. + data: LO_ROW type ref to ZCL_EXCEL_ROW. + data: HEIGHT type FLOAT. + + LO_ROW = ME->GET_ROW( IP_ROW ). * if a fix size is supplied use this - TRY. - height = ip_height_fix. - IF height <= 0. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Please supply a positive number as row-height'. - ENDIF. - lo_row->set_row_height( height ). - EXIT. - CATCH cx_sy_conversion_no_number. + try. + HEIGHT = IP_HEIGHT_FIX. + if HEIGHT <= 0. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Please supply a positive number as row-height'. + endif. + LO_ROW->SET_ROW_HEIGHT( HEIGHT ). + exit. + catch CX_SY_CONVERSION_NO_NUMBER. * Strange stuff passed --> raise error - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Unable to interpret supplied input as number'. - ENDTRY. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Unable to interpret supplied input as number'. + endtry. -ENDMETHOD. - - -METHOD set_row_outline. - - DATA: ls_row_outline LIKE LINE OF me->mt_row_outlines. - FIELD-SYMBOLS: LIKE LINE OF me->mt_row_outlines. - - READ TABLE me->mt_row_outlines ASSIGNING WITH TABLE KEY row_from = iv_row_from - row_to = iv_row_to. - IF sy-subrc <> 0. - IF iv_row_from <= 0. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'First row of outline must be a positive number'. - ENDIF. - IF iv_row_to < iv_row_from. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Last row of outline may not be less than first line of outline'. - ENDIF. - ls_row_outline-row_from = iv_row_from. - ls_row_outline-row_to = iv_row_to. - INSERT ls_row_outline INTO TABLE me->mt_row_outlines ASSIGNING . - ENDIF. - - CASE iv_collapsed. - - WHEN abap_true - OR abap_false. - -collapsed = iv_collapsed. - - WHEN OTHERS. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Unknown collapse state'. - - ENDCASE. -ENDMETHOD. - - -method SET_SHOW_GRIDLINES. - me->show_gridlines = i_show_gridlines. endmethod. -method SET_SHOW_ROWCOLHEADERS. - me->show_rowcolheaders = i_show_rowcolheaders. + method SET_ROW_OUTLINE. + + data: LS_ROW_OUTLINE like line of ME->MT_ROW_OUTLINES. + field-symbols: like line of ME->MT_ROW_OUTLINES. + + read table ME->MT_ROW_OUTLINES assigning with table key ROW_FROM = IV_ROW_FROM + ROW_TO = IV_ROW_TO. + if SY-SUBRC <> 0. + if IV_ROW_FROM <= 0. + raise exception type ZCX_EXCEL + exporting + ERROR = 'First row of outline must be a positive number'. + endif. + if IV_ROW_TO < IV_ROW_FROM. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Last row of outline may not be less than first line of outline'. + endif. + LS_ROW_OUTLINE-ROW_FROM = IV_ROW_FROM. + LS_ROW_OUTLINE-ROW_TO = IV_ROW_TO. + insert LS_ROW_OUTLINE into table ME->MT_ROW_OUTLINES assigning . + endif. + + case IV_COLLAPSED. + + when ABAP_TRUE + or ABAP_FALSE. + -COLLAPSED = IV_COLLAPSED. + + when others. + raise exception type ZCX_EXCEL + exporting + ERROR = 'Unknown collapse state'. + + endcase. endmethod. -method SET_TABCOLOR. - me->tabcolor = iv_tabcolor. + method SET_SHOW_GRIDLINES. + ME->SHOW_GRIDLINES = I_SHOW_GRIDLINES. endmethod. -method SET_TABLE. - - DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, - lr_data TYPE REF TO data, - ls_header TYPE x030l, - lt_dfies TYPE ddfields, - 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. + method SET_SHOW_ROWCOLHEADERS. + ME->SHOW_ROWCOLHEADERS = I_SHOW_ROWCOLHEADERS. + endmethod. - FIELD-SYMBOLS: TYPE ANY, - TYPE ANY, - TYPE dfies. + method SET_TABCOLOR. + ME->TABCOLOR = IV_TABCOLOR. + endmethod. - 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. + method SET_TABLE. - lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + data: LO_TABDESCR type ref to CL_ABAP_STRUCTDESCR, + LR_DATA type ref to DATA, + LS_HEADER type X030L, + LT_DFIES type DDFIELDS, + 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. - ls_header = lo_tabdescr->get_ddic_header( ). - lt_dfies = lo_tabdescr->get_ddic_field_list( ). + field-symbols: type ANY, + type ANY, + type DFIES. + + 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 . - lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). + loop at LT_DFIES assigning . + LV_COLUMN_ALPHA = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( LV_COLUMN_INT ). - IF ip_no_header = abap_false. - " First of all write column header - lv_cell_value = -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 ). - IF ip_transpose = abap_true. - ADD 1 TO lv_column_int. - ELSE. - ADD 1 TO lv_row_int. - ENDIF. - ENDIF. + if IP_NO_HEADER = ABAP_FALSE. + " First of all write column header + LV_CELL_VALUE = -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 ). + if IP_TRANSPOSE = ABAP_TRUE. + add 1 to LV_COLUMN_INT. + else. + add 1 to LV_ROW_INT. + endif. + endif. - LOOP AT ip_table ASSIGNING . - lv_column_alpha = zcl_excel_common=>convert_column2alpha( lv_column_int ). - ASSIGN COMPONENT -fieldname OF STRUCTURE TO . - MOVE 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 ). - IF ip_transpose = abap_true. - ADD 1 TO lv_column_int. - ELSE. - ADD 1 TO lv_row_int. - ENDIF. - ENDLOOP. - IF ip_transpose = abap_true. - lv_column_int = zcl_excel_common=>convert_column2int( ip_top_left_column ). - ADD 1 TO lv_row_int. - ELSE. - lv_row_int = ip_top_left_row. - ADD 1 TO lv_column_int. - ENDIF. - ENDLOOP. + loop at IP_TABLE assigning . + LV_COLUMN_ALPHA = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2ALPHA( LV_COLUMN_INT ). + assign component -FIELDNAME of structure to . + move 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 ). + if IP_TRANSPOSE = ABAP_TRUE. + add 1 to LV_COLUMN_INT. + else. + add 1 to LV_ROW_INT. + endif. + endloop. + if IP_TRANSPOSE = ABAP_TRUE. + LV_COLUMN_INT = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_TOP_LEFT_COLUMN ). + add 1 to LV_ROW_INT. + else. + LV_ROW_INT = IP_TOP_LEFT_ROW. + add 1 to LV_COLUMN_INT. + endif. + endloop. endmethod. -method SET_TITLE. + method SET_TITLE. *--------------------------------------------------------------------* * ToDos: * 2do §1 The current coding for replacing a named ranges name @@ -5063,15 +5044,15 @@ method SET_TITLE. * - Stefan Schmoecker, 2012-12-02 * changes: added additional check for ' as first character *--------------------------------------------------------------------* - DATA: lo_worksheets_iterator TYPE REF TO cl_object_collection_iterator, - lo_worksheet TYPE REF TO zcl_excel_worksheet, - errormessage TYPE string, - lv_rangesheetname_old TYPE string, - lv_rangesheetname_new TYPE string, - lo_ranges_iterator TYPE REF TO cl_object_collection_iterator, - lo_range TYPE REF TO zcl_excel_range, - lv_range_value TYPE zexcel_range_value, - lv_errormessage TYPE string. " Can't pass '...'(abc) to exception-class + data: LO_WORKSHEETS_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET, + ERRORMESSAGE type STRING, + LV_RANGESHEETNAME_OLD type STRING, + LV_RANGESHEETNAME_NEW type STRING, + LO_RANGES_ITERATOR type ref to CL_OBJECT_COLLECTION_ITERATOR, + LO_RANGE type ref to ZCL_EXCEL_RANGE, + LV_RANGE_VALUE type ZEXCEL_RANGE_VALUE, + LV_ERRORMESSAGE type STRING. " Can't pass '...'(abc) to exception-class *--------------------------------------------------------------------* @@ -5079,45 +5060,45 @@ method SET_TITLE. * Illegal characters are: / \ [ ] * ? : --> http://msdn.microsoft.com/en-us/library/ff837411.aspx * Illegal characters not in documentation: ' as first character *--------------------------------------------------------------------* - IF ip_title CA '/\[]*?:'. - lv_errormessage = 'Found illegal character in sheetname. List of forbidden characters: /\[]*?:'(402). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + if IP_TITLE ca '/\[]*?:'. + LV_ERRORMESSAGE = 'Found illegal character in sheetname. List of forbidden characters: /\[]*?:'(402). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - IF ip_title IS NOT INITIAL AND ip_title(1) = `'`. - lv_errormessage = 'Sheetname may not start with &'(403). " & used instead of ' to allow fallbacklanguage - REPLACE '&' IN lv_errormessage WITH `'`. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + if IP_TITLE is not initial and IP_TITLE(1) = `'`. + LV_ERRORMESSAGE = 'Sheetname may not start with &'(403). " & used instead of ' to allow fallbacklanguage + replace '&' in LV_ERRORMESSAGE with `'`. + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. *--------------------------------------------------------------------* * Check whether title is unique in workbook *--------------------------------------------------------------------* - lo_worksheets_iterator = me->excel->get_worksheets_iterator( ). - WHILE lo_worksheets_iterator->has_next( ) = 'X'. + LO_WORKSHEETS_ITERATOR = ME->EXCEL->GET_WORKSHEETS_ITERATOR( ). + while LO_WORKSHEETS_ITERATOR->HAS_NEXT( ) = 'X'. - lo_worksheet ?= lo_worksheets_iterator->get_next( ). - CHECK me->guid <> lo_worksheet->get_guid( ). " Don't check against itself - IF ip_title = lo_worksheet->get_title( ). " Not unique --> raise exception - errormessage = 'Duplicate sheetname &'. - REPLACE '&' IN errormessage WITH ip_title. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = errormessage. - ENDIF. + LO_WORKSHEET ?= LO_WORKSHEETS_ITERATOR->GET_NEXT( ). + check ME->GUID <> LO_WORKSHEET->GET_GUID( ). " Don't check against itself + if IP_TITLE = LO_WORKSHEET->GET_TITLE( ). " Not unique --> raise exception + ERRORMESSAGE = 'Duplicate sheetname &'. + replace '&' in ERRORMESSAGE with IP_TITLE. + raise exception type ZCX_EXCEL + exporting + ERROR = ERRORMESSAGE. + endif. - ENDWHILE. + endwhile. *--------------------------------------------------------------------* * Remember old sheetname and rename sheet to desired name *--------------------------------------------------------------------* - CONCATENATE me->title '!' INTO lv_rangesheetname_old. - me->title = ip_title. + concatenate ME->TITLE '!' into LV_RANGESHEETNAME_OLD. + ME->TITLE = IP_TITLE. *--------------------------------------------------------------------* * After changing this worksheet's title we have to adjust @@ -5127,262 +5108,262 @@ method SET_TITLE. * I fear it isn't - but this implementation is better then * nothing at all since it handles a supposed majority of cases *--------------------------------------------------------------------* - CONCATENATE me->title '!' INTO lv_rangesheetname_new. + concatenate ME->TITLE '!' into LV_RANGESHEETNAME_NEW. - lo_ranges_iterator = me->excel->get_ranges_iterator( ). - WHILE lo_ranges_iterator->has_next( ) = 'X'. + LO_RANGES_ITERATOR = ME->EXCEL->GET_RANGES_ITERATOR( ). + while LO_RANGES_ITERATOR->HAS_NEXT( ) = 'X'. - lo_range ?= lo_ranges_iterator->get_next( ). - lv_range_value = lo_range->get_value( ). - REPLACE ALL OCCURRENCES OF lv_rangesheetname_old IN lv_range_value WITH lv_rangesheetname_new. - IF sy-subrc = 0. - lo_range->set_range_value( lv_range_value ). - ENDIF. + LO_RANGE ?= LO_RANGES_ITERATOR->GET_NEXT( ). + LV_RANGE_VALUE = LO_RANGE->GET_VALUE( ). + replace all occurrences of LV_RANGESHEETNAME_OLD in LV_RANGE_VALUE with LV_RANGESHEETNAME_NEW. + if SY-SUBRC = 0. + LO_RANGE->SET_RANGE_VALUE( LV_RANGE_VALUE ). + endif. - ENDWHILE. + endwhile. endmethod. -METHOD update_dimension_range. + 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. + 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. - CHECK sheet_content IS NOT INITIAL. + check SHEET_CONTENT is not initial. * 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. + 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. + 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. + "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. + 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. + endmethod. -method ZIF_EXCEL_SHEET_PRINTSETTINGS~CLEAR_PRINT_REPEAT_COLUMNS. + method ZIF_EXCEL_SHEET_PRINTSETTINGS~CLEAR_PRINT_REPEAT_COLUMNS. *--------------------------------------------------------------------* * adjust internal representation *--------------------------------------------------------------------* - CLEAR: me->print_title_col_from, - me->print_title_col_to . + clear: ME->PRINT_TITLE_COL_FROM, + ME->PRINT_TITLE_COL_TO . *--------------------------------------------------------------------* * adjust corresponding range *--------------------------------------------------------------------* - me->print_title_set_range( ). + ME->PRINT_TITLE_SET_RANGE( ). endmethod. -method ZIF_EXCEL_SHEET_PRINTSETTINGS~CLEAR_PRINT_REPEAT_ROWS. + method ZIF_EXCEL_SHEET_PRINTSETTINGS~CLEAR_PRINT_REPEAT_ROWS. *--------------------------------------------------------------------* * adjust internal representation *--------------------------------------------------------------------* - CLEAR: me->print_title_row_from, - me->print_title_row_to . + clear: ME->PRINT_TITLE_ROW_FROM, + ME->PRINT_TITLE_ROW_TO . *--------------------------------------------------------------------* * adjust corresponding range *--------------------------------------------------------------------* - me->print_title_set_range( ). + ME->PRINT_TITLE_SET_RANGE( ). endmethod. -method ZIF_EXCEL_SHEET_PRINTSETTINGS~GET_PRINT_REPEAT_COLUMNS. - ev_columns_from = me->print_title_col_from. - ev_columns_to = me->print_title_col_to. + method ZIF_EXCEL_SHEET_PRINTSETTINGS~GET_PRINT_REPEAT_COLUMNS. + EV_COLUMNS_FROM = ME->PRINT_TITLE_COL_FROM. + EV_COLUMNS_TO = ME->PRINT_TITLE_COL_TO. endmethod. -method ZIF_EXCEL_SHEET_PRINTSETTINGS~GET_PRINT_REPEAT_ROWS. - ev_rows_from = me->print_title_row_from. - ev_rows_to = me->print_title_row_to. + method ZIF_EXCEL_SHEET_PRINTSETTINGS~GET_PRINT_REPEAT_ROWS. + EV_ROWS_FROM = ME->PRINT_TITLE_ROW_FROM. + EV_ROWS_TO = ME->PRINT_TITLE_ROW_TO. endmethod. -method ZIF_EXCEL_SHEET_PRINTSETTINGS~SET_PRINT_REPEAT_COLUMNS. + method ZIF_EXCEL_SHEET_PRINTSETTINGS~SET_PRINT_REPEAT_COLUMNS. *--------------------------------------------------------------------* * issue#235 - repeat rows/columns * - Stefan Schmöcker, 2012-12-02 *--------------------------------------------------------------------* - DATA: lv_col_from_int TYPE i, - lv_col_to_int TYPE i, - lv_errormessage TYPE string. + data: LV_COL_FROM_INT type I, + LV_COL_TO_INT type I, + LV_ERRORMESSAGE type STRING. - lv_col_from_int = zcl_excel_common=>convert_column2int( iv_columns_from ). - lv_col_to_int = zcl_excel_common=>convert_column2int( iv_columns_to ). + LV_COL_FROM_INT = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IV_COLUMNS_FROM ). + LV_COL_TO_INT = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IV_COLUMNS_TO ). *--------------------------------------------------------------------* * Check if valid range is supplied *--------------------------------------------------------------------* - IF lv_col_from_int < 1. - lv_errormessage = 'Invalid range supplied for print-title repeatable columns'(401). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + if LV_COL_FROM_INT < 1. + LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable columns'(401). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - IF lv_col_from_int > lv_col_to_int. - lv_errormessage = 'Invalid range supplied for print-title repeatable columns'(401). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + if LV_COL_FROM_INT > LV_COL_TO_INT. + LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable columns'(401). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. *--------------------------------------------------------------------* * adjust internal representation *--------------------------------------------------------------------* - me->print_title_col_from = iv_columns_from. - me->print_title_col_to = iv_columns_to. + ME->PRINT_TITLE_COL_FROM = IV_COLUMNS_FROM. + ME->PRINT_TITLE_COL_TO = IV_COLUMNS_TO. *--------------------------------------------------------------------* * adjust corresponding range *--------------------------------------------------------------------* - me->print_title_set_range( ). + ME->PRINT_TITLE_SET_RANGE( ). endmethod. -method ZIF_EXCEL_SHEET_PRINTSETTINGS~SET_PRINT_REPEAT_ROWS. + method ZIF_EXCEL_SHEET_PRINTSETTINGS~SET_PRINT_REPEAT_ROWS. *--------------------------------------------------------------------* * issue#235 - repeat rows/columns * - Stefan Schmöcker, 2012-12-02 *--------------------------------------------------------------------* - DATA: lv_errormessage TYPE string. + data: LV_ERRORMESSAGE type STRING. *--------------------------------------------------------------------* * Check if valid range is supplied *--------------------------------------------------------------------* - IF iv_rows_from < 1. - lv_errormessage = 'Invalid range supplied for print-title repeatable rowumns'(401). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + if IV_ROWS_FROM < 1. + LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable rowumns'(401). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. - IF iv_rows_from > iv_rows_to. - lv_errormessage = 'Invalid range supplied for print-title repeatable rowumns'(401). - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = lv_errormessage. - ENDIF. + if IV_ROWS_FROM > IV_ROWS_TO. + LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable rowumns'(401). + raise exception type ZCX_EXCEL + exporting + ERROR = LV_ERRORMESSAGE. + endif. *--------------------------------------------------------------------* * adjust internal representation *--------------------------------------------------------------------* - me->print_title_row_from = iv_rows_from. - me->print_title_row_to = iv_rows_to. + ME->PRINT_TITLE_ROW_FROM = IV_ROWS_FROM. + ME->PRINT_TITLE_ROW_TO = IV_ROWS_TO. *--------------------------------------------------------------------* * adjust corresponding range *--------------------------------------------------------------------* - me->print_title_set_range( ). + ME->PRINT_TITLE_SET_RANGE( ). endmethod. -method ZIF_EXCEL_SHEET_PROPERTIES~GET_STYLE. - IF zif_excel_sheet_properties~style IS NOT INITIAL. - ep_style = zif_excel_sheet_properties~style. - ELSE. - ep_style = me->excel->get_default_style( ). - ENDIF. + method ZIF_EXCEL_SHEET_PROPERTIES~GET_STYLE. + if ZIF_EXCEL_SHEET_PROPERTIES~STYLE is not initial. + EP_STYLE = ZIF_EXCEL_SHEET_PROPERTIES~STYLE. + else. + EP_STYLE = ME->EXCEL->GET_DEFAULT_STYLE( ). + endif. endmethod. -method ZIF_EXCEL_SHEET_PROPERTIES~INITIALIZE. + method ZIF_EXCEL_SHEET_PROPERTIES~INITIALIZE. - zif_excel_sheet_properties~show_zeros = zif_excel_sheet_properties=>c_showzero. - zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_on. - zif_excel_sheet_properties~summaryright = zif_excel_sheet_properties=>c_right_on. + ZIF_EXCEL_SHEET_PROPERTIES~SHOW_ZEROS = ZIF_EXCEL_SHEET_PROPERTIES=>C_SHOWZERO. + ZIF_EXCEL_SHEET_PROPERTIES~SUMMARYBELOW = ZIF_EXCEL_SHEET_PROPERTIES=>C_BELOW_ON. + ZIF_EXCEL_SHEET_PROPERTIES~SUMMARYRIGHT = ZIF_EXCEL_SHEET_PROPERTIES=>C_RIGHT_ON. * inizialize zoomscale values - ZIF_EXCEL_SHEET_PROPERTIES~zoomscale = 100. - ZIF_EXCEL_SHEET_PROPERTIES~zoomscale_normal = 100. - ZIF_EXCEL_SHEET_PROPERTIES~zoomscale_pagelayoutview = 100 . - ZIF_EXCEL_SHEET_PROPERTIES~zoomscale_sheetlayoutview = 100 . + ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE = 100. + ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_NORMAL = 100. + ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_PAGELAYOUTVIEW = 100 . + ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_SHEETLAYOUTVIEW = 100 . endmethod. -method ZIF_EXCEL_SHEET_PROPERTIES~SET_STYLE. - zif_excel_sheet_properties~style = ip_style. + method ZIF_EXCEL_SHEET_PROPERTIES~SET_STYLE. + ZIF_EXCEL_SHEET_PROPERTIES~STYLE = IP_STYLE. endmethod. -method ZIF_EXCEL_SHEET_PROTECTION~INITIALIZE. + method ZIF_EXCEL_SHEET_PROTECTION~INITIALIZE. - me->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_unprotected. - CLEAR me->zif_excel_sheet_protection~password. - me->zif_excel_sheet_protection~auto_filter = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~delete_columns = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~delete_rows = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~format_cells = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~format_columns = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~format_rows = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~insert_columns = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~insert_hyperlinks = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~insert_rows = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~objects = zif_excel_sheet_protection=>c_noactive. + ME->ZIF_EXCEL_SHEET_PROTECTION~PROTECTED = ZIF_EXCEL_SHEET_PROTECTION=>C_UNPROTECTED. + clear ME->ZIF_EXCEL_SHEET_PROTECTION~PASSWORD. + ME->ZIF_EXCEL_SHEET_PROTECTION~AUTO_FILTER = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~DELETE_COLUMNS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~DELETE_ROWS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~FORMAT_CELLS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~FORMAT_COLUMNS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~FORMAT_ROWS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~INSERT_COLUMNS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~INSERT_HYPERLINKS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~INSERT_ROWS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~OBJECTS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. * me->zif_excel_sheet_protection~password = zif_excel_sheet_protection=>c_noactive. "issue #68 - me->zif_excel_sheet_protection~pivot_tables = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~scenarios = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~select_locked_cells = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~select_unlocked_cells = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~sheet = zif_excel_sheet_protection=>c_noactive. - me->zif_excel_sheet_protection~sort = zif_excel_sheet_protection=>c_noactive. + ME->ZIF_EXCEL_SHEET_PROTECTION~PIVOT_TABLES = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~PROTECTED = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~SCENARIOS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~SELECT_LOCKED_CELLS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~SELECT_UNLOCKED_CELLS = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~SHEET = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. + ME->ZIF_EXCEL_SHEET_PROTECTION~SORT = ZIF_EXCEL_SHEET_PROTECTION=>C_NOACTIVE. endmethod. -method ZIF_EXCEL_SHEET_VBA_PROJECT~SET_CODENAME. - me->zif_excel_sheet_vba_project~codename = ip_codename. + method ZIF_EXCEL_SHEET_VBA_PROJECT~SET_CODENAME. + ME->ZIF_EXCEL_SHEET_VBA_PROJECT~CODENAME = IP_CODENAME. endmethod. -method ZIF_EXCEL_SHEET_VBA_PROJECT~SET_CODENAME_PR. - me->zif_excel_sheet_vba_project~codename_pr = ip_codename_pr. + method ZIF_EXCEL_SHEET_VBA_PROJECT~SET_CODENAME_PR. + ME->ZIF_EXCEL_SHEET_VBA_PROJECT~CODENAME_PR = IP_CODENAME_PR. endmethod. ENDCLASS.