diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk
index 6dc5bdc..febf3d0 100644
--- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk
+++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk
@@ -18,7 +18,7 @@
-
+
@@ -28,8 +28,8 @@
-
-
+
+ method ZIF_EXCEL_WRITER~WRITE_FILE.
me->excel = io_excel.
@@ -2644,7 +2644,7 @@
*--------------------------------------------------------------------*
TYPES: BEGIN OF colors,
- colorrgb TYPE zexcel_color,
+ colorrgb TYPE zexcel_color,
END OF colors.
*--------------------------------------------------------------------*
@@ -2653,18 +2653,18 @@
*--------------------------------------------------------------------*
TYPES: BEGIN OF cfvo,
- value TYPE zexcel_conditional_value,
- type TYPE zexcel_conditional_type,
+ 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,
+ 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
@@ -2816,11 +2816,11 @@
lc_xml_attr_tabcolor_rgb TYPE string VALUE 'rgb',
lc_xml_attr_tabcolor_theme TYPE string VALUE 'theme',
" Node namespace
- lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
- lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
- lc_xml_node_comp_ns TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006',
- lc_xml_node_comp_pref TYPE string VALUE 'x14ac',
- lc_xml_node_ig_ns TYPE string VALUE 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'.
+ lc_xml_node_ns TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
+ lc_xml_node_r_ns TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
+ lc_xml_node_comp_ns TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006',
+ lc_xml_node_comp_pref TYPE string VALUE 'x14ac',
+ lc_xml_node_ig_ns TYPE string VALUE 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'.
DATA: lo_ixml TYPE REF TO if_ixml,
lo_document TYPE REF TO if_ixml_document,
@@ -2838,6 +2838,7 @@
lo_data_validation TYPE REF TO zcl_excel_data_validation,
lo_table TYPE REF TO zcl_excel_table,
row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi,
+ lo_row_dim_empty TYPE REF TO zcl_excel_worksheet_rowdimensi,
default_col_dimension TYPE REF TO zcl_excel_worksheet_columndime,
default_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi.
@@ -2870,6 +2871,10 @@
lv_relation_id TYPE i VALUE 0,
outline_level_row TYPE i VALUE 0,
outline_level_col TYPE i VALUE 0,
+ lv_current_row TYPE i,
+ 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,
col_count TYPE int4,
merge_count TYPE int4,
write_current_row TYPE boolean,
@@ -3353,79 +3358,108 @@
* 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>.
+ 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.
CLEAR l_autofilter_hidden.
ENDIF.
CLEAR ls_style_mapping.
- IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row.
- IF lo_autofilter IS BOUND.
- IF ls_area-row_start >= ls_last_row-cell_row OR " One less for header
- ls_area-row_end < ls_last_row-cell_row .
+* Create row element
+* issues #346,#154, #195 - problems when we have information in row_dimension but no cell content in that row
+* Get next line that may have to be added. If we have empty lines this is the next line after previous cell content
+* Otherwise it is the line of the current cell content
+ lv_current_row = ls_last_row-cell_row + 1.
+ IF lv_current_row > ls_sheet_content-cell_row.
+ lv_current_row = ls_sheet_content-cell_row.
+ ENDIF.
+* Fill in empty lines if necessary - assign an emtpy sheet content
+ lv_next_row = lv_current_row.
+ WHILE lv_next_row <= ls_sheet_content-cell_row.
+ lv_current_row = lv_next_row.
+ lv_next_row = lv_current_row + 1.
+ IF lv_current_row = ls_sheet_content-cell_row. " cell value found in this row
+ ASSIGN ls_sheet_content TO <ls_sheet_content>.
+ 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.
+ " Dummyentry A1
+ ls_sheet_content_empty-cell_row = lv_current_row.
+ ls_sheet_content_empty-cell_column = 1.
+ ASSIGN ls_sheet_content_empty TO <ls_sheet_content>.
+ ENDIF.
+
+ IF ls_last_row-cell_row NE <ls_sheet_content>-cell_row.
+ IF lo_autofilter IS BOUND.
+ IF ls_area-row_start >= ls_last_row-cell_row OR " One less for header
+ ls_area-row_end < ls_last_row-cell_row .
+ CLEAR l_autofilter_hidden.
+ ENDIF.
+ ELSE.
CLEAR l_autofilter_hidden.
ENDIF.
- ELSE.
- CLEAR l_autofilter_hidden.
- ENDIF.
- IF ls_last_row-cell_row IS NOT INITIAL.
- " Row visibility of previos row.
- IF row_dimension->get_visible( ) = abap_false OR
- l_autofilter_hidden = abap_true.
- lo_element_2->set_attribute_ns( name = 'hidden' value = 'true').
+ IF ls_last_row-cell_row IS NOT INITIAL.
+ " Row visibility of previos row.
+ IF row_dimension->get_visible( ) = abap_false OR
+ l_autofilter_hidden = abap_true.
+ lo_element_2->set_attribute_ns( name = 'hidden' value = 'true').
+ ENDIF.
+ lo_element->append_child( new_child = lo_element_2 ). " row node
ENDIF.
- lo_element->append_child( new_child = lo_element_2 ). " row node
- ENDIF.
- " Add new row
- lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row
- parent = lo_document ).
- " r
- lv_value = <ls_sheet_content>-cell_row.
- SHIFT lv_value RIGHT DELETING TRAILING space.
- SHIFT lv_value LEFT DELETING LEADING space.
+ " Add new row
+ lo_element_2 = lo_document->create_simple_element( name = lc_xml_node_row
+ parent = lo_document ).
+ " r
+ lv_value = <ls_sheet_content>-cell_row.
+ SHIFT lv_value RIGHT DELETING TRAILING space.
+ SHIFT lv_value LEFT DELETING LEADING space.
- lo_element_2->set_attribute_ns( name = lc_xml_attr_r
- value = lv_value ).
- " Spans
- lv_value = col_count.
- CONCATENATE '1:' lv_value INTO lv_value.
- SHIFT lv_value RIGHT DELETING TRAILING space.
- SHIFT lv_value LEFT DELETING LEADING space.
- lo_element_2->set_attribute_ns( name = lc_xml_attr_spans
- value = lv_value ).
- 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_xf_index( ) <> 0 OR
- l_autofilter_hidden = abap_true.
- " Row dimensions
- IF row_dimension->get_row_height( ) >= 0.
- lo_element_2->set_attribute_ns( name = 'customHeight' value = '1').
- lv_value = row_dimension->get_row_height( ).
- lo_element_2->set_attribute_ns( name = 'ht' value = lv_value ).
- ENDIF.
- " Collapsed
- IF row_dimension->get_collapsed( ) = 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( ).
- 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 ).
- ENDIF.
- " Style
- IF row_dimension->get_xf_index( ) <> 0.
- lv_value = row_dimension->get_xf_index( ).
- lo_element_2->set_attribute_ns( name = 's' value = lv_value ).
- lo_element_2->set_attribute_ns( name = 'customFormat' value = '1').
+ lo_element_2->set_attribute_ns( name = lc_xml_attr_r
+ value = lv_value ).
+ " Spans
+ lv_value = col_count.
+ CONCATENATE '1:' lv_value INTO lv_value.
+ SHIFT lv_value RIGHT DELETING TRAILING space.
+ SHIFT lv_value LEFT DELETING LEADING space.
+ lo_element_2->set_attribute_ns( name = lc_xml_attr_spans
+ value = lv_value ).
+ 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_xf_index( ) <> 0 OR
+ l_autofilter_hidden = abap_true.
+ " Row dimensions
+ IF row_dimension->get_row_height( ) >= 0.
+ lo_element_2->set_attribute_ns( name = 'customHeight' value = '1').
+ lv_value = row_dimension->get_row_height( ).
+ lo_element_2->set_attribute_ns( name = 'ht' value = lv_value ).
+ ENDIF.
+ " Collapsed
+ IF row_dimension->get_collapsed( ) = 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( ).
+ 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 ).
+ ENDIF.
+ " Style
+ IF row_dimension->get_xf_index( ) <> 0.
+ lv_value = row_dimension->get_xf_index( ).
+ lo_element_2->set_attribute_ns( name = 's' value = lv_value ).
+ lo_element_2->set_attribute_ns( name = 'customFormat' value = '1').
+ ENDIF.
ENDIF.
+ l_autofilter_hidden = abap_true. " First default is not showing
ENDIF.
- l_autofilter_hidden = abap_true. " First default is not showing
- ENDIF.
+ ENDWHILE.
lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_c
parent = lo_document ).
@@ -3508,7 +3542,7 @@
lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_v
parent = lo_document ).
- IF <ls_sheet_content>-data_type EQ 's' or <ls_sheet_content>-data_type EQ 's_leading_blanks'.
+ IF <ls_sheet_content>-data_type EQ 's' OR <ls_sheet_content>-data_type EQ 's_leading_blanks'.
lv_value = me->get_shared_string_index( <ls_sheet_content>-cell_value ).
CONDENSE lv_value.
lo_element_4->set_value( value = lv_value ).
@@ -4037,7 +4071,7 @@
" Hyperlinks
DATA: lv_hyperlinks_count TYPE i,
- lo_link TYPE REF TO zcl_excel_hyperlink.
+ lo_link TYPE REF TO zcl_excel_hyperlink.
lv_hyperlinks_count = io_worksheet->get_hyperlinks_size( ).
IF lv_hyperlinks_count > 0.
@@ -6174,10 +6208,10 @@ ENDMETHOD.
ENDIF.
endmethod.
-
+
- method GET_SHARED_STRING_INDEX.
+ METHOD get_shared_string_index.
DATA ls_shared_string TYPE zexcel_s_shared_string.
@@ -6185,6 +6219,6 @@ ENDMETHOD.
READ TABLE shared_strings INTO ls_shared_string WITH KEY string_value = ip_cell_value BINARY SEARCH.
ep_index = ls_shared_string-string_no.
- endmethod.
+ENDMETHOD.