mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 11:06:15 +08:00
Merge pull request #544 from Pacojka/master
Performance improvement for GET_ROW/GET_COLUMN
This commit is contained in:
commit
56f6fafe77
|
@ -5,38 +5,45 @@ class ZCL_EXCEL_COLUMNS definition
|
||||||
|
|
||||||
*"* public components of class ZCL_EXCEL_COLUMNS
|
*"* public components of class ZCL_EXCEL_COLUMNS
|
||||||
*"* do not include other source files here!!!
|
*"* 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
|
methods ADD
|
||||||
importing
|
importing
|
||||||
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
|
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
|
||||||
methods CLEAR .
|
methods CLEAR .
|
||||||
methods CONSTRUCTOR .
|
methods CONSTRUCTOR .
|
||||||
methods GET
|
methods GET
|
||||||
importing
|
importing
|
||||||
!IP_INDEX type I
|
!IP_INDEX type I
|
||||||
returning
|
returning
|
||||||
value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN .
|
value(EO_COLUMN) type ref to ZCL_EXCEL_COLUMN .
|
||||||
methods GET_ITERATOR
|
methods GET_ITERATOR
|
||||||
returning
|
returning
|
||||||
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
|
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
|
||||||
methods IS_EMPTY
|
methods IS_EMPTY
|
||||||
returning
|
returning
|
||||||
value(IS_EMPTY) type FLAG .
|
value(IS_EMPTY) type FLAG .
|
||||||
methods REMOVE
|
methods REMOVE
|
||||||
importing
|
importing
|
||||||
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
|
!IO_COLUMN type ref to ZCL_EXCEL_COLUMN .
|
||||||
methods SIZE
|
methods SIZE
|
||||||
returning
|
returning
|
||||||
value(EP_SIZE) type I .
|
value(EP_SIZE) type I .
|
||||||
*"* protected components of class ZABAP_EXCEL_WORKSHEETS
|
*"* protected components of class ZABAP_EXCEL_WORKSHEETS
|
||||||
*"* do not include other source files here!!!
|
*"* do not include other source files here!!!
|
||||||
protected section.
|
protected section.
|
||||||
*"* private components of class ZABAP_EXCEL_RANGES
|
*"* private components of class ZABAP_EXCEL_RANGES
|
||||||
*"* do not include other source files here!!!
|
*"* 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.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,44 +51,58 @@ ENDCLASS.
|
||||||
CLASS ZCL_EXCEL_COLUMNS IMPLEMENTATION.
|
CLASS ZCL_EXCEL_COLUMNS IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD add.
|
method ADD.
|
||||||
columns->add( io_column ).
|
data: LS_HASHED_COLUMN type MTY_S_HASHED_COLUMN.
|
||||||
ENDMETHOD.
|
|
||||||
|
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.
|
method CLEAR.
|
||||||
columns->clear( ).
|
clear COLUMNS_HASEHD.
|
||||||
ENDMETHOD.
|
COLUMNS->CLEAR( ).
|
||||||
|
endmethod.
|
||||||
|
|
||||||
|
|
||||||
METHOD constructor.
|
method CONSTRUCTOR.
|
||||||
|
|
||||||
CREATE OBJECT columns.
|
create object COLUMNS.
|
||||||
|
|
||||||
ENDMETHOD.
|
endmethod.
|
||||||
|
|
||||||
|
|
||||||
METHOD get.
|
method GET.
|
||||||
eo_column ?= columns->if_object_collection~get( ip_index ).
|
field-symbols: <LS_HASHED_COLUMN> type MTY_S_HASHED_COLUMN.
|
||||||
ENDMETHOD.
|
|
||||||
|
read table COLUMNS_HASEHD with key COLUMN_INDEX = IP_INDEX assigning <LS_HASHED_COLUMN>.
|
||||||
|
if SY-SUBRC = 0.
|
||||||
|
EO_COLUMN = <LS_HASHED_COLUMN>-COLUMN.
|
||||||
|
endif.
|
||||||
|
endmethod.
|
||||||
|
|
||||||
|
|
||||||
METHOD get_iterator.
|
method GET_ITERATOR.
|
||||||
eo_iterator ?= columns->if_object_collection~get_iterator( ).
|
EO_ITERATOR ?= COLUMNS->IF_OBJECT_COLLECTION~GET_ITERATOR( ).
|
||||||
ENDMETHOD.
|
endmethod.
|
||||||
|
|
||||||
|
|
||||||
METHOD is_empty.
|
method IS_EMPTY.
|
||||||
is_empty = columns->if_object_collection~is_empty( ).
|
IS_EMPTY = COLUMNS->IF_OBJECT_COLLECTION~IS_EMPTY( ).
|
||||||
ENDMETHOD.
|
endmethod.
|
||||||
|
|
||||||
|
|
||||||
METHOD remove.
|
method REMOVE.
|
||||||
columns->remove( io_column ).
|
delete table COLUMNS_HASEHD with table key COLUMN_INDEX = IO_COLUMN->GET_COLUMN_INDEX( ) .
|
||||||
ENDMETHOD.
|
COLUMNS->REMOVE( IO_COLUMN ).
|
||||||
|
endmethod.
|
||||||
|
|
||||||
|
|
||||||
METHOD size.
|
method SIZE.
|
||||||
ep_size = columns->if_object_collection~size( ).
|
EP_SIZE = COLUMNS->IF_OBJECT_COLLECTION~SIZE( ).
|
||||||
ENDMETHOD.
|
endmethod.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -12,36 +12,44 @@ class ZCL_EXCEL_ROWS definition
|
||||||
*"* do not include other source files here!!!
|
*"* do not include other source files here!!!
|
||||||
*"* protected components of class ZABAP_EXCEL_WORKSHEETS
|
*"* protected components of class ZABAP_EXCEL_WORKSHEETS
|
||||||
*"* do not include other source files here!!!
|
*"* 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
|
methods ADD
|
||||||
importing
|
importing
|
||||||
!IO_ROW type ref to ZCL_EXCEL_ROW .
|
!IO_ROW type ref to ZCL_EXCEL_ROW .
|
||||||
methods CLEAR .
|
methods CLEAR .
|
||||||
methods CONSTRUCTOR .
|
methods CONSTRUCTOR .
|
||||||
methods GET
|
methods GET
|
||||||
importing
|
importing
|
||||||
!IP_INDEX type I
|
!IP_INDEX type I
|
||||||
returning
|
returning
|
||||||
value(EO_ROW) type ref to ZCL_EXCEL_ROW .
|
value(EO_ROW) type ref to ZCL_EXCEL_ROW .
|
||||||
methods GET_ITERATOR
|
methods GET_ITERATOR
|
||||||
returning
|
returning
|
||||||
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
|
value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR .
|
||||||
methods IS_EMPTY
|
methods IS_EMPTY
|
||||||
returning
|
returning
|
||||||
value(IS_EMPTY) type FLAG .
|
value(IS_EMPTY) type FLAG .
|
||||||
methods REMOVE
|
methods REMOVE
|
||||||
importing
|
importing
|
||||||
!IO_ROW type ref to ZCL_EXCEL_ROW .
|
!IO_ROW type ref to ZCL_EXCEL_ROW .
|
||||||
methods SIZE
|
methods SIZE
|
||||||
returning
|
returning
|
||||||
value(EP_SIZE) type I .
|
value(EP_SIZE) type I .
|
||||||
PROTECTED SECTION.
|
protected section.
|
||||||
*"* private components of class ZABAP_EXCEL_RANGES
|
*"* private components of class ZABAP_EXCEL_RANGES
|
||||||
*"* do not include other source files here!!!
|
*"* 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.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,44 +57,58 @@ ENDCLASS.
|
||||||
CLASS ZCL_EXCEL_ROWS IMPLEMENTATION.
|
CLASS ZCL_EXCEL_ROWS IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD add.
|
method ADD.
|
||||||
rows->add( io_row ).
|
data: LS_HASHED_ROW type MTY_S_HASHED_ROW.
|
||||||
ENDMETHOD. "ADD
|
|
||||||
|
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.
|
method CLEAR.
|
||||||
rows->clear( ).
|
clear ROWS_HASEHD.
|
||||||
ENDMETHOD. "CLEAR
|
ROWS->CLEAR( ).
|
||||||
|
endmethod. "CLEAR
|
||||||
|
|
||||||
|
|
||||||
METHOD constructor.
|
method CONSTRUCTOR.
|
||||||
|
|
||||||
CREATE OBJECT rows.
|
create object ROWS.
|
||||||
|
|
||||||
ENDMETHOD. "CONSTRUCTOR
|
endmethod. "CONSTRUCTOR
|
||||||
|
|
||||||
|
|
||||||
METHOD get.
|
method GET.
|
||||||
eo_row ?= rows->if_object_collection~get( ip_index ).
|
field-symbols: <LS_HASHED_ROW> type MTY_S_HASHED_ROW.
|
||||||
ENDMETHOD. "GET
|
|
||||||
|
read table ROWS_HASEHD with key ROW_INDEX = IP_INDEX assigning <LS_HASHED_ROW>.
|
||||||
|
if SY-SUBRC = 0.
|
||||||
|
EO_ROW = <LS_HASHED_ROW>-ROW.
|
||||||
|
endif.
|
||||||
|
endmethod. "GET
|
||||||
|
|
||||||
|
|
||||||
METHOD get_iterator.
|
method GET_ITERATOR.
|
||||||
eo_iterator ?= rows->if_object_collection~get_iterator( ).
|
EO_ITERATOR ?= ROWS->IF_OBJECT_COLLECTION~GET_ITERATOR( ).
|
||||||
ENDMETHOD. "GET_ITERATOR
|
endmethod. "GET_ITERATOR
|
||||||
|
|
||||||
|
|
||||||
METHOD is_empty.
|
method IS_EMPTY.
|
||||||
is_empty = rows->if_object_collection~is_empty( ).
|
IS_EMPTY = ROWS->IF_OBJECT_COLLECTION~IS_EMPTY( ).
|
||||||
ENDMETHOD. "IS_EMPTY
|
endmethod. "IS_EMPTY
|
||||||
|
|
||||||
|
|
||||||
METHOD remove.
|
method REMOVE.
|
||||||
rows->remove( io_row ).
|
delete table ROWS_HASEHD with table key ROW_INDEX = IO_ROW->GET_ROW_INDEX( ) .
|
||||||
ENDMETHOD. "REMOVE
|
ROWS->REMOVE( IO_ROW ).
|
||||||
|
endmethod. "REMOVE
|
||||||
|
|
||||||
|
|
||||||
METHOD size.
|
method SIZE.
|
||||||
ep_size = rows->if_object_collection~size( ).
|
EP_SIZE = ROWS->IF_OBJECT_COLLECTION~SIZE( ).
|
||||||
ENDMETHOD. "SIZE
|
endmethod. "SIZE
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user