From 72a336253d3f5e527dc9e6ef0365fb10512a0de8 Mon Sep 17 00:00:00 2001 From: StefanSchmoecker Date: Sat, 3 Jan 2015 14:50:25 +0100 Subject: [PATCH] issue #346 2nd part, #278 Changes: ZCL_EXCEL_WORKSHEET: New attributes to hold row-outline information ZCL_EXCEL_WORKSHEET_ROWDIMENSI: Look at those row-outline information. Modified methods that refer to outlining ZCL_EXCEL_WRITER_2007: Respect new outlining informatino by using the modified methods from rowdimensi, Also corrected an error that occurs if we have leading or trailing empty rows but information stored in rowdimensions ZDEMO_EXCEL12: Modified Demoreport 12 to demonstrate new outlining method --- ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk | 255 +++++++++++------- ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk | 238 ++++++++-------- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 96 +++++-- ZA2X/PROG/ZDEMO_EXCEL12.slnk | 51 +++- 4 files changed, 396 insertions(+), 244 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk index cf63edf..859990c 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -21,12 +21,20 @@ TYPE HASHED TABLE OF mty_s_font_cache WITH UNIQUE KEY font_name font_height flag_bold flag_italic "/> - - - - - + + + + + + *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -203,43 +211,44 @@ ENDCLASS. "lcl_gui_alv_grid DEFINITION ABAP SLIS SOI - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method ZIF_EXCEL_SHEET_PRINTSETTINGS~CLEAR_PRINT_REPEAT_COLUMNS. @@ -3662,7 +3671,23 @@ ENDMETHOD. 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. + + @@ -3743,7 +3768,7 @@ ENDMETHOD. endmethod. - + @@ -3782,7 +3807,7 @@ ENDMETHOD. ENDIF. endmethod. - + @@ -3809,33 +3834,33 @@ ENDMETHOD. endmethod. - + method GET_COLUMN_DIMENSIONS. r_column_dimension[] = me->column_dimensions[]. endmethod. - + method GET_COND_STYLES_ITERATOR. eo_iterator = me->conditional_styles->get_iterator( ). endmethod. - + method GET_DATA_VALIDATIONS_ITERATOR. eo_iterator = me->data_validations->get_iterator( ). endmethod. - + method GET_DATA_VALIDATIONS_SIZE. ep_size = me->data_validations->size( ). endmethod. - + method GET_DEFAULT_COLUMN_DIMENSION. IF me->default_column_dimension IS NOT BOUND. @@ -3849,7 +3874,7 @@ ENDMETHOD. r_column_dimension = me->default_column_dimension. endmethod. - + method GET_DEFAULT_EXCEL_DATE_FORMAT. CONSTANTS: c_lang_e TYPE lang VALUE 'E'. @@ -3875,7 +3900,7 @@ ENDMETHOD. ep_default_excel_date_format = default_excel_date_format. endmethod. - + method GET_DEFAULT_EXCEL_TIME_FORMAT. DATA: l_timefm TYPE xutimefm. @@ -3911,7 +3936,7 @@ ENDMETHOD. ep_default_excel_time_format = default_excel_time_format. endmethod. - + method GET_DEFAULT_ROW_DIMENSION. IF me->default_row_dimension IS NOT BOUND. @@ -3921,7 +3946,7 @@ ENDMETHOD. r_row_dimension = me->default_row_dimension. endmethod. - + method GET_DIMENSION_RANGE. @@ -3941,7 +3966,7 @@ ENDMETHOD. endmethod. - + method GET_DRAWINGS. @@ -3973,7 +3998,7 @@ ENDMETHOD. ENDCASE. endmethod. - + method GET_DRAWINGS_ITERATOR. @@ -3985,7 +4010,7 @@ ENDMETHOD. ENDCASE. endmethod. - + method GET_FREEZE_CELL. @@ -3993,7 +4018,7 @@ ENDMETHOD. ep_column = me->freeze_pane_cell_column. endmethod. - + METHOD get_guid. @@ -4001,7 +4026,7 @@ ENDMETHOD. ENDMETHOD. - + method GET_HIGHEST_COLUMN. @@ -4009,7 +4034,7 @@ ENDMETHOD. r_highest_column = me->lower_cell-cell_column. endmethod. - + METHOD get_highest_row. @@ -4017,19 +4042,19 @@ ENDMETHOD. 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. @@ -4105,7 +4130,7 @@ ENDMETHOD. endmethod. - + method GET_RANGES_ITERATOR. @@ -4113,7 +4138,7 @@ ENDMETHOD. endmethod. - + METHOD GET_ROW_DIMENSION. @@ -4138,7 +4163,7 @@ ENDMETHOD. ENDMETHOD. - + METHOD get_row_dimensions. @@ -4146,26 +4171,34 @@ ENDMETHOD. ENDMETHOD. - + + + METHOD get_row_outlines. + + rt_row_outlines = me->mt_row_outlines. + +ENDMETHOD. + + method GET_TABCOLOR. ev_tabcolor = me->tabcolor. endmethod. - + method GET_TABLES_ITERATOR. eo_iterator = tables->if_object_collection~get_iterator( ). endmethod. - + method GET_TABLES_SIZE. ep_size = tables->if_object_collection~size( ). endmethod. - - + + method GET_TITLE. DATA lv_value TYPE string. @@ -4234,7 +4267,7 @@ ENDMETHOD. endmethod. - + @@ -4258,7 +4291,7 @@ ENDMETHOD. ENDLOOP. endmethod. - + method PRINT_TITLE_SET_RANGE. *--------------------------------------------------------------------* * issue#235 - repeat rows/columns @@ -4357,7 +4390,7 @@ endmethod. endmethod. - + @@ -4593,7 +4626,7 @@ endmethod. endmethod. - + @@ -4627,7 +4660,7 @@ endmethod. endmethod. - + @@ -4657,7 +4690,7 @@ endmethod. endmethod. - + @@ -4693,7 +4726,7 @@ endmethod. endmethod. - + method SET_DEFAULT_EXCEL_DATE_FORMAT. @@ -4707,7 +4740,7 @@ endmethod. default_excel_date_format = ip_default_excel_date_format. endmethod. - + @@ -4749,13 +4782,13 @@ endmethod. endmethod. - + method SET_PRINT_GRIDLINES. me->print_gridlines = i_print_gridlines. endmethod. - + @@ -4786,31 +4819,73 @@ endmethod. endmethod. - + + + + + + METHOD set_row_outline. + + DATA: ls_row_outline LIKE LINE OF me->mt_row_outlines. + FIELD-SYMBOLS: <ls_row_outline> LIKE LINE OF me->mt_row_outlines. + + READ TABLE me->mt_row_outlines ASSIGNING <ls_row_outline> 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 <ls_row_outline>. + ENDIF. + + CASE iv_collapsed. + + WHEN abap_true + OR abap_false. + <ls_row_outline>-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. endmethod. - + method SET_TABCOLOR. me->tabcolor = iv_tabcolor. endmethod. - + - - + + @@ -4888,7 +4963,7 @@ endmethod. endmethod. - + method SET_TITLE. @@ -4991,9 +5066,9 @@ endmethod. 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, @@ -5032,6 +5107,6 @@ endmethod. SHIFT lv_row_alpha LEFT DELETING LEADING space. CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. - endmethod. +ENDMETHOD. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk index 0a79258..a2ed626 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk @@ -1,71 +1,5 @@ - - - class ZCL_EXCEL_WORKSHEET_ROWDIMENSI definition - public - final - create public . - -*"* public components of class ZCL_EXCEL_WORKSHEET_ROWDIMENSI -*"* do not include other source files here!!! -public section. - type-pools ABAP . - - methods CONSTRUCTOR - importing - !IP_INDEX type INT4 default 0 . - methods GET_OUTLINE_LEVEL - returning - value(R_OUTLINE_LEVEL) type INT4 . - methods GET_XF_INDEX - returning - value(R_XF_INDEX) type INT4 . - methods GET_ROW_INDEX - returning - value(R_ROW_INDEX) type INT4 . - methods SET_OUTLINE_LEVEL - importing - !IP_OUTLINE_LEVEL type INT4 - raising - ZCX_EXCEL . - methods SET_ROW_INDEX - importing - !IP_INDEX type INT4 . - methods SET_XF_INDEX - importing - !IP_XF_INDEX type INT4 . - methods GET_ROW_HEIGHT - returning - value(R_ROW_HEIGHT) type FLOAT . - methods SET_ROW_HEIGHT - importing - !IP_ROW_HEIGHT type SIMPLE - raising - ZCX_EXCEL . - methods GET_COLLAPSED - returning - value(R_COLLAPSED) type BOOLEAN . - methods GET_VISIBLE - returning - value(R_VISIBLE) type BOOLEAN . - methods SET_COLLAPSED - importing - !IP_COLLAPSED type BOOLEAN . - methods SET_VISIBLE - importing - !IP_VISIBLE type BOOLEAN . - *"* protected components of class ZCL_EXCEL_WORKSHEET_ROWDIMENSI -*"* do not include other source files here!!! -protected section. - *"* private components of class ZCL_EXCEL_WORKSHEET_ROWDIMENSI -*"* do not include other source files here!!! -private section. - - data ROW_INDEX type INT4 . - data ROW_HEIGHT type FLOAT . - data VISIBLE type BOOLEAN . - data OUTLINE_LEVEL type INT4 value 0. "#EC NOTEXT . - data COLLAPSED type BOOLEAN . - data XF_INDEX type INT4 . + + *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -76,14 +10,14 @@ private section. *"* in the implementation part of the class ABAP - - - - - - - - + + + + + + + + method CONSTRUCTOR. " Initialise values me->row_index = ip_index. @@ -94,53 +28,117 @@ private section. " set row dimension as unformatted by default me->xf_index = 0. -endmethod. + endmethod. - - - method GET_COLLAPSED. + + + + METHOD get_collapsed. + + DATA: lt_row_outlines TYPE zcl_excel_worksheet=>mty_ts_outlines_row, + lv_previous_row TYPE i, + lv_following_row TYPE i. + r_collapsed = me->collapsed. -endmethod. + + CHECK r_collapsed = abap_false. " Maybe new method for outlines is being used + CHECK io_worksheet IS BOUND. + +* If an outline is collapsed ( even inside an outer outline ) the line following the last line +* of the group gets the flag "collapsed" + IF io_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_off. + lv_following_row = me->row_index + 1. + lt_row_outlines = io_worksheet->get_row_outlines( ). + READ TABLE lt_row_outlines TRANSPORTING NO FIELDS WITH KEY row_from = lv_following_row " first line of an outline + collapsed = abap_true. " that is collapsed + ELSE. + lv_previous_row = me->row_index - 1. + lt_row_outlines = io_worksheet->get_row_outlines( ). + READ TABLE lt_row_outlines TRANSPORTING NO FIELDS WITH KEY row_to = lv_previous_row " last line of an outline + collapsed = abap_true. " that is collapsed + ENDIF. + CHECK sy-subrc = 0. " ok - we found it + r_collapsed = abap_true. + + +ENDMETHOD. - - - method GET_OUTLINE_LEVEL. - r_outline_level = me->outline_level. -endmethod. + + + + METHOD get_outline_level. + + DATA: lt_row_outlines TYPE zcl_excel_worksheet=>mty_ts_outlines_row. + FIELD-SYMBOLS: <ls_row_outline> LIKE LINE OF lt_row_outlines. + +* if someone has set the outline level explicitly - just use that + IF me->outline_level IS NOT INITIAL. + r_outline_level = me->outline_level. + RETURN. + ENDIF. +* Maybe we can use the outline information in the worksheet + CHECK io_worksheet IS BOUND. + + lt_row_outlines = io_worksheet->get_row_outlines( ). + LOOP AT lt_row_outlines ASSIGNING <ls_row_outline> WHERE row_from <= me->row_index + AND row_to >= me->row_index. + + ADD 1 TO r_outline_level. + + ENDLOOP. + +ENDMETHOD. - - + + method GET_ROW_HEIGHT. r_row_height = me->row_height. -endmethod. + endmethod. - - + + method GET_ROW_INDEX. r_row_index = me->row_index. -endmethod. + endmethod. - - - method GET_VISIBLE. + + + + METHOD get_visible. + + DATA: lt_row_outlines TYPE zcl_excel_worksheet=>mty_ts_outlines_row. + FIELD-SYMBOLS: <ls_row_outline> LIKE LINE OF lt_row_outlines. + r_visible = me->visible. -endmethod. + CHECK r_visible = 'X'. " Currently visible --> but maybe the new outline methodology will hide it implicitly + CHECK io_worksheet IS BOUND. " But we have to see the worksheet to make sure + + lt_row_outlines = io_worksheet->get_row_outlines( ). + LOOP AT lt_row_outlines ASSIGNING <ls_row_outline> WHERE row_from <= me->row_index + AND row_to >= me->row_index + AND collapsed = abap_true. " row is in a collapsed outline --> not visible + CLEAR r_visible. + RETURN. " one hit is enough to ensure invisibility + + ENDLOOP. + +ENDMETHOD. - - + + method GET_XF_INDEX. r_xf_index = me->xf_index. -endmethod. + endmethod. - - + + method SET_COLLAPSED. me->collapsed = ip_collapsed. -endmethod. + endmethod. - - - + + + method SET_OUTLINE_LEVEL. IF ip_outline_level < 0 OR ip_outline_level > 7. @@ -151,12 +149,12 @@ endmethod. ENDIF. me->outline_level = ip_outline_level. -endmethod. + endmethod. - - - - METHOD set_row_height. + + + + method SET_ROW_HEIGHT. TRY. me->row_height = ip_row_height. CATCH cx_sy_conversion_no_number. @@ -164,24 +162,24 @@ endmethod. EXPORTING error = 'Unable to interpret ip_row_height as number'. ENDTRY. -ENDMETHOD. + endmethod. - - + + method SET_ROW_INDEX. me->row_index = ip_index. -endmethod. + endmethod. - - + + method SET_VISIBLE. me->visible = ip_visible. -endmethod. + endmethod. - - + + method SET_XF_INDEX. me->XF_INDEX = ip_XF_INDEX. -endmethod. + endmethod. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index febf3d0..d777c38 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -2669,6 +2669,9 @@ *--------------------------------------------------------------------* * issue #220 - If cell in tables-area don't use default from row or column or sheet - Declarations 1 - end *--------------------------------------------------------------------* +** Constants + CONSTANTS: + lc_dummy_cell_content TYPE zexcel_s_cell_data-cell_value VALUE '})~~~ This is a dummy value for ABAP2XLSX and you should never find this in a real excelsheet Ihope'. ** Constant node name @@ -2875,6 +2878,9 @@ lv_next_row TYPE i, ls_sheet_content LIKE LINE OF io_worksheet->sheet_content, ls_sheet_content_empty LIKE LINE OF io_worksheet->sheet_content, + lv_last_row TYPE i, + lts_row_dimensions TYPE zexcel_t_worksheet_rowdimensio, + lts_row_outlines TYPE zcl_excel_worksheet=>mty_ts_outlines_row, col_count TYPE int4, merge_count TYPE int4, write_current_row TYPE boolean, @@ -2892,7 +2898,8 @@ FIELD-SYMBOLS: <ls_sheet_content> TYPE zexcel_s_cell_data, <fs_range_merge> LIKE LINE OF lt_range_merge, <column_dimension> TYPE zexcel_s_worksheet_columndime, - <row_dimension> TYPE zexcel_s_worksheet_rowdimensio. + <row_dimension> TYPE zexcel_s_worksheet_rowdimensio, + <ls_row_outline> LIKE LINE OF lts_row_outlines. *--------------------------------------------------------------------* * issue #220 - If cell in tables-area don't use default from row or column or sheet - Declarations 2 - start @@ -3156,16 +3163,19 @@ ENDIF. ENDIF. " outlineLevelRow - LOOP AT row_dimensions ASSIGNING <row_dimension>. - IF <row_dimension>-row_dimension->get_outline_level( ) > outline_level_row. - outline_level_row = <row_dimension>-row_dimension->get_outline_level( ). - ENDIF. - ENDLOOP. - lv_value = outline_level_row. - SHIFT lv_value RIGHT DELETING TRAILING space. - SHIFT lv_value LEFT DELETING LEADING space. - lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelrow - value = lv_value ). +* Excel is recalculating the outlinelevel on startup from the outline levels found in the rows +* If we place anything incorrect here it gets corrected, if don't place anything it gets added +* So no need to calculate the outlinelevel here ( at least for rows - probably for columns as well but I haven't tested yet +* LOOP AT row_dimensions ASSIGNING <row_dimension>. +* IF <row_dimension>-row_dimension->get_outline_level( ) > outline_level_row. +* outline_level_row = <row_dimension>-row_dimension->get_outline_level( ). +* ENDIF. +* ENDLOOP. +* lv_value = outline_level_row. +* SHIFT lv_value RIGHT DELETING TRAILING space. +* SHIFT lv_value LEFT DELETING LEADING space. +* lo_element->set_attribute_ns( name = lc_xml_attr_outlinelevelrow +* value = lv_value ). " outlineLevelCol LOOP AT column_dimensions ASSIGNING <column_dimension>. IF <column_dimension>-column_dimension->get_outline_level( ) > outline_level_col. @@ -3357,7 +3367,47 @@ *--------------------------------------------------------------------* * issue #220 - If cell in tables-area don't use default from row or column or sheet - Coding 1 - end *--------------------------------------------------------------------* +* We have problems when the first rows or trailing rows are not set but we have rowinformation +* to solve this we add dummycontent into first and last line that will not be set +* Set first line if necessary + READ TABLE io_worksheet->sheet_content TRANSPORTING NO FIELDS WITH KEY cell_row = 1. + IF sy-subrc <> 0. + ls_sheet_content_empty-cell_row = 1. + ls_sheet_content_empty-cell_column = 1. + ls_sheet_content_empty-cell_value = lc_dummy_cell_content. + INSERT ls_sheet_content_empty INTO TABLE io_worksheet->sheet_content. + ENDIF. +* Set last line if necessary +* Last row with cell content + lv_last_row = io_worksheet->get_highest_row( ). +* Last line with row-information set directly ( like line height, hidden-status ... ) lts_row_dimensions = io_worksheet->get_row_dimensions( ). + SORT lts_row_dimensions BY row DESCENDING. + READ TABLE lts_row_dimensions INDEX 1 ASSIGNING <row_dimension>. + IF sy-subrc = 0 AND <row_dimension>-row > lv_last_row. + lv_last_row = <row_dimension>-row. + ENDIF. +* Last line with row-information set indirectly by row outline + lts_row_outlines = io_worksheet->get_row_outlines( ). + LOOP AT lts_row_outlines ASSIGNING <ls_row_outline>. + IF <ls_row_outline>-collapsed = 'X'. + lv_current_row = <ls_row_outline>-row_to + 1. " collapsed-status may be set on following row + ELSE. + lv_current_row = <ls_row_outline>-row_to. " collapsed-status may be set on following row + ENDIF. + IF lv_current_row > lv_last_row. + lv_last_row = lv_current_row. + ENDIF. + ENDLOOP. + READ TABLE io_worksheet->sheet_content TRANSPORTING NO FIELDS WITH KEY cell_row = lv_last_row. + IF sy-subrc <> 0. + ls_sheet_content_empty-cell_row = lv_last_row. + ls_sheet_content_empty-cell_column = 1. + ls_sheet_content_empty-cell_value = lc_dummy_cell_content. + INSERT ls_sheet_content_empty INTO TABLE io_worksheet->sheet_content. + ENDIF. + + CLEAR ls_sheet_content. LOOP AT io_worksheet->sheet_content INTO 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. @@ -3382,10 +3432,10 @@ ELSE. * Check if empty row is really necessary - this is basically the case when we have information in row_dimension lo_row_dim_empty = io_worksheet->get_row_dimension( lv_current_row ). - CHECK lo_row_dim_empty->get_row_height( ) >= 0 OR - lo_row_dim_empty->get_collapsed( ) = abap_true OR - lo_row_dim_empty->get_outline_level( ) > 0 OR - lo_row_dim_empty->get_xf_index( ) <> 0. + CHECK lo_row_dim_empty->get_row_height( ) >= 0 OR + lo_row_dim_empty->get_collapsed( io_worksheet ) = abap_true OR + lo_row_dim_empty->get_outline_level( io_worksheet ) > 0 OR + lo_row_dim_empty->get_xf_index( ) <> 0. " Dummyentry A1 ls_sheet_content_empty-cell_row = lv_current_row. ls_sheet_content_empty-cell_column = 1. @@ -3403,7 +3453,7 @@ ENDIF. IF ls_last_row-cell_row IS NOT INITIAL. " Row visibility of previos row. - IF row_dimension->get_visible( ) = abap_false OR + IF row_dimension->get_visible( io_worksheet ) = abap_false OR l_autofilter_hidden = abap_true. lo_element_2->set_attribute_ns( name = 'hidden' value = 'true'). ENDIF. @@ -3429,8 +3479,8 @@ row_dimension = io_worksheet->get_row_dimension( <ls_sheet_content>-cell_row ). " Do we need the row dimension attributes? IF row_dimension->get_row_height( ) >= 0 OR - row_dimension->get_collapsed( ) = abap_true OR - row_dimension->get_outline_level( ) > 0 OR + row_dimension->get_collapsed( io_worksheet ) = abap_true OR + row_dimension->get_outline_level( io_worksheet ) > 0 OR row_dimension->get_xf_index( ) <> 0 OR l_autofilter_hidden = abap_true. " Row dimensions @@ -3440,12 +3490,12 @@ lo_element_2->set_attribute_ns( name = 'ht' value = lv_value ). ENDIF. " Collapsed - IF row_dimension->get_collapsed( ) = abap_true. + IF row_dimension->get_collapsed( io_worksheet ) = abap_true. lo_element_2->set_attribute_ns( name = 'collapsed' value = 'true'). ENDIF. " Outline level - IF row_dimension->get_outline_level( ) > 0. - lv_value = row_dimension->get_outline_level( ). + IF row_dimension->get_outline_level( io_worksheet ) > 0. + lv_value = row_dimension->get_outline_level( io_worksheet ). SHIFT lv_value RIGHT DELETING TRAILING space. SHIFT lv_value LEFT DELETING LEADING space. lo_element_2->set_attribute_ns( name = 'outlineLevel' value = lv_value ). @@ -3527,7 +3577,8 @@ CONDENSE lv_value. lo_element_4->set_value( value = lv_value ). lo_element_3->append_child( new_child = lo_element_4 ). " fomula node - ELSEIF <ls_sheet_content>-cell_value IS NOT INITIAL. "cell can have just style or formula + ELSEIF <ls_sheet_content>-cell_value IS NOT INITIAL "cell can have just style or formula + AND <ls_sheet_content>-cell_value <> lc_dummy_cell_content. IF <ls_sheet_content>-data_type IS NOT INITIAL. IF <ls_sheet_content>-data_type EQ 's_leading_blanks'. lo_element_3->set_attribute_ns( name = lc_xml_attr_t @@ -3578,6 +3629,7 @@ ENDIF. lo_element->append_child( new_child = lo_element_2 ). " row node ENDIF. + DELETE io_worksheet->sheet_content WHERE cell_value = lc_dummy_cell_content. " Get rid of dummyentries lo_element_root->append_child( new_child = lo_element ). " sheetData node diff --git a/ZA2X/PROG/ZDEMO_EXCEL12.slnk b/ZA2X/PROG/ZDEMO_EXCEL12.slnk index 2826348..151fd8a 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL12.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL12.slnk @@ -1,5 +1,5 @@ - - + + @@ -51,9 +51,11 @@ START-OF-SELECTION. lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Hello world (hidden row)' ). lo_worksheet->set_cell( ip_column = 'E' ip_row = 5 ip_value = 'Hello world in a row height size 20' ). - lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Outline row level 0' ). - lo_worksheet->set_cell( ip_column = 'B' ip_row = 7 ip_value = 'Outline row level 1' ). - lo_worksheet->set_cell( ip_column = 'B' ip_row = 8 ip_value = 'Outline row level 2' ). + lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Simple outline rows 10-16 ( collapsed )' ). + lo_worksheet->set_cell( ip_column = 'B' ip_row = 19 ip_value = '3 Outlines - Outlinelevel 1 is collapsed' ). + lo_worksheet->set_cell( ip_column = 'C' ip_row = 19 ip_value = 'One of the two inner outlines is expanded, one collapsed' ). + lo_worksheet->set_cell( ip_column = 'B' ip_row = 20 ip_value = 'Inner outline level - expanded' ). + lo_worksheet->set_cell( ip_column = 'B' ip_row = 24 ip_value = 'Inner outline level - lines 25-28 are collapsed' ). lo_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_off. " By default is on lo_worksheet->zif_excel_sheet_properties~summaryright = zif_excel_sheet_properties=>c_right_off. " By default is on @@ -81,13 +83,38 @@ START-OF-SELECTION. row_dimension->set_visible( ip_visible = abap_false ). row_dimension = lo_worksheet->get_row_dimension( ip_row = 5 ). row_dimension->set_row_height( ip_row_height = 20 ). - " Implementation in the Writer is not working yet ===== TODO ===== - row_dimension = lo_worksheet->get_row_dimension( ip_row = 6 ). - row_dimension->set_outline_level( ip_outline_level = 0 ). - row_dimension = lo_worksheet->get_row_dimension( ip_row = 7 ). - row_dimension->set_outline_level( ip_outline_level = 1 ). - row_dimension = lo_worksheet->get_row_dimension( ip_row = 8 ). - row_dimension->set_outline_level( ip_outline_level = 2 ). +* obsolete, not intuitive. Use new method shown below +* " Implementation in the Writer is not working yet ===== TODO ===== +* row_dimension = lo_worksheet->get_row_dimension( ip_row = 6 ). +* row_dimension->set_outline_level( ip_outline_level = 0 ). +* row_dimension = lo_worksheet->get_row_dimension( ip_row = 7 ). +* row_dimension->set_outline_level( ip_outline_level = 1 ). +* row_dimension = lo_worksheet->get_row_dimension( ip_row = 8 ). +* row_dimension->set_outline_level( ip_outline_level = 2 ). + +* Define an outline rows 10-16, collapsed on startup + lo_worksheet->set_row_outline( iv_row_from = 10 + iv_row_to = 16 + iv_collapsed = abap_true ). " collapsed + +* Define an inner outline rows 21-22, expanded when outer outline becomes extended + lo_worksheet->set_row_outline( iv_row_from = 21 + iv_row_to = 22 + iv_collapsed = abap_false ). " expanded + +* Define an inner outline rows 25-28, collapsed on startup + lo_worksheet->set_row_outline( iv_row_from = 25 + iv_row_to = 28 + iv_collapsed = abap_true ). " collapsed + +* Define an outer outline rows 20-30, collapsed on startup + lo_worksheet->set_row_outline( iv_row_from = 20 + iv_row_to = 30 + iv_collapsed = abap_true ). " collapsed + +* Hint: the order you create the outlines can be arbitrary +* You can start with inner outlines or with outer outlines + *** Create output lcl_output=>output( lo_excel ).