diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index 0d6303f..da48beb 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -107,6 +107,7 @@ CLASS zcl_excel_worksheet DEFINITION !it_field_catalog TYPE zexcel_t_fieldcatalog OPTIONAL !is_table_settings TYPE zexcel_s_table_settings OPTIONAL value(iv_default_descr) TYPE c OPTIONAL + !IV_NO_LINE_IF_EMPTY type ABAP_BOOL default ABAP_FALSE EXPORTING !es_table_settings TYPE zexcel_s_table_settings RAISING @@ -3030,7 +3031,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. ADD 1 TO lv_row_int. ENDLOOP. - IF sy-subrc <> 0. "create empty row if table has no data + IF sy-subrc <> 0 AND iv_no_line_if_empty = abap_false. "create empty row if table has no data me->set_cell( ip_column = lv_column_alpha ip_row = lv_row_int ip_value = space ). @@ -4876,7 +4877,8 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. ep_value_type = lv_value_type ). ENDIF. CASE lv_value_type. - WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2. + WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2 + OR cl_abap_typedescr=>typekind_int8. "Allow INT8 types columns lo_addit = cl_abap_elemdescr=>get_i( ). CREATE DATA lo_value_new TYPE HANDLE lo_addit. ASSIGN lo_value_new->* TO . diff --git a/src/zdemo_excel.prog.abap b/src/zdemo_excel.prog.abap index 3a67a46..8034d16 100644 --- a/src/zdemo_excel.prog.abap +++ b/src/zdemo_excel.prog.abap @@ -77,6 +77,7 @@ START-OF-SELECTION. SUBMIT zdemo_excel39 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Charts SUBMIT zdemo_excel40 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Demo Printsettings SUBMIT zdemo_excel41 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Inheritance + SUBMIT zdemo_excel44 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: No line if empty SUBMIT zdemo_excel_comments WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Comments SUBMIT ztest_excel_image_header WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Image in Header and Footer diff --git a/src/zdemo_excel44.prog.abap b/src/zdemo_excel44.prog.abap new file mode 100644 index 0000000..da052a4 --- /dev/null +++ b/src/zdemo_excel44.prog.abap @@ -0,0 +1,58 @@ +*&---------------------------------------------------------------------* +*& Report ZDEMO_EXCEL44 +*& +*&---------------------------------------------------------------------* +*& +*& +*&---------------------------------------------------------------------* + +REPORT zdemo_excel44. + +DATA: lo_excel_no_line_if_empty TYPE REF TO zcl_excel, + lo_excel TYPE REF TO zcl_excel, + lo_worksheet_no_line_if_empty TYPE REF TO zcl_excel_worksheet, + lo_worksheet TYPE REF TO zcl_excel_worksheet. + +DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog. + +DATA: gc_save_file_name TYPE string VALUE '44_iTabEmpty.csv'. +INCLUDE zdemo_excel_outputopt_incl. + +SELECTION-SCREEN BEGIN OF BLOCK b44 WITH FRAME TITLE txt_b44. + +* No line if internal table is empty +DATA: p_mtyfil TYPE flag VALUE abap_true. + +SELECTION-SCREEN END OF BLOCK b44. + +INITIALIZATION. + txt_b44 = 'Testing empty file option'(b44). + +START-OF-SELECTION. + + " Creates active sheet + CREATE OBJECT lo_excel_no_line_if_empty. + CREATE OBJECT lo_excel. + + " Get active sheet + lo_worksheet_no_line_if_empty = lo_excel_no_line_if_empty->get_active_worksheet( ). + lo_worksheet = lo_excel->get_active_worksheet( ). + lo_worksheet_no_line_if_empty->set_title( 'Internal table' ). + lo_worksheet->set_title( 'Internal table' ). + + DATA lt_test TYPE TABLE OF sflight. + + lo_worksheet_no_line_if_empty->bind_table( ip_table = lt_test + iv_no_line_if_empty = p_mtyfil ). + + p_mtyfil = abap_false. + lo_worksheet->bind_table( ip_table = lt_test + iv_no_line_if_empty = p_mtyfil ). + +*** Create output + lcl_output=>output( EXPORTING cl_excel = lo_excel_no_line_if_empty + iv_writerclass_name = 'ZCL_EXCEL_WRITER_CSV' ). + + gc_save_file_name = '44_iTabNotEmpty.csv'. + lcl_output=>output( EXPORTING cl_excel = lo_excel + iv_writerclass_name = 'ZCL_EXCEL_WRITER_CSV' ). diff --git a/src/zdemo_excel44.prog.xml b/src/zdemo_excel44.prog.xml new file mode 100644 index 0000000..d06dda8 --- /dev/null +++ b/src/zdemo_excel44.prog.xml @@ -0,0 +1,34 @@ + + + + + + ZDEMO_EXCEL44 + 1 + T + E + X + X + + + + I + B44 + Testing empty file option + 50 + + + R + Demo excel 44 + 13 + + + S + P_MTYFIL + No data => No empty line + 32 + + + + +