From f312f7f12ad131c5bef4c09fdac6bef818065ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schm=C3=B6cker?= Date: Sun, 4 Nov 2012 00:08:46 +0000 Subject: [PATCH] ready to test #220 - Demoreport22 has invisible Columnheaders git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@351 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk | 150 ++++++++++++++++++--------- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 85 +++++++++++++-- 2 files changed, 176 insertions(+), 59 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk b/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk index 2403cda..6d33577 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_TABLE.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_TABLE definition public final @@ -61,7 +61,15 @@ public section. importing !IP_INCLUDE_TOTALS_ROW type ABAP_BOOL default ABAP_TRUE returning - value(OV_REFERENCE) type STRING . + value(OV_REFERENCE) type STRING . + methods GET_BOTTOM_ROW_INTEGER + returning + value(EV_ROW) type I . + methods GET_RIGHT_COLUMN_INTEGER + returning + value(EV_COLUMN) type I + raising + ZCX_EXCEL . *"* protected components of class ZCL_EXCEL_TABLE *"* do not include other source files here!!! protected section. @@ -82,46 +90,70 @@ private section. *"* in the implementation part of the class ABAP - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. endmethod. - - + + + METHOD get_bottom_row_integer. + DATA: lv_table_lines TYPE i. + FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE. + + IF settings-bottom_right_row IS NOT INITIAL. + ev_row = zcl_excel_common=>convert_column2int( settings-bottom_right_row ). + EXIT. + ENDIF. + + ASSIGN table_data->* TO <fs_table>. + DESCRIBE TABLE <fs_table> LINES lv_table_lines. + IF lv_table_lines = 0. + lv_table_lines = 1. "table needs at least 1 data row + ENDIF. + + ev_row = settings-top_left_row + lv_table_lines. + + IF me->has_totals( ) = abap_true." ???? AND ip_include_totals_row = abap_true. + ADD 1 TO ev_row. + ENDIF. +ENDMETHOD. + + + method GET_ID. ov_id = id. endmethod. - - + + method GET_NAME. IF me->name IS INITIAL. @@ -132,10 +164,10 @@ endmethod. ov_name = me->name. endmethod. - - - - METHOD get_reference. + + + + method GET_REFERENCE. DATA: lv_column TYPE zexcel_cell_column, lv_table_lines TYPE i, lv_right_column TYPE zexcel_cell_column_alpha, @@ -174,12 +206,32 @@ endmethod. ':' lv_right_column lv_bottom_row_string INTO ov_reference. +endmethod. + + + + + METHOD get_right_column_integer. + DATA: lv_column TYPE zexcel_cell_column, + lv_table_lines TYPE i, + ls_field_catalog TYPE zexcel_s_fieldcatalog. + + IF settings-bottom_right_column IS NOT INITIAL. + ev_column = zcl_excel_common=>convert_column2int( settings-bottom_right_column ). + EXIT. + ENDIF. + + ev_column = zcl_excel_common=>convert_column2int( settings-top_left_column ). + LOOP AT fieldcat INTO ls_field_catalog WHERE dynpfld EQ abap_true. + ADD 1 TO ev_column. + ENDLOOP. + ENDMETHOD. - - - - + + + + method GET_TOTALS_FORMULA. CONSTANTS: lc_function_id_sum TYPE string VALUE '109', lc_function_id_min TYPE string VALUE '105', @@ -214,8 +266,8 @@ ENDMETHOD. CONCATENATE 'SUBTOTAL(' lv_function_id ',[' ip_column '])' INTO ep_formula. endmethod. - - + + method HAS_TOTALS. DATA: ls_field_catalog TYPE zexcel_s_fieldcatalog. @@ -230,14 +282,14 @@ endmethod. endmethod. - - + + method SET_DATA. GET REFERENCE OF ir_data INTO me->table_data. endmethod. - - + + method SET_ID. id = iv_id. endmethod. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 1e515fb..593d19d 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -1830,13 +1830,27 @@ endmethod. - method CREATE_XL_SHEET. + METHOD create_xl_sheet. TYPES: BEGIN OF cfvo, value TYPE zexcel_conditional_value, type TYPE zexcel_conditional_type, END OF cfvo. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Declarations 1 - start +*--------------------------------------------------------------------* + TYPES: BEGIN OF lty_table_area, + left TYPE i, + right TYPE i, + top TYPE i, + bottom TYPE i, + END OF lty_table_area. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Declarations 1 - end +*--------------------------------------------------------------------* + + ** Constant node name DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', lc_xml_node_sheetpr TYPE string VALUE 'sheetPr', @@ -2047,6 +2061,17 @@ endmethod. <column_dimension> TYPE zexcel_s_worksheet_columndime, <row_dimension> TYPE zexcel_s_worksheet_rowdimensio. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Declarations 2 - start +*--------------------------------------------------------------------* + DATA: lt_table_areas TYPE SORTED TABLE OF lty_table_area WITH NON-UNIQUE KEY left right top bottom, + ls_table_area LIKE LINE OF lt_table_areas. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Declarations 2 - end +*--------------------------------------------------------------------* + + + ********************************************************************** * STEP 1: Create [Content_Types].xml into the root of the ZIP lo_ixml = cl_ixml=>create( ). @@ -2081,14 +2106,14 @@ endmethod. lo_element = lo_document->create_simple_element( name = lc_xml_node_sheetpr parent = lo_document ). " TODO tabColor - if io_worksheet->tabcolor is not INITIAL. + IF io_worksheet->tabcolor IS NOT INITIAL. lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_tabcolor parent = lo_element ). * Theme not supported yet - start with RGB lv_value = io_worksheet->tabcolor-rgb. lo_element_2->set_attribute_ns( name = lc_xml_attr_tabcolor_rgb value = lv_value ). - endif. + ENDIF. " outlinePr lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_outlinepr @@ -2475,6 +2500,23 @@ endmethod. ls_area = lo_autofilter->get_filter_area( ) . l_autofilter_hidden = abap_true. " First defautl is not showing ENDIF. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 1 - start +*--------------------------------------------------------------------* +* Build table to hold all table-areas attached to this sheet + lo_iterator = io_worksheet->get_tables_iterator( ). + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_table ?= lo_iterator->if_object_collection_iterator~get_next( ). + ls_table_area-left = zcl_excel_common=>convert_column2int( lo_table->settings-top_left_column ). + ls_table_area-right = lo_table->get_right_column_integer( ). + ls_table_area-top = lo_table->settings-top_left_row. + ls_table_area-bottom = lo_table->get_bottom_row_integer( ). + INSERT ls_table_area INTO TABLE lt_table_areas. + ENDWHILE. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 1 - end +*--------------------------------------------------------------------* + LOOP AT io_worksheet->sheet_content ASSIGNING <ls_sheet_content>. READ TABLE lt_values INTO ls_values WITH KEY column = ls_last_row-cell_column. IF sy-subrc = 0 AND ls_values-value = ls_last_row-cell_value. @@ -2560,16 +2602,39 @@ endmethod. IF <ls_sheet_content>-cell_style IS NOT INITIAL. lv_style_guid = <ls_sheet_content>-cell_style. ELSE. - lv_column_p = zcl_excel_common=>convert_column2alpha( <ls_sheet_content>-cell_column ). - READ TABLE column_dimensions with key column = lv_column_p ASSIGNING <column_dimension>. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 2 - start +*--------------------------------------------------------------------* +* Check if cell in any of the table areas + LOOP AT lt_table_areas TRANSPORTING NO FIELDS WHERE top <= <ls_sheet_content>-cell_row + AND bottom >= <ls_sheet_content>-cell_row + AND left <= <ls_sheet_content>-cell_column + AND right >= <ls_sheet_content>-cell_column. + EXIT. + ENDLOOP. IF sy-subrc = 0. - lv_style_guid = <column_dimension>-column_dimension->get_column_style_guid( ). - IF lv_style_guid IS INITIAL. + CLEAR lv_style_guid. " No style --> EXCEL will use built-in-styles as declared in the tables-section + ELSE. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 2 - end +*--------------------------------------------------------------------* + lv_column_p = zcl_excel_common=>convert_column2alpha( <ls_sheet_content>-cell_column ). + READ TABLE column_dimensions WITH KEY column = lv_column_p ASSIGNING <column_dimension>. + IF sy-subrc = 0. + lv_style_guid = <column_dimension>-column_dimension->get_column_style_guid( ). + IF lv_style_guid IS INITIAL. + lv_style_guid = io_worksheet->zif_excel_sheet_properties~get_style( ). + ENDIF. + ELSE. lv_style_guid = io_worksheet->zif_excel_sheet_properties~get_style( ). ENDIF. - ELSE. - lv_style_guid = io_worksheet->zif_excel_sheet_properties~get_style( ). +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 3 - start +*--------------------------------------------------------------------* ENDIF. +*--------------------------------------------------------------------* +* issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 3 - end +*--------------------------------------------------------------------* ENDIF. * IF <ls_sheet_content>-cell_style IS NOT INITIAL. * READ TABLE styles_mapping INTO ls_style_mapping WITH KEY guid = <ls_sheet_content>-cell_style. @@ -3364,7 +3429,7 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -endmethod. +ENDMETHOD.