Merge branch 'main' into hvam/deps0609

This commit is contained in:
Lars Hvam 2025-01-16 11:35:37 +01:00 committed by GitHub
commit f379e1f4fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 86 additions and 45 deletions

View File

@ -1664,26 +1664,19 @@ CLASS zcl_excel_converter IMPLEMENTATION.
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount
filename = l_dir
filetype = 'BIN'
CHANGING data_tab = lt_file ).
cl_gui_frontend_services=>execute(
EXPORTING
document = l_dir
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
).
CHANGING data_tab = lt_file
EXCEPTIONS OTHERS = 1 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
cl_gui_frontend_services=>execute( EXPORTING document = l_dir
EXCEPTIONS OTHERS = 1 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
@ -1812,7 +1805,12 @@ CLASS zcl_excel_converter IMPLEMENTATION.
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount
filename = l_dir
filetype = 'BIN'
CHANGING data_tab = lt_file ).
CHANGING data_tab = lt_file
EXCEPTIONS OTHERS = 1 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@ -3492,26 +3492,17 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.
METHOD normalize_style_parameter.
DATA: lo_style_type TYPE REF TO cl_abap_typedescr.
FIELD-SYMBOLS:
<style> TYPE REF TO zcl_excel_style.
DATA lo_style_type TYPE REF TO cl_abap_typedescr.
FIELD-SYMBOLS <style> TYPE REF TO zcl_excel_style.
CHECK ip_style_or_guid IS NOT INITIAL.
lo_style_type = cl_abap_typedescr=>describe_by_data( ip_style_or_guid ).
IF lo_style_type->type_kind = lo_style_type->typekind_oref.
lo_style_type = cl_abap_typedescr=>describe_by_object_ref( ip_style_or_guid ).
IF lo_style_type->absolute_name = '\CLASS=ZCL_EXCEL_STYLE'.
ASSIGN ip_style_or_guid TO <style>.
rv_guid = <style>->get_guid( ).
ENDIF.
ELSEIF lo_style_type->absolute_name = '\TYPE=ZEXCEL_CELL_STYLE'.
rv_guid = ip_style_or_guid.
ELSEIF lo_style_type->type_kind = lo_style_type->typekind_hex.
rv_guid = ip_style_or_guid.
ELSE.
RAISE EXCEPTION TYPE zcx_excel EXPORTING error = 'IP_GUID type must be either REF TO zcl_excel_style or zexcel_cell_style'.
ENDIF.

View File

@ -30,6 +30,12 @@ CLASS zcl_excel_writer_csv DEFINITION
CLASS-METHODS set_initial_ext_date
IMPORTING
!ip_value TYPE char10 DEFAULT c_default .
CLASS-METHODS set_skip_hidden_rows
IMPORTING
!ip_value TYPE abap_bool.
CLASS-METHODS set_skip_hidden_columns
IMPORTING
!ip_value TYPE abap_bool.
*"* protected components of class ZCL_EXCEL_WRITER_CSV
*"* do not include other source files here!!!
PROTECTED SECTION.
@ -45,6 +51,8 @@ CLASS zcl_excel_writer_csv DEFINITION
CLASS-DATA worksheet_name TYPE zexcel_worksheets_name .
CLASS-DATA worksheet_index TYPE zexcel_active_worksheet .
CLASS-DATA initial_ext_date TYPE char10 VALUE c_default.
CLASS-DATA skip_hidden_rows TYPE abap_bool.
CLASS-DATA skip_hidden_columns TYPE abap_bool.
METHODS create
RETURNING
@ -91,6 +99,9 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
DATA: lo_iterator TYPE REF TO zcl_excel_collection_iterator,
lo_worksheet TYPE REF TO zcl_excel_worksheet.
DATA: lo_autofilter TYPE REF TO zcl_excel_autofilter.
DATA: lv_row_hidden TYPE abap_bool.
DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted,
lv_row TYPE i,
lv_col TYPE i,
@ -113,8 +124,9 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
* --- Retrieve SAP date format
CLEAR ls_format.
SELECT ddtext INTO ls_format-attvalue FROM dd07t WHERE domname = 'XUDATFM'
AND ddlanguage = sy-langu.
AND ( ddlanguage = sy-langu OR ddlanguage = 'E' ).
ls_format-cmpname = 'DATE'.
ls_format-attvalue = ls_format-attvalue(10). " Ignore description, only use pattern
CONDENSE ls_format-attvalue.
CONCATENATE '''' ls_format-attvalue '''' INTO ls_format-attvalue.
APPEND ls_format TO lt_format.
@ -151,11 +163,54 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
SORT lt_cell_data BY cell_row
cell_column.
IF skip_hidden_rows = abap_true.
* --- Retrieve autofilters (to identify hidden rows)
lo_autofilter = excel->get_autofilters_reference( )->get( io_worksheet = lo_worksheet ).
IF lo_autofilter IS NOT INITIAL.
lo_autofilter->get_filter_area( ). " trigger filter area validation
ENDIF.
ENDIF.
lv_row = 1.
lv_col = 1.
CLEAR lv_string.
LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>.
* --- Check, if row is hidden
AT NEW cell_row.
IF lo_autofilter IS NOT INITIAL.
lv_row_hidden = lo_autofilter->is_row_hidden( iv_row = <fs_sheet_content>-cell_row ).
ENDIF.
ENDAT.
* --- Add empty rows
WHILE lv_row < <fs_sheet_content>-cell_row.
CONCATENATE lv_string zcl_excel_writer_csv=>eol INTO lv_string.
lv_row = lv_row + 1.
lv_col = 1.
ENDWHILE.
* --- Skip hidden rows
IF lv_row_hidden = abap_true.
lv_row = <fs_sheet_content>-cell_row + 1.
lv_col = 1.
CONTINUE.
ENDIF.
* --- Add empty columns
WHILE lv_col < <fs_sheet_content>-cell_column.
CONCATENATE lv_string zcl_excel_writer_csv=>delimiter INTO lv_string.
lv_col = lv_col + 1.
ENDWHILE.
* --- Skip hidden columns
IF skip_hidden_columns = abap_true AND
lo_worksheet->get_column( ip_column = <fs_sheet_content>-cell_column )->get_visible( ) = abap_false.
lv_col = <fs_sheet_content>-cell_column + 1.
CONTINUE.
ENDIF.
* --- Retrieve Cell Style format and data type
CLEAR ls_numfmt.
IF <fs_sheet_content>-data_type IS INITIAL AND <fs_sheet_content>-cell_style IS NOT INITIAL.
@ -210,19 +265,6 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
ENDIF. " lv_attrname IS NOT INITIAL.
ENDIF. " <fs_sheet_content>-data_type IS INITIAL AND ls_numfmt IS NOT INITIAL.
* --- Add empty rows
WHILE lv_row < <fs_sheet_content>-cell_row.
CONCATENATE lv_string zcl_excel_writer_csv=>eol INTO lv_string.
lv_row = lv_row + 1.
lv_col = 1.
ENDWHILE.
* --- Add empty columns
WHILE lv_col < <fs_sheet_content>-cell_column.
CONCATENATE lv_string zcl_excel_writer_csv=>delimiter INTO lv_string.
lv_col = lv_col + 1.
ENDWHILE.
* ----- Use format to determine the data type and display format.
CASE <fs_sheet_content>-data_type.
@ -318,6 +360,16 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
ENDMETHOD.
METHOD set_skip_hidden_rows.
skip_hidden_rows = ip_value.
ENDMETHOD.
METHOD set_skip_hidden_columns.
skip_hidden_columns = ip_value.
ENDMETHOD.
METHOD zif_excel_writer~write_file.
me->excel = io_excel.
ep_file = me->create( ).