mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 14:06:24 +08:00
zdemo_excel29 demo file from Web Repository (#989)
Fix #988 * zdemo_excel29 demo file from Web Repository * Delete TestMacro.xlsm * Remove comment about ZDEMO_EXCEL29/TestMacro.xlsm Co-authored-by: sandraros <sandra.rossi@gmail.com>
This commit is contained in:
parent
77afa4480d
commit
07340621a2
|
@ -22,11 +22,6 @@ Implement SAP OSS Notes:
|
|||
|
||||
[Note 1385713 - SUBMIT: Allowing parameter of type STRING](https://service.sap.com/sap/support/notes/1385713)
|
||||
|
||||
* Macro-Enabled workbook
|
||||
|
||||
Run report ZDEMO_EXCEL29 and use as VBA source file [TestMacro.xlsm](https://github.com/abap2xlsx/abap2xlsx/blob/master/resources/TestMacro.xlsm) attached.
|
||||
Basically abap2xlsx works using an existing VBA binary (we do not want to create a VBA editor).
|
||||
|
||||
* Download XLSX files in Background
|
||||
|
||||
Run report ZDEMO_EXCEL25.
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL26
|
||||
*& Report ZDEMO_EXCEL29
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
|
@ -19,18 +19,35 @@ DATA: lv_file TYPE xstring,
|
|||
DATA: lv_full_path TYPE string,
|
||||
lv_filename TYPE string,
|
||||
lv_workdir TYPE string.
|
||||
DATA: lv_separator TYPE c LENGTH 1.
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir OBLIGATORY.
|
||||
SELECTION-SCREEN COMMENT /1(83) p_text1.
|
||||
SELECTION-SCREEN COMMENT /1(83) p_text2.
|
||||
SELECTION-SCREEN SKIP 1.
|
||||
|
||||
PARAMETERS: p_smw0 RADIOBUTTON GROUP rad1 DEFAULT 'X'.
|
||||
PARAMETERS: p_objid TYPE w3objid OBLIGATORY DEFAULT 'ZDEMO_EXCEL29_INPUT'.
|
||||
|
||||
PARAMETERS: p_file RADIOBUTTON GROUP rad1.
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
LOAD-OF-PROGRAM.
|
||||
p_text1 = 'abap2xlsx works with VBA macro by using an existing VBA binary.'.
|
||||
p_text2 = '(we do not want to create a VBA editor).'.
|
||||
|
||||
AT SELECTION-SCREEN OUTPUT.
|
||||
IF p_path IS INITIAL.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_separator ).
|
||||
p_path = lv_workdir && lv_separator && 'TestMacro.xlsm'.
|
||||
ENDIF.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
DATA: lt_filetable TYPE filetable,
|
||||
lv_rc TYPE i.
|
||||
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
CALL METHOD cl_gui_frontend_services=>file_open_dialog
|
||||
EXPORTING
|
||||
window_title = 'Select Macro-Enabled Workbook template'
|
||||
|
@ -59,7 +76,12 @@ START-OF-SELECTION.
|
|||
|
||||
CREATE OBJECT lo_excel_reader TYPE zcl_excel_reader_xlsm.
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_xlsm.
|
||||
lo_excel = lo_excel_reader->load_file( lv_full_path ).
|
||||
* load template
|
||||
IF p_file IS NOT INITIAL.
|
||||
lo_excel = lo_excel_reader->load_file( lv_full_path ).
|
||||
ELSE.
|
||||
PERFORM load_smw0 USING lo_excel_reader p_objid CHANGING lo_excel.
|
||||
ENDIF.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
REPLACE '.xlsm' IN lv_full_path WITH 'FromReader.xlsm'.
|
||||
|
||||
|
@ -77,3 +99,65 @@ START-OF-SELECTION.
|
|||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
||||
|
||||
FORM load_smw0
|
||||
USING
|
||||
io_reader TYPE REF TO zif_excel_reader
|
||||
iv_w3objid TYPE w3objid
|
||||
CHANGING
|
||||
ro_excel TYPE REF TO zcl_excel
|
||||
RAISING
|
||||
zcx_excel.
|
||||
|
||||
DATA: lv_excel_data TYPE xstring,
|
||||
lt_mime TYPE TABLE OF w3mime,
|
||||
ls_key TYPE wwwdatatab,
|
||||
lv_errormessage TYPE string,
|
||||
lv_filesize TYPE i,
|
||||
lv_filesizec TYPE c LENGTH 10.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Read file into binary string
|
||||
*--------------------------------------------------------------------*
|
||||
|
||||
ls_key-relid = 'MI'.
|
||||
ls_key-objid = iv_w3objid .
|
||||
|
||||
CALL FUNCTION 'WWWDATA_IMPORT'
|
||||
EXPORTING
|
||||
key = ls_key
|
||||
TABLES
|
||||
mime = lt_mime
|
||||
EXCEPTIONS
|
||||
OTHERS = 1.
|
||||
IF sy-subrc <> 0.
|
||||
lv_errormessage = 'A problem occured when reading the MIME object'(004).
|
||||
zcx_excel=>raise_text( lv_errormessage ).
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'WWWPARAMS_READ'
|
||||
EXPORTING
|
||||
relid = ls_key-relid
|
||||
objid = ls_key-objid
|
||||
name = 'filesize'
|
||||
IMPORTING
|
||||
value = lv_filesizec.
|
||||
|
||||
lv_filesize = lv_filesizec.
|
||||
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
|
||||
EXPORTING
|
||||
input_length = lv_filesize
|
||||
IMPORTING
|
||||
buffer = lv_excel_data
|
||||
TABLES
|
||||
binary_tab = lt_mime
|
||||
EXCEPTIONS
|
||||
failed = 1
|
||||
OTHERS = 2.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Parse Excel data into ZCL_EXCEL object from binary string
|
||||
*--------------------------------------------------------------------*
|
||||
ro_excel = io_reader->load( i_excel2007 = lv_excel_data ).
|
||||
|
||||
ENDFORM.
|
||||
|
|
|
@ -13,15 +13,33 @@
|
|||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Marco-Enabled workbook</ENTRY>
|
||||
<ENTRY>abap2xlsx Demo: Macro-Enabled workbook</ENTRY>
|
||||
<LENGTH>38</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_FILE</KEY>
|
||||
<ENTRY>Load template from file</ENTRY>
|
||||
<LENGTH>31</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_OBJID</KEY>
|
||||
<ENTRY>Object ID</ENTRY>
|
||||
<LENGTH>17</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>Macro-enabled Workbook</ENTRY>
|
||||
<LENGTH>30</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_SMW0</KEY>
|
||||
<ENTRY>Load template from SMW0</ENTRY>
|
||||
<LENGTH>31</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
|
|
BIN
src/demos/zdemo_excel29_input.w3mi.data.xlsm
Normal file
BIN
src/demos/zdemo_excel29_input.w3mi.data.xlsm
Normal file
Binary file not shown.
29
src/demos/zdemo_excel29_input.w3mi.xml
Normal file
29
src/demos/zdemo_excel29_input.w3mi.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_W3MI" serializer_version="v2.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<NAME>ZDEMO_EXCEL29_INPUT</NAME>
|
||||
<TEXT>abap2xlsx resources/TestMacro.xlsm</TEXT>
|
||||
<PARAMS>
|
||||
<WWWPARAMS>
|
||||
<RELID>MI</RELID>
|
||||
<OBJID>ZDEMO_EXCEL29_INPUT</OBJID>
|
||||
<NAME>fileextension</NAME>
|
||||
<VALUE>.xlsm</VALUE>
|
||||
</WWWPARAMS>
|
||||
<WWWPARAMS>
|
||||
<RELID>MI</RELID>
|
||||
<OBJID>ZDEMO_EXCEL29_INPUT</OBJID>
|
||||
<NAME>filename</NAME>
|
||||
<VALUE>TestMacro.xlsm</VALUE>
|
||||
</WWWPARAMS>
|
||||
<WWWPARAMS>
|
||||
<RELID>MI</RELID>
|
||||
<OBJID>ZDEMO_EXCEL29_INPUT</OBJID>
|
||||
<NAME>mimetype</NAME>
|
||||
<VALUE>application/vnd.ms-excel.sheet.macroEnabled</VALUE>
|
||||
</WWWPARAMS>
|
||||
</PARAMS>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
Loading…
Reference in New Issue
Block a user