From 0e8bce36372e25422d42e459bb22eedcab9ea71c Mon Sep 17 00:00:00 2001 From: Gregor Wolf Date: Fri, 10 Dec 2010 22:35:10 +0000 Subject: [PATCH] Added CONVERT_COLUMNROW2COLUMN_A_ROW method in the ZCL_EXCEL_COMMON class to fix #45 in the Excel Reader class ZCL_EXCEL_READER_2007. git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@73 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk | 116 ++++++++++++++++++--------- ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk | 45 ++++++----- 2 files changed, 100 insertions(+), 61 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk index cbf2b1f..1aa55ef 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk @@ -1,13 +1,13 @@ - + class ZCL_EXCEL_COMMON definition public final create public . +public section. *"* public components of class ZCL_EXCEL_COMMON *"* do not include other source files here!!! -public section. class-data C_EXCEL_NUMFMT_OFFSET type INT1 value 164. "#EC NOTEXT . class-data C_SPRAS_EN type SPRAS value 'E'. "#EC NOTEXT . @@ -47,13 +47,19 @@ public section. importing !I_PWD type ZEXCEL_AES_PASSWORD returning - value(R_ENCRYPTED_PWD) type ZEXCEL_AES_PASSWORD . + value(R_ENCRYPTED_PWD) type ZEXCEL_AES_PASSWORD . + class-methods CONVERT_COLUMNROW2COLUMN_A_ROW + importing + !I_COLUMNROW type STRING + exporting + !E_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !E_ROW type ZEXCEL_CELL_ROW . *"* protected components of class ZCL_EXCEL_COMMON *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL_COMMON + private section. +*"* private components of class ZCL_EXCEL_COMMON *"* do not include other source files here!!! -private section. class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . @@ -81,13 +87,14 @@ private section. *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - - - + + + + + + + + method CHAR2HEX. IF o_conv IS NOT BOUND. @@ -101,10 +108,11 @@ private section. r_hex+1 = o_conv->get_buffer( ). " x'65' must be x'0065' endmethod. + - - - + + + method CONVERT_COLUMN2ALPHA. DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, @@ -125,10 +133,11 @@ endmethod. ENDWHILE. endmethod. + - - - + + + method CONVERT_COLUMN2INT. DATA: lv_uccpi TYPE i, @@ -155,10 +164,32 @@ endmethod. ENDIF. endmethod. + - - - + + + + + METHOD convert_columnrow2column_a_row. + DATA: width TYPE i, + col_width TYPE i, + row_str TYPE string. + width = strlen( i_columnrow ). + col_width = 2. + e_column = i_columnrow. + WHILE e_column CA '0123456789'. + col_width = col_width - 1. + e_column = i_columnrow(col_width). + ENDWHILE. + width = width - col_width. + row_str = i_columnrow+col_width(width). + e_row = row_str. +ENDMETHOD. + + + + + method DATE_TO_EXCEL_STRING. DATA: lv_date_diff TYPE i, lc_date_baseline TYPE d VALUE '19000101'. @@ -167,10 +198,11 @@ endmethod. lv_date_diff = ip_value - lc_date_baseline + 2. ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_date_diff ). endmethod. + - - - + + + method ENCRYPT_PASSWORD. DATA lv_curr_offset TYPE i. @@ -209,10 +241,11 @@ endmethod. WRITE lv_pwd_hash TO r_encrypted_pwd. endmethod. + - - - + + + method GET_FIELDCATALOG. DATA: lr_data TYPE REF TO data, @@ -236,10 +269,11 @@ endmethod. ENDLOOP. endmethod. + - - - + + + method NUMBER_TO_EXCEL_STRING. DATA: lv_value_c TYPE c LENGTH 100. @@ -253,10 +287,11 @@ endmethod. CONCATENATE '-' ep_value INTO ep_value. ENDIF. endmethod. + - - - + + + method SHL01. DATA: @@ -273,10 +308,11 @@ endmethod. SET BIT 16 OF r_pwd_hash TO 0. endmethod. + - - - + + + method SHR14. DATA: @@ -300,10 +336,11 @@ endmethod. ENDDO. endmethod. + - - - + + + method TIME_TO_EXCEL_STRING. DATA: lv_seconds_in_day TYPE i, lv_day_fraction TYPE f, @@ -314,5 +351,6 @@ endmethod. lv_day_fraction = lv_seconds_in_day / lc_seconds_in_day. ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_day_fraction ). endmethod. + diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk index 8de21d6..1bc2ef7 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk @@ -1,6 +1,6 @@ - - - + + + class ZCL_EXCEL_READER_2007 definition public final @@ -54,8 +54,9 @@ private section. *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - + + + METHOD zif_excel_reader~load. TYPES: @@ -111,7 +112,6 @@ private section. attr_id TYPE string, tag_name TYPE string, r TYPE string, - r_width TYPE i, cell_data_type TYPE string, cell_column TYPE zexcel_cell_column_alpha, cell_row TYPE zexcel_cell_row, @@ -260,14 +260,13 @@ private section. ENDIF. ENDCASE. IF NOT value IS INITIAL. - " WRITE: value. - " TODO: wite a robust method which splits r into - " cell_column and cell_row - cell_column = r(1). - r_width = STRLEN( r ). - r_width = r_width - 1. - cell_row = r+1(r_width). - " WRITE: cell_column, cell_row, cell_value. + zcl_excel_common=>convert_columnrow2column_a_row( + EXPORTING + i_columnrow = r + IMPORTING + e_column = cell_column + e_row = cell_row + ). lo_worksheet->set_cell( EXPORTING ip_column = cell_column " Cell Column @@ -350,10 +349,10 @@ ENDMETHOD. r_excel = me->zif_excel_reader~load( excel_data ). endmethod. - - - - + + + + method GET_FROM_ZIP_ARCHIVE. IF me->zip IS NOT BOUND. @@ -389,11 +388,12 @@ endmethod. ENDIF. endmethod. + - - - - + + + + method GET_IXML_FROM_ZIP_ARCHIVE. TYPE-POOLS: ixml. @@ -417,5 +417,6 @@ endmethod. parser->parse( ). endmethod. +