mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 11:06:15 +08:00
Merge branch 'main' into patch-converter-alv-get-filter
This commit is contained in:
commit
263a4f42af
|
@ -1664,26 +1664,19 @@ CLASS zcl_excel_converter IMPLEMENTATION.
|
||||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount
|
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount
|
||||||
filename = l_dir
|
filename = l_dir
|
||||||
filetype = 'BIN'
|
filetype = 'BIN'
|
||||||
CHANGING data_tab = lt_file ).
|
CHANGING data_tab = lt_file
|
||||||
cl_gui_frontend_services=>execute(
|
EXCEPTIONS OTHERS = 1 ).
|
||||||
EXPORTING
|
IF sy-subrc <> 0.
|
||||||
document = l_dir
|
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||||
EXCEPTIONS
|
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||||
cntl_error = 1
|
ELSE.
|
||||||
error_no_gui = 2
|
cl_gui_frontend_services=>execute( EXPORTING document = l_dir
|
||||||
bad_parameter = 3
|
EXCEPTIONS OTHERS = 1 ).
|
||||||
file_not_found = 4
|
|
||||||
path_not_found = 5
|
|
||||||
file_extension_unknown = 6
|
|
||||||
error_execute_failed = 7
|
|
||||||
synchronous_failed = 8
|
|
||||||
not_supported_by_gui = 9
|
|
||||||
).
|
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
ENDIF.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1812,7 +1805,12 @@ CLASS zcl_excel_converter IMPLEMENTATION.
|
||||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount
|
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount
|
||||||
filename = l_dir
|
filename = l_dir
|
||||||
filetype = 'BIN'
|
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.
|
ENDIF.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -999,6 +999,9 @@ CLASS zcl_excel_reader_2007 IMPLEMENTATION.
|
||||||
*--------------------------------------------------------------------*
|
*--------------------------------------------------------------------*
|
||||||
CLEAR: lv_current_offset.
|
CLEAR: lv_current_offset.
|
||||||
WHILE lo_node_si_child IS BOUND. " actually these children of <si> are <r>-tags
|
WHILE lo_node_si_child IS BOUND. " actually these children of <si> are <r>-tags
|
||||||
|
lv_tag_name = lo_node_si_child->get_name( ).
|
||||||
|
IF lv_tag_name = 'r'.
|
||||||
|
|
||||||
CLEAR: ls_rtf.
|
CLEAR: ls_rtf.
|
||||||
|
|
||||||
" extracting rich text formating data
|
" extracting rich text formating data
|
||||||
|
@ -1014,10 +1017,13 @@ CLASS zcl_excel_reader_2007 IMPLEMENTATION.
|
||||||
lv_node_value = unescape_string_value( lo_node_r_child_t->get_value( ) ).
|
lv_node_value = unescape_string_value( lo_node_r_child_t->get_value( ) ).
|
||||||
CONCATENATE <ls_shared_string>-value lv_node_value INTO <ls_shared_string>-value RESPECTING BLANKS.
|
CONCATENATE <ls_shared_string>-value lv_node_value INTO <ls_shared_string>-value RESPECTING BLANKS.
|
||||||
ls_rtf-length = strlen( lv_node_value ).
|
ls_rtf-length = strlen( lv_node_value ).
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
|
IF ls_rtf-length > 0.
|
||||||
lv_current_offset = strlen( <ls_shared_string>-value ).
|
lv_current_offset = strlen( <ls_shared_string>-value ).
|
||||||
APPEND ls_rtf TO <ls_shared_string>-rtf.
|
APPEND ls_rtf TO <ls_shared_string>-rtf.
|
||||||
|
ENDIF.
|
||||||
|
ENDIF.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
lo_node_si_child ?= lo_node_si_child->get_next( ).
|
lo_node_si_child ?= lo_node_si_child->get_next( ).
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@ CLASS zcl_excel_writer_csv DEFINITION
|
||||||
CLASS-METHODS set_initial_ext_date
|
CLASS-METHODS set_initial_ext_date
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!ip_value TYPE char10 DEFAULT c_default .
|
!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
|
*"* protected components of class ZCL_EXCEL_WRITER_CSV
|
||||||
*"* do not include other source files here!!!
|
*"* do not include other source files here!!!
|
||||||
PROTECTED SECTION.
|
PROTECTED SECTION.
|
||||||
|
@ -45,6 +51,8 @@ CLASS zcl_excel_writer_csv DEFINITION
|
||||||
CLASS-DATA worksheet_name TYPE zexcel_worksheets_name .
|
CLASS-DATA worksheet_name TYPE zexcel_worksheets_name .
|
||||||
CLASS-DATA worksheet_index TYPE zexcel_active_worksheet .
|
CLASS-DATA worksheet_index TYPE zexcel_active_worksheet .
|
||||||
CLASS-DATA initial_ext_date TYPE char10 VALUE c_default.
|
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
|
METHODS create
|
||||||
RETURNING
|
RETURNING
|
||||||
|
@ -91,6 +99,9 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
|
||||||
DATA: lo_iterator TYPE REF TO zcl_excel_collection_iterator,
|
DATA: lo_iterator TYPE REF TO zcl_excel_collection_iterator,
|
||||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
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,
|
DATA: lt_cell_data TYPE zexcel_t_cell_data_unsorted,
|
||||||
lv_row TYPE i,
|
lv_row TYPE i,
|
||||||
lv_col TYPE i,
|
lv_col TYPE i,
|
||||||
|
@ -113,8 +124,9 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
|
||||||
* --- Retrieve SAP date format
|
* --- Retrieve SAP date format
|
||||||
CLEAR ls_format.
|
CLEAR ls_format.
|
||||||
SELECT ddtext INTO ls_format-attvalue FROM dd07t WHERE domname = 'XUDATFM'
|
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-cmpname = 'DATE'.
|
||||||
|
ls_format-attvalue = ls_format-attvalue(10). " Ignore description, only use pattern
|
||||||
CONDENSE ls_format-attvalue.
|
CONDENSE ls_format-attvalue.
|
||||||
CONCATENATE '''' ls_format-attvalue '''' INTO ls_format-attvalue.
|
CONCATENATE '''' ls_format-attvalue '''' INTO ls_format-attvalue.
|
||||||
APPEND ls_format TO lt_format.
|
APPEND ls_format TO lt_format.
|
||||||
|
@ -151,11 +163,54 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
|
||||||
|
|
||||||
SORT lt_cell_data BY cell_row
|
SORT lt_cell_data BY cell_row
|
||||||
cell_column.
|
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_row = 1.
|
||||||
lv_col = 1.
|
lv_col = 1.
|
||||||
CLEAR lv_string.
|
CLEAR lv_string.
|
||||||
LOOP AT lt_cell_data ASSIGNING <fs_sheet_content>.
|
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
|
* --- Retrieve Cell Style format and data type
|
||||||
CLEAR ls_numfmt.
|
CLEAR ls_numfmt.
|
||||||
IF <fs_sheet_content>-data_type IS INITIAL AND <fs_sheet_content>-cell_style IS NOT INITIAL.
|
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. " lv_attrname IS NOT INITIAL.
|
||||||
ENDIF. " <fs_sheet_content>-data_type IS INITIAL AND ls_numfmt 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.
|
* ----- Use format to determine the data type and display format.
|
||||||
CASE <fs_sheet_content>-data_type.
|
CASE <fs_sheet_content>-data_type.
|
||||||
|
|
||||||
|
@ -318,6 +360,16 @@ CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
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.
|
METHOD zif_excel_writer~write_file.
|
||||||
me->excel = io_excel.
|
me->excel = io_excel.
|
||||||
ep_file = me->create( ).
|
ep_file = me->create( ).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user