mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 02:12:05 +08:00
customizable demo 25 + backend in demo 37 (#909)
and removing demo 25 from zdemo_excel (no interest). Co-authored-by: sandraros <sandra.rossi@gmail.com> Co-authored-by: Lars Hvam <larshp@hotmail.com> Co-authored-by: Abo <andrea@borgia.bo.it>
This commit is contained in:
parent
6efa4c6904
commit
df709ace6a
|
@ -60,7 +60,7 @@ START-OF-SELECTION.
|
|||
SUBMIT zdemo_excel22 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Bind table with field catalog & sheet style
|
||||
SUBMIT zdemo_excel23 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Multiple sheets with and w/o grid lines, print options
|
||||
SUBMIT zdemo_excel24 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Multiple sheets with different default date formats
|
||||
SUBMIT zdemo_excel25 AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Create and xlsx on Application Server (could be executed in batch mode)
|
||||
" zdemo_excel25 is not processed because the default logical path may not exist, and anyway zdemo_excel25 doesn't demonstrate any abap2xlsx feature
|
||||
" zdemo_excel26 is not added because it uses ALV and cannot be processed (Native)
|
||||
SUBMIT zdemo_excel27 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Conditional Formatting
|
||||
SUBMIT zdemo_excel28 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: CSV writer
|
||||
|
|
|
@ -8,7 +8,108 @@
|
|||
|
||||
REPORT zdemo_excel25.
|
||||
|
||||
CONSTANTS: lv_file_name TYPE string VALUE '25_HelloWorld.xlsx'.
|
||||
TYPES: BEGIN OF ty_f4_path,
|
||||
pathintern TYPE filepath-pathintern,
|
||||
pathname TYPE pathtext-pathname,
|
||||
pathextern TYPE path-pathextern,
|
||||
END OF ty_f4_path.
|
||||
|
||||
DATA: lt_r_fldval TYPE RANGE OF filepath-pathintern,
|
||||
lt_value TYPE TABLE OF ty_f4_path,
|
||||
ls_value TYPE ty_f4_path.
|
||||
|
||||
PARAMETERS log_path TYPE filepath-pathintern DEFAULT 'LOCAL_TEMPORARY_FILES'.
|
||||
SELECTION-SCREEN COMMENT /35(83) physpath.
|
||||
PARAMETERS filename TYPE string LOWER CASE DEFAULT '25_HelloWorld.xlsx'.
|
||||
PARAMETERS param_1 TYPE string LOWER CASE.
|
||||
PARAMETERS param_2 TYPE string LOWER CASE.
|
||||
|
||||
AT SELECTION-SCREEN OUTPUT.
|
||||
|
||||
PERFORM read_file_paths.
|
||||
READ TABLE lt_value WITH KEY pathintern = log_path INTO ls_value.
|
||||
physpath = ls_value-pathextern.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR log_path.
|
||||
|
||||
DATA: lt_return TYPE TABLE OF ddshretval,
|
||||
ls_return TYPE ddshretval,
|
||||
lt_dynpfield TYPE TABLE OF dynpread,
|
||||
ls_dynpfield TYPE dynpread.
|
||||
|
||||
CALL FUNCTION 'DYNP_VALUES_READ'
|
||||
EXPORTING
|
||||
dyname = sy-repid
|
||||
dynumb = sy-dynnr
|
||||
request = 'A' " read all screen fields
|
||||
TABLES
|
||||
dynpfields = lt_dynpfield
|
||||
EXCEPTIONS
|
||||
OTHERS = 9.
|
||||
|
||||
READ TABLE lt_dynpfield WITH KEY fieldname = 'LOG_PATH' INTO ls_dynpfield.
|
||||
log_path = ls_dynpfield-fieldvalue.
|
||||
|
||||
PERFORM read_file_paths.
|
||||
|
||||
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
|
||||
EXPORTING
|
||||
value_org = 'S'
|
||||
multiple_choice = ' '
|
||||
retfield = 'PATHINTERN'
|
||||
TABLES
|
||||
value_tab = lt_value
|
||||
return_tab = lt_return
|
||||
EXCEPTIONS
|
||||
OTHERS = 0.
|
||||
|
||||
IF lt_return IS INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_return INDEX 1 INTO ls_return.
|
||||
READ TABLE lt_value WITH KEY pathintern = ls_return-fieldval INTO ls_value.
|
||||
|
||||
DELETE lt_dynpfield WHERE fieldname = 'LOG_PATH' OR fieldname = 'PHYSPATH'.
|
||||
ls_dynpfield-fieldname = 'LOG_PATH'.
|
||||
ls_dynpfield-fieldvalue = ls_value-pathintern.
|
||||
APPEND ls_dynpfield TO lt_dynpfield.
|
||||
ls_dynpfield-fieldname = 'PHYSPATH'.
|
||||
ls_dynpfield-fieldvalue = ls_value-pathextern.
|
||||
APPEND ls_dynpfield TO lt_dynpfield.
|
||||
|
||||
CALL FUNCTION 'DYNP_VALUES_UPDATE'
|
||||
EXPORTING
|
||||
dyname = sy-repid
|
||||
dynumb = sy-dynnr
|
||||
TABLES
|
||||
dynpfields = lt_dynpfield
|
||||
EXCEPTIONS
|
||||
OTHERS = 8.
|
||||
|
||||
FORM read_file_paths.
|
||||
|
||||
DATA: ls_r_fldval LIKE LINE OF lt_r_fldval.
|
||||
|
||||
CLEAR lt_r_fldval.
|
||||
IF log_path CA '*'.
|
||||
ls_r_fldval-sign = 'I'.
|
||||
ls_r_fldval-option = 'CP'.
|
||||
ls_r_fldval-low = log_path.
|
||||
APPEND ls_r_fldval TO lt_r_fldval.
|
||||
ENDIF.
|
||||
|
||||
SELECT filepath~pathintern pathtext~pathname path~pathextern
|
||||
FROM filepath
|
||||
INNER JOIN path ON path~pathintern = filepath~pathintern
|
||||
INNER JOIN opsystem ON opsystem~filesys = path~filesys AND opsystem~opsys = sy-opsys
|
||||
LEFT JOIN pathtext ON pathtext~pathintern = filepath~pathintern AND pathtext~language = sy-langu
|
||||
INTO TABLE lt_value
|
||||
WHERE filepath~pathintern IN lt_r_fldval.
|
||||
|
||||
ENDFORM.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel.
|
||||
DATA: lo_excel_writer TYPE REF TO zif_excel_writer.
|
||||
|
@ -16,12 +117,15 @@ DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
|||
DATA: lo_exception TYPE REF TO cx_root.
|
||||
DATA: lv_file TYPE xstring.
|
||||
DATA: lv_default_file_name TYPE string.
|
||||
DATA: lv_default_file_name2 TYPE c LENGTH 255.
|
||||
DATA: lv_error TYPE string.
|
||||
|
||||
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
|
||||
EXPORTING
|
||||
logical_path = 'LOCAL_TEMPORARY_FILES' " Logical path'
|
||||
file_name = lv_file_name " File name
|
||||
logical_path = log_path
|
||||
file_name = filename
|
||||
parameter_1 = param_1
|
||||
parameter_2 = param_2
|
||||
IMPORTING
|
||||
file_name_with_path = lv_default_file_name " File name with path
|
||||
EXCEPTIONS
|
||||
|
@ -57,4 +161,9 @@ TRY.
|
|||
CATCH cx_root INTO lo_exception.
|
||||
lv_error = lo_exception->get_text( ).
|
||||
MESSAGE lv_error TYPE 'I'.
|
||||
STOP.
|
||||
ENDTRY.
|
||||
|
||||
lv_default_file_name2 = lv_default_file_name.
|
||||
SET PARAMETER ID 'GR8' FIELD lv_default_file_name2.
|
||||
SUBMIT zdemo_excel37 VIA SELECTION-SCREEN WITH p_applse = abap_true AND RETURN.
|
||||
|
|
|
@ -16,6 +16,7 @@ DATA: gc_save_file_name TYPE string VALUE '37- Read template and output.&'.
|
|||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK blx WITH FRAME.
|
||||
PARAMETERS: p_upfile TYPE string LOWER CASE MEMORY ID gr8.
|
||||
PARAMETERS: p_applse AS CHECKBOX.
|
||||
SELECTION-SCREEN END OF BLOCK blx.
|
||||
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
@ -240,13 +241,13 @@ FORM read_template RAISING zcx_excel .
|
|||
|
||||
WHEN '.XLSX'.
|
||||
CREATE OBJECT reader TYPE zcl_excel_reader_2007.
|
||||
excel = reader->load_file( p_upfile ).
|
||||
excel = reader->load_file( i_filename = p_upfile i_from_applserver = p_applse ).
|
||||
"Use template for charts
|
||||
excel->use_template = abap_true.
|
||||
|
||||
WHEN '.XLSM'.
|
||||
CREATE OBJECT reader TYPE zcl_excel_reader_xlsm.
|
||||
excel = reader->load_file( p_upfile ).
|
||||
excel = reader->load_file( i_filename = p_upfile i_from_applserver = p_applse ).
|
||||
"Use template for charts
|
||||
excel->use_template = abap_true.
|
||||
|
||||
|
@ -258,7 +259,7 @@ FORM read_template RAISING zcx_excel .
|
|||
|
||||
WHEN OTHERS.
|
||||
CREATE OBJECT reader TYPE (lb_read).
|
||||
excel = reader->load_file( p_upfile ).
|
||||
excel = reader->load_file( i_filename = p_upfile i_from_applserver = p_applse ).
|
||||
"Use template for charts
|
||||
excel->use_template = abap_true.
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
<ENTRY>Writer class</ENTRY>
|
||||
<LENGTH>20</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_APPLSE</KEY>
|
||||
<ENTRY>From Application Server</ENTRY>
|
||||
<LENGTH>31</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_UPFILE</KEY>
|
||||
|
|
Loading…
Reference in New Issue
Block a user