mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 05:36:21 +08:00
Moving to abapGit
This commit is contained in:
parent
f8b0e354db
commit
14874360eb
259
src/zabap2xlsx_demo_show.prog.abap
Normal file
259
src/zabap2xlsx_demo_show.prog.abap
Normal file
|
@ -0,0 +1,259 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZABAP2XLSX_DEMO_SHOW
|
||||
*&---------------------------------------------------------------------*
|
||||
REPORT zabap2xlsx_demo_like_se83.
|
||||
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS lcl_perform DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_perform DEFINITION CREATE PRIVATE.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS: setup_objects,
|
||||
collect_reports,
|
||||
|
||||
handle_nav FOR EVENT double_click OF cl_gui_alv_grid
|
||||
IMPORTING e_row.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES: BEGIN OF ty_reports,
|
||||
progname TYPE reposrc-progname,
|
||||
sort TYPE reposrc-progname,
|
||||
filename TYPE string,
|
||||
END OF ty_reports.
|
||||
|
||||
CLASS-DATA:
|
||||
lo_grid TYPE REF TO cl_gui_alv_grid,
|
||||
lo_text TYPE REF TO cl_gui_textedit,
|
||||
cl_document TYPE REF TO i_oi_document_proxy,
|
||||
|
||||
t_reports TYPE STANDARD TABLE OF ty_reports WITH NON-UNIQUE DEFAULT KEY.
|
||||
CLASS-DATA:error TYPE REF TO i_oi_error,
|
||||
t_errors TYPE STANDARD TABLE OF REF TO i_oi_error WITH NON-UNIQUE DEFAULT KEY,
|
||||
cl_control TYPE REF TO i_oi_container_control. "Office Dokument
|
||||
|
||||
ENDCLASS. "lcl_perform DEFINITION
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
lcl_perform=>collect_reports( ).
|
||||
lcl_perform=>setup_objects( ).
|
||||
|
||||
END-OF-SELECTION.
|
||||
|
||||
WRITE '.'. " Force output
|
||||
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS lcl_perform IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_perform IMPLEMENTATION.
|
||||
METHOD setup_objects.
|
||||
DATA: lo_split TYPE REF TO cl_gui_splitter_container,
|
||||
lo_container TYPE REF TO cl_gui_container.
|
||||
|
||||
DATA: it_fieldcat TYPE lvc_t_fcat,
|
||||
is_layout TYPE lvc_s_layo,
|
||||
is_variant TYPE disvariant.
|
||||
FIELD-SYMBOLS: <fc> LIKE LINE OF it_fieldcat.
|
||||
|
||||
|
||||
CREATE OBJECT lo_split
|
||||
EXPORTING
|
||||
parent = cl_gui_container=>screen0
|
||||
rows = 1
|
||||
columns = 3
|
||||
no_autodef_progid_dynnr = 'X'.
|
||||
lo_split->set_column_width( EXPORTING id = 1
|
||||
width = 20 ).
|
||||
lo_split->set_column_width( EXPORTING id = 2
|
||||
width = 40 ).
|
||||
|
||||
* Left: List of reports
|
||||
lo_container = lo_split->get_container( row = 1
|
||||
column = 1 ).
|
||||
|
||||
CREATE OBJECT lo_grid
|
||||
EXPORTING
|
||||
i_parent = lo_container.
|
||||
SET HANDLER lcl_perform=>handle_nav FOR lo_grid.
|
||||
|
||||
is_variant-report = sy-repid.
|
||||
is_variant-handle = '0001'.
|
||||
|
||||
is_layout-cwidth_opt = 'X'.
|
||||
|
||||
APPEND INITIAL LINE TO it_fieldcat ASSIGNING <fc>.
|
||||
<fc>-fieldname = 'PROGNAME'.
|
||||
<fc>-tabname = 'REPOSRC'.
|
||||
|
||||
APPEND INITIAL LINE TO it_fieldcat ASSIGNING <fc>.
|
||||
<fc>-fieldname = 'SORT'.
|
||||
<fc>-ref_field = 'PROGNAME'.
|
||||
<fc>-ref_table = 'REPOSRC'.
|
||||
|
||||
|
||||
lo_grid->set_table_for_first_display( EXPORTING
|
||||
is_variant = is_variant
|
||||
i_save = 'A'
|
||||
is_layout = is_layout
|
||||
CHANGING
|
||||
it_outtab = t_reports
|
||||
it_fieldcatalog = it_fieldcat
|
||||
EXCEPTIONS
|
||||
invalid_parameter_combination = 1
|
||||
program_error = 2
|
||||
too_many_lines = 3
|
||||
OTHERS = 4 ).
|
||||
|
||||
* Middle: Text with coding
|
||||
lo_container = lo_split->get_container( row = 1
|
||||
column = 2 ).
|
||||
CREATE OBJECT lo_text
|
||||
EXPORTING
|
||||
parent = lo_container.
|
||||
lo_text->set_readonly_mode( cl_gui_textedit=>true ).
|
||||
lo_text->set_font_fixed( ).
|
||||
|
||||
|
||||
|
||||
* right: DemoOutput
|
||||
lo_container = lo_split->get_container( row = 1
|
||||
column = 3 ).
|
||||
|
||||
c_oi_container_control_creator=>get_container_control( IMPORTING control = cl_control
|
||||
error = error ).
|
||||
APPEND error TO t_errors.
|
||||
|
||||
cl_control->init_control( EXPORTING inplace_enabled = 'X'
|
||||
no_flush = 'X'
|
||||
r3_application_name = 'Demo Document Container'
|
||||
parent = lo_container
|
||||
IMPORTING error = error
|
||||
EXCEPTIONS OTHERS = 2 ).
|
||||
APPEND error TO t_errors.
|
||||
|
||||
cl_control->get_document_proxy( EXPORTING document_type = 'Excel.Sheet' " EXCEL
|
||||
no_flush = ' '
|
||||
IMPORTING document_proxy = cl_document
|
||||
error = error ).
|
||||
APPEND error TO t_errors.
|
||||
* Errorhandling should be inserted here
|
||||
|
||||
|
||||
ENDMETHOD. "setup_objects
|
||||
|
||||
"collect_reports
|
||||
METHOD collect_reports.
|
||||
FIELD-SYMBOLS:<report> LIKE LINE OF t_reports.
|
||||
DATA: t_source TYPE STANDARD TABLE OF text255 WITH NON-UNIQUE DEFAULT KEY.
|
||||
|
||||
* Get all demoreports
|
||||
SELECT progname
|
||||
INTO CORRESPONDING FIELDS OF TABLE t_reports
|
||||
FROM reposrc
|
||||
WHERE progname LIKE 'ZDEMO_EXCEL%'
|
||||
AND progname <> sy-repid
|
||||
AND subc = '1'.
|
||||
|
||||
LOOP AT t_reports ASSIGNING <report>.
|
||||
|
||||
* Check if already switched to new outputoptions
|
||||
READ REPORT <report>-progname INTO t_source.
|
||||
IF sy-subrc = 0.
|
||||
FIND 'INCLUDE zdemo_excel_outputopt_incl.' IN TABLE t_source IGNORING CASE.
|
||||
ENDIF.
|
||||
IF sy-subrc <> 0.
|
||||
DELETE t_reports.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
|
||||
|
||||
* Build half-numeric sort
|
||||
<report>-sort = <report>-progname.
|
||||
REPLACE REGEX '(ZDEMO_EXCEL)(\d\d)\s*$' IN <report>-sort WITH '$1\0$2'. " REPLACE REGEX '(ZDEMO_EXCEL)([^][^])*$' IN <report>-sort WITH '$1$2'.REPLACE REGEX '(ZDEMO_EXCEL)([^][^])*$' IN <report>-sort WITH '$1$2'.REPLACE
|
||||
|
||||
REPLACE REGEX '(ZDEMO_EXCEL)(\d)\s*$' IN <report>-sort WITH '$1\0\0$2'.
|
||||
ENDLOOP.
|
||||
SORT t_reports BY sort progname.
|
||||
|
||||
ENDMETHOD. "collect_reports
|
||||
|
||||
METHOD handle_nav.
|
||||
CONSTANTS: filename TYPE text80 VALUE 'ZABAP2XLSX_DEMO_SHOW.xlsx'.
|
||||
DATA: wa_report LIKE LINE OF t_reports,
|
||||
t_source TYPE STANDARD TABLE OF text255,
|
||||
t_rawdata TYPE solix_tab,
|
||||
wa_rawdata LIKE LINE OF t_rawdata,
|
||||
bytecount TYPE i,
|
||||
length TYPE i,
|
||||
add_selopt TYPE flag.
|
||||
|
||||
|
||||
READ TABLE t_reports INTO wa_report INDEX e_row-index.
|
||||
CHECK sy-subrc = 0.
|
||||
|
||||
* Set new text into middle frame
|
||||
READ REPORT wa_report-progname INTO t_source.
|
||||
lo_text->set_text_as_r3table( EXPORTING table = t_source ).
|
||||
|
||||
|
||||
* Unload old xls-file
|
||||
cl_document->close_document( ).
|
||||
|
||||
* Get the demo
|
||||
* If additional parameters found on selection screen, start via selection screen , otherwise start w/o
|
||||
CLEAR add_selopt.
|
||||
FIND 'PARAMETERS' IN TABLE t_source.
|
||||
IF sy-subrc = 0.
|
||||
add_selopt = 'X'.
|
||||
ELSE.
|
||||
FIND 'SELECT-OPTIONS' IN TABLE t_source.
|
||||
IF sy-subrc = 0.
|
||||
add_selopt = 'X'.
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
IF add_selopt IS INITIAL.
|
||||
SUBMIT (wa_report-progname) AND RETURN "#EC CI_SUBMIT
|
||||
WITH p_backfn = filename
|
||||
WITH rb_back = 'X'
|
||||
WITH rb_down = ' '
|
||||
WITH rb_send = ' '
|
||||
WITH rb_show = ' '.
|
||||
ELSE.
|
||||
SUBMIT (wa_report-progname) VIA SELECTION-SCREEN AND RETURN "#EC CI_SUBMIT
|
||||
WITH p_backfn = filename
|
||||
WITH rb_back = 'X'
|
||||
WITH rb_down = ' '
|
||||
WITH rb_send = ' '
|
||||
WITH rb_show = ' '.
|
||||
ENDIF.
|
||||
|
||||
OPEN DATASET filename FOR INPUT IN BINARY MODE.
|
||||
IF sy-subrc = 0.
|
||||
DO.
|
||||
CLEAR wa_rawdata.
|
||||
READ DATASET filename INTO wa_rawdata LENGTH length.
|
||||
IF sy-subrc <> 0.
|
||||
APPEND wa_rawdata TO t_rawdata.
|
||||
ADD length TO bytecount.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
APPEND wa_rawdata TO t_rawdata.
|
||||
ADD length TO bytecount.
|
||||
ENDDO.
|
||||
CLOSE DATASET filename.
|
||||
ENDIF.
|
||||
|
||||
cl_control->get_document_proxy( EXPORTING document_type = 'Excel.Sheet' " EXCEL
|
||||
no_flush = ' '
|
||||
IMPORTING document_proxy = cl_document
|
||||
error = error ).
|
||||
|
||||
cl_document->open_document_from_table( EXPORTING document_size = bytecount
|
||||
document_table = t_rawdata
|
||||
open_inplace = 'X' ).
|
||||
|
||||
ENDMETHOD. "handle_nav
|
||||
|
||||
ENDCLASS. "lcl_perform IMPLEMENTATION
|
25
src/zabap2xlsx_demo_show.prog.xml
Normal file
25
src/zabap2xlsx_demo_show.prog.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAP2XLSX_DEMO_SHOW</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo Show</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
757
src/zangry_birds.prog.abap
Normal file
757
src/zangry_birds.prog.abap
Normal file
|
@ -0,0 +1,757 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZANGRY_BIRDS
|
||||
*& Just for fun
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zangry_birds.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_border_light TYPE REF TO zcl_excel_style_border,
|
||||
lo_style_color0 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color1 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color2 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color3 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color4 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color5 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color6 TYPE REF TO zcl_excel_style,
|
||||
lo_style_color7 TYPE REF TO zcl_excel_style,
|
||||
lo_style_credit TYPE REF TO zcl_excel_style,
|
||||
lo_style_link TYPE REF TO zcl_excel_style,
|
||||
lo_column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
lo_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink.
|
||||
|
||||
DATA: lv_style_color0_guid TYPE zexcel_cell_style,
|
||||
lv_style_color1_guid TYPE zexcel_cell_style,
|
||||
lv_style_color2_guid TYPE zexcel_cell_style,
|
||||
lv_style_color3_guid TYPE zexcel_cell_style,
|
||||
lv_style_color4_guid TYPE zexcel_cell_style,
|
||||
lv_style_color5_guid TYPE zexcel_cell_style,
|
||||
lv_style_color6_guid TYPE zexcel_cell_style,
|
||||
lv_style_color7_guid TYPE zexcel_cell_style,
|
||||
lv_style_credit_guid TYPE zexcel_cell_style,
|
||||
lv_style_link_guid TYPE zexcel_cell_style,
|
||||
lv_style TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_col_str TYPE zexcel_cell_column_alpha,
|
||||
lv_row TYPE i,
|
||||
lv_col TYPE i,
|
||||
lt_mapper TYPE TABLE OF zexcel_cell_style,
|
||||
ls_mapper TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'angry_birds.xlsx'.
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
CREATE OBJECT lo_border_light.
|
||||
lo_border_light->border_color-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_border_light->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
|
||||
" Create color white
|
||||
lo_style_color0 = lo_excel->add_new_style( ).
|
||||
lo_style_color0->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color0->fill->fgcolor-rgb = 'FFFFFFFF'.
|
||||
lo_style_color0->borders->allborders = lo_border_light.
|
||||
lv_style_color0_guid = lo_style_color0->get_guid( ).
|
||||
|
||||
" Create color black
|
||||
lo_style_color1 = lo_excel->add_new_style( ).
|
||||
lo_style_color1->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color1->fill->fgcolor-rgb = 'FF252525'.
|
||||
lo_style_color1->borders->allborders = lo_border_light.
|
||||
lv_style_color1_guid = lo_style_color1->get_guid( ).
|
||||
|
||||
" Create color dark green
|
||||
lo_style_color2 = lo_excel->add_new_style( ).
|
||||
lo_style_color2->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color2->fill->fgcolor-rgb = 'FF75913A'.
|
||||
lo_style_color2->borders->allborders = lo_border_light.
|
||||
lv_style_color2_guid = lo_style_color2->get_guid( ).
|
||||
|
||||
" Create color light green
|
||||
lo_style_color3 = lo_excel->add_new_style( ).
|
||||
lo_style_color3->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color3->fill->fgcolor-rgb = 'FF9DFB73'.
|
||||
lo_style_color3->borders->allborders = lo_border_light.
|
||||
lv_style_color3_guid = lo_style_color3->get_guid( ).
|
||||
|
||||
" Create color green
|
||||
lo_style_color4 = lo_excel->add_new_style( ).
|
||||
lo_style_color4->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color4->fill->fgcolor-rgb = 'FF92CF56'.
|
||||
lo_style_color4->borders->allborders = lo_border_light.
|
||||
lv_style_color4_guid = lo_style_color4->get_guid( ).
|
||||
|
||||
" Create color 2dark green
|
||||
lo_style_color5 = lo_excel->add_new_style( ).
|
||||
lo_style_color5->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color5->fill->fgcolor-rgb = 'FF506228'.
|
||||
lo_style_color5->borders->allborders = lo_border_light.
|
||||
lv_style_color5_guid = lo_style_color5->get_guid( ).
|
||||
|
||||
" Create color yellow
|
||||
lo_style_color6 = lo_excel->add_new_style( ).
|
||||
lo_style_color6->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color6->fill->fgcolor-rgb = 'FFC3E224'.
|
||||
lo_style_color6->borders->allborders = lo_border_light.
|
||||
lv_style_color6_guid = lo_style_color6->get_guid( ).
|
||||
|
||||
" Create color yellow
|
||||
lo_style_color7 = lo_excel->add_new_style( ).
|
||||
lo_style_color7->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_color7->fill->fgcolor-rgb = 'FFB3C14F'.
|
||||
lo_style_color7->borders->allborders = lo_border_light.
|
||||
lv_style_color7_guid = lo_style_color7->get_guid( ).
|
||||
|
||||
" Credits
|
||||
lo_style_credit = lo_excel->add_new_style( ).
|
||||
lo_style_credit->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_credit->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
|
||||
lo_style_credit->font->size = 20.
|
||||
lv_style_credit_guid = lo_style_credit->get_guid( ).
|
||||
|
||||
" Link
|
||||
lo_style_link = lo_excel->add_new_style( ).
|
||||
lo_style_link->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_link->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
|
||||
* lo_style_link->font->size = 20.
|
||||
lv_style_link_guid = lo_style_link->get_guid( ).
|
||||
|
||||
" Create image map " line 2
|
||||
DO 30 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 3
|
||||
DO 28 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 4
|
||||
DO 27 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 5
|
||||
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 15 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 6
|
||||
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 7
|
||||
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 8
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 9
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 10
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 11
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 12
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 13
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 14
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 12 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 15
|
||||
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 16
|
||||
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 17
|
||||
DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 13 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 18
|
||||
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 19
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 27 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 20
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 21
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 19 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 22
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 23
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 24
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 25
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 26
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 27
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 28
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 29
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 30
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 31
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 32
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 33
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 34
|
||||
DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 35
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 36
|
||||
DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 37
|
||||
DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 38
|
||||
DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 39
|
||||
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 22 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 40
|
||||
DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 41
|
||||
DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 15 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 42
|
||||
DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 43
|
||||
DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO.
|
||||
DO 7 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 44
|
||||
DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 45
|
||||
DO 16 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 13 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
" line 46
|
||||
DO 18 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO.
|
||||
DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO.
|
||||
APPEND INITIAL LINE TO lt_mapper. " escape
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Angry Birds' ).
|
||||
|
||||
lv_row = 1.
|
||||
lv_col = 1.
|
||||
|
||||
LOOP AT lt_mapper INTO ls_mapper.
|
||||
lv_col_str = zcl_excel_common=>convert_column2alpha( lv_col ).
|
||||
IF ls_mapper IS INITIAL.
|
||||
lo_row_dimension = lo_worksheet->get_row_dimension( ip_row = lv_row ).
|
||||
lo_row_dimension->set_row_height( ip_row_height = 8 ).
|
||||
lv_col = 1.
|
||||
lv_row = lv_row + 1.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
lo_worksheet->set_cell( ip_column = lv_col_str
|
||||
ip_row = lv_row
|
||||
ip_value = space
|
||||
ip_style = ls_mapper ).
|
||||
lv_col = lv_col + 1.
|
||||
|
||||
lo_column_dimension = lo_worksheet->get_column_dimension( ip_column = lv_col_str ).
|
||||
lo_column_dimension->set_width( ip_width = 2 ).
|
||||
ENDLOOP.
|
||||
|
||||
lo_worksheet->set_show_gridlines( i_show_gridlines = abap_false ).
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 'AP'
|
||||
ip_row = 15
|
||||
ip_value = 'Created with abap2xlsx'
|
||||
ip_style = lv_style_credit_guid ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'http://www.abap2xlsx.org' ).
|
||||
lo_worksheet->set_cell( ip_column = 'AP'
|
||||
ip_row = 24
|
||||
ip_value = 'http://www.abap2xlsx.org'
|
||||
ip_style = lv_style_link_guid
|
||||
ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
lo_column_dimension = lo_worksheet->get_column_dimension( ip_column = 'AP' ).
|
||||
lo_column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
lo_worksheet->set_merge( ip_row = 15 ip_column_start = 'AP' ip_row_to = 22 ip_column_end = 'AR' ).
|
||||
lo_worksheet->set_merge( ip_row = 24 ip_column_start = 'AP' ip_row_to = 26 ip_column_end = 'AR' ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
* " This method is only available on AS ABAP > 6.40
|
||||
* lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
* lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zangry_birds.prog.xml
Normal file
32
src/zangry_birds.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZANGRY_BIRDS</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Styles</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
385
src/zdemo_calendar.prog.abap
Normal file
385
src/zdemo_calendar.prog.abap
Normal file
|
@ -0,0 +1,385 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_CALENDAR
|
||||
*& abap2xlsx Demo: Create Calendar with Pictures
|
||||
*&---------------------------------------------------------------------*
|
||||
*& This report creates a monthly calendar in the specified date range.
|
||||
*& Each month is put on a seperate worksheet. The pictures for each
|
||||
*& month can be specified in a tab delimited file called "Calendar.txt"
|
||||
*& which is saved in the Export Directory. By default this is the SAP
|
||||
*& Workdir. The file contains 3 fields:
|
||||
*&
|
||||
*& Month (with leading 0)
|
||||
*& Image Filename
|
||||
*& Image Description
|
||||
*& URL for the Description
|
||||
*&
|
||||
*& The Images should be landscape JPEG's with a 3:2 ratio and min.
|
||||
*& 450 pixel height. They must also be saved in the Export Directory.
|
||||
*& In my tests I've discovered a limit of 20 MB in the
|
||||
*& cl_gui_frontend_services=>gui_download method. So keep your images
|
||||
*& smaller or change to a server export using OPEN DATASET.
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_calendar.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE 'Calendar.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
INCLUDE zdemo_calendar_classes.
|
||||
|
||||
DATA: lv_workdir TYPE string.
|
||||
|
||||
PARAMETERS: p_from TYPE dfrom DEFAULT '20130101',
|
||||
p_to TYPE dto DEFAULT '20131231'.
|
||||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK orientation WITH FRAME TITLE orient.
|
||||
PARAMETERS: p_portr TYPE flag RADIOBUTTON GROUP orie,
|
||||
p_lands TYPE flag RADIOBUTTON GROUP orie DEFAULT 'X'.
|
||||
SELECTION-SCREEN END OF BLOCK orientation.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
orient = 'Orientation'(000).
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
lo_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi,
|
||||
hyperlink TYPE REF TO zcl_excel_hyperlink,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing.
|
||||
|
||||
DATA: lo_style_month TYPE REF TO zcl_excel_style,
|
||||
lv_style_month_guid TYPE zexcel_cell_style.
|
||||
DATA: lo_style_border TYPE REF TO zcl_excel_style,
|
||||
lo_border_dark TYPE REF TO zcl_excel_style_border,
|
||||
lv_style_border_guid TYPE zexcel_cell_style.
|
||||
DATA: lo_style_center TYPE REF TO zcl_excel_style,
|
||||
lv_style_center_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
image_descr_path TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
DATA: lv_content TYPE xstring,
|
||||
width TYPE i,
|
||||
lv_height TYPE i,
|
||||
lv_from_row TYPE zexcel_cell_row.
|
||||
|
||||
DATA: month TYPE i,
|
||||
month_nr TYPE fcmnr,
|
||||
count TYPE i VALUE 1,
|
||||
title TYPE zexcel_sheet_title,
|
||||
value TYPE string,
|
||||
image_path TYPE string,
|
||||
date_from TYPE datum,
|
||||
date_to TYPE datum,
|
||||
row TYPE zexcel_cell_row,
|
||||
to_row TYPE zexcel_cell_row,
|
||||
to_col TYPE zexcel_cell_column_alpha,
|
||||
to_col_end TYPE zexcel_cell_column_alpha,
|
||||
to_col_int TYPE i.
|
||||
|
||||
DATA: month_names TYPE TABLE OF t247.
|
||||
FIELD-SYMBOLS: <month_name> LIKE LINE OF month_names.
|
||||
|
||||
TYPES: BEGIN OF tt_datatab,
|
||||
month_nr TYPE fcmnr,
|
||||
filename TYPE string,
|
||||
descr TYPE string,
|
||||
url TYPE string,
|
||||
END OF tt_datatab.
|
||||
|
||||
DATA: image_descriptions TYPE TABLE OF tt_datatab.
|
||||
FIELD-SYMBOLS: <img_descr> LIKE LINE OF image_descriptions.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'Calendar', "#EC NOTEXT
|
||||
c_from_row_portrait TYPE zexcel_cell_row VALUE 28,
|
||||
c_from_row_landscape TYPE zexcel_cell_row VALUE 38,
|
||||
from_col TYPE zexcel_cell_column_alpha VALUE 'C',
|
||||
c_height_portrait TYPE i VALUE 450, " Image Height in Portrait Mode
|
||||
c_height_landscape TYPE i VALUE 670, " Image Height in Landscape Mode
|
||||
c_factor TYPE f VALUE '1.5'. " Image Ratio, default 3:2
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name '.xlsx' INTO lv_full_path. "#EC NOTEXT
|
||||
|
||||
" Read Image Names for Month and Description
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name '.txt' INTO image_descr_path. "#EC NOTEXT
|
||||
cl_gui_frontend_services=>gui_upload(
|
||||
EXPORTING
|
||||
filename = image_descr_path " Name of file
|
||||
filetype = 'ASC' " File Type (ASCII, Binary)
|
||||
has_field_separator = 'X'
|
||||
read_by_line = 'X' " File Written Line-By-Line to the Internal Table
|
||||
CHANGING
|
||||
data_tab = image_descriptions " Transfer table for file contents
|
||||
EXCEPTIONS
|
||||
file_open_error = 1
|
||||
file_read_error = 2
|
||||
no_batch = 3
|
||||
gui_refuse_filetransfer = 4
|
||||
invalid_type = 5
|
||||
no_authority = 6
|
||||
unknown_error = 7
|
||||
bad_data_format = 8
|
||||
header_not_allowed = 9
|
||||
separator_not_allowed = 10
|
||||
header_too_long = 11
|
||||
unknown_dp_error = 12
|
||||
access_denied = 13
|
||||
dp_out_of_memory = 14
|
||||
disk_full = 15
|
||||
dp_timeout = 16
|
||||
not_supported_by_gui = 17
|
||||
error_no_gui = 18
|
||||
OTHERS = 19
|
||||
).
|
||||
IF sy-subrc <> 0.
|
||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
ENDIF.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create Styles
|
||||
" Create an underline double style
|
||||
lo_style_month = lo_excel->add_new_style( ).
|
||||
" lo_style_month->font->underline = abap_true.
|
||||
" lo_style_month->font->underline_mode = zcl_excel_style_font=>c_underline_single.
|
||||
lo_style_month->font->name = zcl_excel_style_font=>c_name_roman.
|
||||
lo_style_month->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_month->font->family = zcl_excel_style_font=>c_family_roman.
|
||||
lo_style_month->font->bold = abap_true.
|
||||
lo_style_month->font->size = 36.
|
||||
lv_style_month_guid = lo_style_month->get_guid( ).
|
||||
" Create border object
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black.
|
||||
lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
"Create style with border
|
||||
lo_style_border = lo_excel->add_new_style( ).
|
||||
lo_style_border->borders->allborders = lo_border_dark.
|
||||
lo_style_border->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_right.
|
||||
lo_style_border->alignment->vertical = zcl_excel_style_alignment=>c_vertical_top.
|
||||
lv_style_border_guid = lo_style_border->get_guid( ).
|
||||
"Create style alignment center
|
||||
lo_style_center = lo_excel->add_new_style( ).
|
||||
lo_style_center->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_center->alignment->vertical = zcl_excel_style_alignment=>c_vertical_top.
|
||||
lv_style_center_guid = lo_style_center->get_guid( ).
|
||||
|
||||
" Get Month Names
|
||||
CALL FUNCTION 'MONTH_NAMES_GET'
|
||||
TABLES
|
||||
month_names = month_names.
|
||||
|
||||
zcl_date_calculation=>months_between_two_dates(
|
||||
EXPORTING
|
||||
i_date_from = p_from
|
||||
i_date_to = p_to
|
||||
i_incl_to = abap_true
|
||||
IMPORTING
|
||||
e_month = month
|
||||
).
|
||||
|
||||
date_from = p_from.
|
||||
|
||||
WHILE count <= month.
|
||||
IF count = 1.
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
ELSE.
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
ENDIF.
|
||||
|
||||
lo_worksheet->zif_excel_sheet_properties~selected = zif_excel_sheet_properties=>c_selected.
|
||||
|
||||
title = count.
|
||||
value = count.
|
||||
CONDENSE title.
|
||||
CONDENSE value.
|
||||
lo_worksheet->set_title( title ).
|
||||
lo_worksheet->set_print_gridlines( abap_false ).
|
||||
lo_worksheet->sheet_setup->paper_size = zcl_excel_sheet_setup=>c_papersize_a4.
|
||||
lo_worksheet->sheet_setup->horizontal_centered = abap_true.
|
||||
lo_worksheet->sheet_setup->vertical_centered = abap_true.
|
||||
lo_col_dim = lo_worksheet->get_column_dimension( 'A' ).
|
||||
lo_col_dim->set_width( '1.0' ).
|
||||
lo_col_dim = lo_worksheet->get_column_dimension( 'B' ).
|
||||
lo_col_dim->set_width( '2.0' ).
|
||||
IF p_lands = abap_true.
|
||||
lo_worksheet->sheet_setup->orientation = zcl_excel_sheet_setup=>c_orientation_landscape.
|
||||
lv_height = c_height_landscape.
|
||||
lv_from_row = c_from_row_landscape.
|
||||
lo_worksheet->sheet_setup->margin_top = '0.10'.
|
||||
lo_worksheet->sheet_setup->margin_left = '0.10'.
|
||||
lo_worksheet->sheet_setup->margin_right = '0.10'.
|
||||
lo_worksheet->sheet_setup->margin_bottom = '0.10'.
|
||||
ELSE.
|
||||
lo_col_dim = lo_worksheet->get_column_dimension( 'K' ).
|
||||
lo_col_dim->set_width( '3.0' ).
|
||||
lo_worksheet->sheet_setup->margin_top = '0.80'.
|
||||
lo_worksheet->sheet_setup->margin_left = '0.55'.
|
||||
lo_worksheet->sheet_setup->margin_right = '0.05'.
|
||||
lo_worksheet->sheet_setup->margin_bottom = '0.30'.
|
||||
lv_height = c_height_portrait.
|
||||
lv_from_row = c_from_row_portrait.
|
||||
ENDIF.
|
||||
|
||||
" Add Month Name
|
||||
month_nr = date_from+4(2).
|
||||
IF p_portr = abap_true.
|
||||
READ TABLE month_names WITH KEY mnr = month_nr ASSIGNING <month_name>.
|
||||
CONCATENATE <month_name>-ltx ` ` date_from(4) INTO value.
|
||||
row = lv_from_row - 2.
|
||||
to_col = from_col.
|
||||
ELSE.
|
||||
row = lv_from_row - 1.
|
||||
to_col_int = zcl_excel_common=>convert_column2int( from_col ) + 32.
|
||||
to_col = zcl_excel_common=>convert_column2alpha( to_col_int ).
|
||||
to_col_int = to_col_int + 1.
|
||||
to_col_end = zcl_excel_common=>convert_column2alpha( to_col_int ).
|
||||
CONCATENATE month_nr '/' date_from+2(2) INTO value.
|
||||
to_row = row + 2.
|
||||
lo_worksheet->set_merge(
|
||||
EXPORTING
|
||||
ip_column_start = to_col " Cell Column Start
|
||||
ip_column_end = to_col_end " Cell Column End
|
||||
ip_row = row " Cell Row
|
||||
ip_row_to = to_row " Cell Row
|
||||
).
|
||||
ENDIF.
|
||||
lo_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = to_col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_style = lv_style_month_guid
|
||||
).
|
||||
|
||||
* to_col_int = zcl_excel_common=>convert_column2int( from_col ) + 7.
|
||||
* to_col = zcl_excel_common=>convert_column2alpha( to_col_int ).
|
||||
*
|
||||
* lo_worksheet->set_merge(
|
||||
* EXPORTING
|
||||
* ip_column_start = from_col " Cell Column Start
|
||||
* ip_column_end = to_col " Cell Column End
|
||||
* ip_row = row " Cell Row
|
||||
* ip_row_to = row " Cell Row
|
||||
* ).
|
||||
|
||||
" Add drawing from a XSTRING read from a file
|
||||
UNASSIGN <img_descr>.
|
||||
READ TABLE image_descriptions WITH KEY month_nr = month_nr ASSIGNING <img_descr>.
|
||||
IF <img_descr> IS ASSIGNED.
|
||||
value = <img_descr>-descr.
|
||||
IF p_portr = abap_true.
|
||||
row = lv_from_row - 3.
|
||||
ELSE.
|
||||
row = lv_from_row - 2.
|
||||
ENDIF.
|
||||
IF NOT <img_descr>-url IS INITIAL.
|
||||
hyperlink = zcl_excel_hyperlink=>create_external_link( <img_descr>-url ).
|
||||
lo_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = from_col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_hyperlink = hyperlink
|
||||
).
|
||||
ELSE.
|
||||
lo_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = from_col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
).
|
||||
ENDIF.
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( row ).
|
||||
lo_row_dim->set_row_height( '22.0' ).
|
||||
|
||||
" In Landscape mode the row between the description and the
|
||||
" dates should be not so high
|
||||
IF p_lands = abap_true.
|
||||
row = lv_from_row - 3.
|
||||
lo_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = from_col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = ' ' " Cell Value
|
||||
).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( row ).
|
||||
lo_row_dim->set_row_height( '7.0' ).
|
||||
row = lv_from_row - 1.
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( row ).
|
||||
lo_row_dim->set_row_height( '5.0' ).
|
||||
ENDIF.
|
||||
|
||||
CONCATENATE p_path lv_file_separator <img_descr>-filename INTO image_path.
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 1
|
||||
ip_from_col = 'B' ).
|
||||
|
||||
lv_content = zcl_helper=>load_image( image_path ).
|
||||
width = lv_height * c_factor.
|
||||
lo_drawing->set_media( ip_media = lv_content
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_jpg
|
||||
ip_width = width
|
||||
ip_height = lv_height ).
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
ENDIF.
|
||||
|
||||
" Add Calendar
|
||||
* CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
|
||||
* EXPORTING
|
||||
* day_in = date_from
|
||||
* IMPORTING
|
||||
* last_day_of_month = date_to.
|
||||
date_to = date_from.
|
||||
date_to+6(2) = '01'. " First of month
|
||||
add 31 to date_to. " Somewhere in following month
|
||||
date_to = date_to - date_to+6(2). " Last of month
|
||||
IF p_portr = abap_true.
|
||||
zcl_helper=>add_calendar(
|
||||
EXPORTING
|
||||
i_date_from = date_from
|
||||
i_date_to = date_to
|
||||
i_from_row = lv_from_row
|
||||
i_from_col = from_col
|
||||
i_day_style = lv_style_border_guid
|
||||
i_cw_style = lv_style_center_guid
|
||||
CHANGING
|
||||
c_worksheet = lo_worksheet
|
||||
).
|
||||
ELSE.
|
||||
zcl_helper=>add_calendar_landscape(
|
||||
EXPORTING
|
||||
i_date_from = date_from
|
||||
i_date_to = date_to
|
||||
i_from_row = lv_from_row
|
||||
i_from_col = from_col
|
||||
i_day_style = lv_style_border_guid
|
||||
i_cw_style = lv_style_center_guid
|
||||
CHANGING
|
||||
c_worksheet = lo_worksheet
|
||||
).
|
||||
ENDIF.
|
||||
count = count + 1.
|
||||
date_from = date_to + 1.
|
||||
ENDWHILE.
|
||||
|
||||
lo_excel->set_active_sheet_index_by_name( '1' ).
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
136
src/zdemo_calendar.prog.xml
Normal file
136
src/zdemo_calendar.prog.xml
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_CALENDAR</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>000</KEY>
|
||||
<ENTRY>Orientation</ENTRY>
|
||||
<LENGTH>11</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>001</KEY>
|
||||
<ENTRY>CW</ENTRY>
|
||||
<LENGTH>4</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>002</KEY>
|
||||
<ENTRY>Created with abap2xlsx. Find more information at https://ivanfemia.github.io/abap2xlsx/</ENTRY>
|
||||
<LENGTH>100</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Create Calendar with Pictures</ENTRY>
|
||||
<LENGTH>45</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_FROM</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>17</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_LANDS</KEY>
|
||||
<ENTRY>Landscape</ENTRY>
|
||||
<LENGTH>17</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PORTR</KEY>
|
||||
<ENTRY>Portrait</ENTRY>
|
||||
<LENGTH>16</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_TO</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>15</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
<I18N_TPOOL>
|
||||
<item>
|
||||
<LANGUAGE>D</LANGUAGE>
|
||||
<TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>I</ID>
|
||||
<KEY>000</KEY>
|
||||
<ENTRY>Ausrichtung</ENTRY>
|
||||
<LENGTH>11</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>I</ID>
|
||||
<KEY>001</KEY>
|
||||
<ENTRY>KW</ENTRY>
|
||||
<LENGTH>4</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>I</ID>
|
||||
<KEY>002</KEY>
|
||||
<ENTRY>Erzeugt mit abap2xlsx. Weitere Informationen unter https://ivanfemia.github.io/abap2xlsx/</ENTRY>
|
||||
<LENGTH>100</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Erzeugen eines Kalenders mit Bildern</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_LANDS</KEY>
|
||||
<ENTRY> Querformat</ENTRY>
|
||||
<LENGTH>18</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PORTR</KEY>
|
||||
<ENTRY> Hochformat</ENTRY>
|
||||
<LENGTH>18</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_FROM</KEY>
|
||||
<ENTRY>D .</ENTRY>
|
||||
<LENGTH>17</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>D .</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_TO</KEY>
|
||||
<ENTRY>D .</ENTRY>
|
||||
<LENGTH>15</LENGTH>
|
||||
</TEXTPOOL>
|
||||
</TEXTPOOL>
|
||||
</item>
|
||||
</I18N_TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
471
src/zdemo_calendar_classes.prog.abap
Normal file
471
src/zdemo_calendar_classes.prog.abap
Normal file
|
@ -0,0 +1,471 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZDEMO_CALENDAR_CLASSES
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Class ZCL_DATE_CALCULATION
|
||||
*&---------------------------------------------------------------------*
|
||||
* Text
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS zcl_date_calculation DEFINITION.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS: months_between_two_dates
|
||||
IMPORTING
|
||||
i_date_from TYPE datum
|
||||
i_date_to TYPE datum
|
||||
i_incl_to TYPE flag
|
||||
EXPORTING
|
||||
e_month TYPE i.
|
||||
ENDCLASS. "ZCL_DATE_CALCULATION
|
||||
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS ZCL_DATE_CALCULATION IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS zcl_date_calculation IMPLEMENTATION.
|
||||
METHOD months_between_two_dates.
|
||||
DATA: date_to TYPE datum.
|
||||
DATA: BEGIN OF datum_von,
|
||||
jjjj(4) TYPE n,
|
||||
mm(2) TYPE n,
|
||||
tt(2) TYPE n,
|
||||
END OF datum_von.
|
||||
|
||||
DATA: BEGIN OF datum_bis,
|
||||
jjjj(4) TYPE n,
|
||||
mm(2) TYPE n,
|
||||
tt(2) TYPE n,
|
||||
END OF datum_bis.
|
||||
|
||||
e_month = 0.
|
||||
|
||||
CHECK NOT ( i_date_from IS INITIAL )
|
||||
AND NOT ( i_date_to IS INITIAL ).
|
||||
|
||||
date_to = i_date_to.
|
||||
IF i_incl_to = abap_true.
|
||||
date_to = date_to + 1.
|
||||
ENDIF.
|
||||
|
||||
datum_von = i_date_from.
|
||||
datum_bis = date_to.
|
||||
|
||||
e_month = ( datum_bis-jjjj - datum_von-jjjj ) * 12
|
||||
+ ( datum_bis-mm - datum_von-mm ).
|
||||
ENDMETHOD. "MONTHS_BETWEEN_TWO_DATES
|
||||
ENDCLASS. "ZCL_DATE_CALCULATION IMPLEMENTATION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS zcl_date_calculation_test DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS zcl_date_calculation_test DEFINITION FOR TESTING
|
||||
" DURATION SHORT
|
||||
" RISK LEVEL HARMLESS
|
||||
"#AU Duration Medium
|
||||
"#AU Risk_Level Harmless
|
||||
.
|
||||
PUBLIC SECTION.
|
||||
METHODS:
|
||||
months_between_two_dates FOR TESTING.
|
||||
ENDCLASS. "zcl_date_calculation_test DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS zcl_date_calculation_test IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS zcl_date_calculation_test IMPLEMENTATION.
|
||||
METHOD months_between_two_dates.
|
||||
|
||||
DATA: date_from TYPE datum VALUE '20120101',
|
||||
date_to TYPE datum VALUE '20121231'.
|
||||
DATA: month TYPE i.
|
||||
|
||||
zcl_date_calculation=>months_between_two_dates(
|
||||
EXPORTING
|
||||
i_date_from = date_from
|
||||
i_date_to = date_to
|
||||
i_incl_to = abap_true
|
||||
IMPORTING
|
||||
e_month = month
|
||||
).
|
||||
|
||||
cl_aunit_assert=>assert_equals(
|
||||
exp = 12 " Data Object with Expected Type
|
||||
act = month " Data Object with Current Value
|
||||
msg = 'Calculated date is wrong' " Message in Case of Error
|
||||
).
|
||||
|
||||
ENDMETHOD. "months_between_two_dates
|
||||
ENDCLASS. "zcl_date_calculation_test IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS zcl_helper DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS zcl_helper DEFINITION.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS:
|
||||
load_image
|
||||
IMPORTING
|
||||
filename TYPE string
|
||||
RETURNING value(r_image) TYPE xstring,
|
||||
add_calendar
|
||||
IMPORTING
|
||||
i_date_from TYPE datum
|
||||
i_date_to TYPE datum
|
||||
i_from_row TYPE zexcel_cell_row
|
||||
i_from_col TYPE zexcel_cell_column_alpha
|
||||
i_day_style TYPE zexcel_cell_style
|
||||
i_cw_style TYPE zexcel_cell_style
|
||||
CHANGING
|
||||
c_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
add_calendar_landscape
|
||||
IMPORTING
|
||||
i_date_from TYPE datum
|
||||
i_date_to TYPE datum
|
||||
i_from_row TYPE zexcel_cell_row
|
||||
i_from_col TYPE zexcel_cell_column_alpha
|
||||
i_day_style TYPE zexcel_cell_style
|
||||
i_cw_style TYPE zexcel_cell_style
|
||||
CHANGING
|
||||
c_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
add_a2x_footer
|
||||
IMPORTING
|
||||
i_from_row TYPE zexcel_cell_row
|
||||
i_from_col TYPE zexcel_cell_column_alpha
|
||||
CHANGING
|
||||
c_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
add_calender_week
|
||||
IMPORTING
|
||||
i_date TYPE datum
|
||||
i_row TYPE zexcel_cell_row
|
||||
i_col TYPE zexcel_cell_column_alpha
|
||||
i_style TYPE zexcel_cell_style
|
||||
CHANGING
|
||||
c_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
ENDCLASS. "zcl_helper DEFINITION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS zcl_helper IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS zcl_helper IMPLEMENTATION.
|
||||
METHOD load_image.
|
||||
"Load samle image
|
||||
DATA: lt_bin TYPE solix_tab,
|
||||
lv_len TYPE i.
|
||||
|
||||
CALL METHOD cl_gui_frontend_services=>gui_upload
|
||||
EXPORTING
|
||||
filename = filename
|
||||
filetype = 'BIN'
|
||||
IMPORTING
|
||||
filelength = lv_len
|
||||
CHANGING
|
||||
data_tab = lt_bin
|
||||
EXCEPTIONS
|
||||
file_open_error = 1
|
||||
file_read_error = 2
|
||||
no_batch = 3
|
||||
gui_refuse_filetransfer = 4
|
||||
invalid_type = 5
|
||||
no_authority = 6
|
||||
unknown_error = 7
|
||||
bad_data_format = 8
|
||||
header_not_allowed = 9
|
||||
separator_not_allowed = 10
|
||||
header_too_long = 11
|
||||
unknown_dp_error = 12
|
||||
access_denied = 13
|
||||
dp_out_of_memory = 14
|
||||
disk_full = 15
|
||||
dp_timeout = 16
|
||||
not_supported_by_gui = 17
|
||||
error_no_gui = 18
|
||||
OTHERS = 19.
|
||||
IF sy-subrc <> 0.
|
||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
|
||||
EXPORTING
|
||||
input_length = lv_len
|
||||
IMPORTING
|
||||
buffer = r_image
|
||||
TABLES
|
||||
binary_tab = lt_bin
|
||||
EXCEPTIONS
|
||||
failed = 1
|
||||
OTHERS = 2.
|
||||
IF sy-subrc <> 0.
|
||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
ENDIF.
|
||||
ENDMETHOD. "load_image
|
||||
METHOD add_calendar.
|
||||
DATA: day_names TYPE TABLE OF t246.
|
||||
DATA: row TYPE zexcel_cell_row,
|
||||
row_max TYPE i,
|
||||
col_int TYPE zexcel_cell_column,
|
||||
col_max TYPE i,
|
||||
from_col_int TYPE zexcel_cell_column,
|
||||
col TYPE zexcel_cell_column_alpha,
|
||||
lr_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
lr_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
DATA: lv_date TYPE datum,
|
||||
value TYPE string,
|
||||
weekday TYPE wotnr,
|
||||
weekrow TYPE wotnr VALUE 1,
|
||||
day TYPE i,
|
||||
width TYPE f,
|
||||
height TYPE f.
|
||||
DATA: hyperlink TYPE REF TO zcl_excel_hyperlink.
|
||||
|
||||
FIELD-SYMBOLS: <day_name> LIKE LINE OF day_names.
|
||||
|
||||
lv_date = i_date_from.
|
||||
from_col_int = zcl_excel_common=>convert_column2int( i_from_col ).
|
||||
" Add description for Calendar Week
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = i_from_col " Cell Column
|
||||
ip_row = i_from_row " Cell Row
|
||||
ip_value = 'CW'(001) " Cell Value
|
||||
ip_style = i_cw_style
|
||||
).
|
||||
|
||||
" Add Days
|
||||
CALL FUNCTION 'DAY_NAMES_GET'
|
||||
TABLES
|
||||
day_names = day_names.
|
||||
|
||||
LOOP AT day_names ASSIGNING <day_name>.
|
||||
row = i_from_row.
|
||||
col_int = from_col_int + <day_name>-wotnr.
|
||||
col = zcl_excel_common=>convert_column2alpha( col_int ).
|
||||
value = <day_name>-langt.
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_style = i_cw_style
|
||||
).
|
||||
ENDLOOP.
|
||||
|
||||
WHILE lv_date <= i_date_to.
|
||||
day = lv_date+6(2).
|
||||
CALL FUNCTION 'FIMA_X_DAY_IN_MONTH_COMPUTE'
|
||||
EXPORTING
|
||||
i_datum = lv_date
|
||||
IMPORTING
|
||||
e_wochentag_nr = weekday.
|
||||
|
||||
row = i_from_row + weekrow.
|
||||
col_int = from_col_int + weekday.
|
||||
col = zcl_excel_common=>convert_column2alpha( col_int ).
|
||||
|
||||
value = day.
|
||||
CONDENSE value.
|
||||
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_style = i_day_style " Single-Character Indicator
|
||||
).
|
||||
|
||||
IF weekday = 7.
|
||||
" Add Calender Week
|
||||
zcl_helper=>add_calender_week(
|
||||
EXPORTING
|
||||
i_date = lv_date
|
||||
i_row = row
|
||||
i_col = i_from_col
|
||||
i_style = i_cw_style
|
||||
CHANGING
|
||||
c_worksheet = c_worksheet
|
||||
).
|
||||
weekrow = weekrow + 1.
|
||||
ENDIF.
|
||||
lv_date = lv_date + 1.
|
||||
ENDWHILE.
|
||||
" Add Calender Week
|
||||
zcl_helper=>add_calender_week(
|
||||
EXPORTING
|
||||
i_date = lv_date
|
||||
i_row = row
|
||||
i_col = i_from_col
|
||||
i_style = i_cw_style
|
||||
CHANGING
|
||||
c_worksheet = c_worksheet
|
||||
).
|
||||
" Add Created with abap2xlsx
|
||||
row = row + 2.
|
||||
zcl_helper=>add_a2x_footer(
|
||||
EXPORTING
|
||||
i_from_row = row
|
||||
i_from_col = i_from_col
|
||||
CHANGING
|
||||
c_worksheet = c_worksheet
|
||||
).
|
||||
col_int = from_col_int.
|
||||
col_max = from_col_int + 7.
|
||||
WHILE col_int <= col_max.
|
||||
col = zcl_excel_common=>convert_column2alpha( col_int ).
|
||||
IF sy-index = 1.
|
||||
width = '5.0'.
|
||||
ELSE.
|
||||
width = '11.4'.
|
||||
ENDIF.
|
||||
lr_col_dim = c_worksheet->get_column_dimension( col ).
|
||||
lr_col_dim->set_width( width ).
|
||||
col_int = col_int + 1.
|
||||
ENDWHILE.
|
||||
row = i_from_row + 1.
|
||||
row_max = i_from_row + 6.
|
||||
WHILE row <= row_max.
|
||||
height = 50.
|
||||
lr_row_dim = c_worksheet->get_row_dimension( row ).
|
||||
lr_row_dim->set_row_height( height ).
|
||||
row = row + 1.
|
||||
ENDWHILE.
|
||||
ENDMETHOD. "add_calendar
|
||||
METHOD add_a2x_footer.
|
||||
DATA: value TYPE string,
|
||||
hyperlink TYPE REF TO zcl_excel_hyperlink.
|
||||
|
||||
value = 'Created with abap2xlsx. Find more information at http://abap2xlsx.org.'(002).
|
||||
hyperlink = zcl_excel_hyperlink=>create_external_link( 'http://abap2xlsx.org' ). "#EC NOTEXT
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = i_from_col " Cell Column
|
||||
ip_row = i_from_row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_hyperlink = hyperlink
|
||||
).
|
||||
|
||||
ENDMETHOD. "add_a2x_footer
|
||||
METHOD add_calendar_landscape.
|
||||
DATA: day_names TYPE TABLE OF t246.
|
||||
|
||||
DATA: lv_date TYPE datum,
|
||||
day TYPE i,
|
||||
value TYPE string,
|
||||
weekday TYPE wotnr.
|
||||
DATA: row TYPE zexcel_cell_row,
|
||||
from_col_int TYPE zexcel_cell_column,
|
||||
col_int TYPE zexcel_cell_column,
|
||||
col TYPE zexcel_cell_column_alpha.
|
||||
DATA: lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
lo_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
|
||||
FIELD-SYMBOLS: <day_name> LIKE LINE OF day_names.
|
||||
|
||||
lv_date = i_date_from.
|
||||
" Add Days
|
||||
CALL FUNCTION 'DAY_NAMES_GET'
|
||||
TABLES
|
||||
day_names = day_names.
|
||||
|
||||
WHILE lv_date <= i_date_to.
|
||||
day = lv_date+6(2).
|
||||
CALL FUNCTION 'FIMA_X_DAY_IN_MONTH_COMPUTE'
|
||||
EXPORTING
|
||||
i_datum = lv_date
|
||||
IMPORTING
|
||||
e_wochentag_nr = weekday.
|
||||
" Day name row
|
||||
row = i_from_row.
|
||||
col_int = from_col_int + day + 2.
|
||||
col = zcl_excel_common=>convert_column2alpha( col_int ).
|
||||
READ TABLE day_names ASSIGNING <day_name>
|
||||
WITH KEY wotnr = weekday.
|
||||
value = <day_name>-kurzt.
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_style = i_cw_style
|
||||
).
|
||||
|
||||
" Day row
|
||||
row = i_from_row + 1.
|
||||
value = day.
|
||||
CONDENSE value.
|
||||
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_style = i_day_style " Single-Character Indicator
|
||||
).
|
||||
" width
|
||||
lo_col_dim = c_worksheet->get_column_dimension( col ).
|
||||
lo_col_dim->set_width( '3.6' ).
|
||||
|
||||
|
||||
lv_date = lv_date + 1.
|
||||
ENDWHILE.
|
||||
" Add ABAP2XLSX Footer
|
||||
row = i_from_row + 2.
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = col " Cell Column
|
||||
ip_row = row " Cell Row
|
||||
ip_value = ' ' " Cell Value
|
||||
).
|
||||
lo_row_dim = c_worksheet->get_row_dimension( row ).
|
||||
lo_row_dim->set_row_height( '5.0' ).
|
||||
row = i_from_row + 3.
|
||||
zcl_helper=>add_a2x_footer(
|
||||
EXPORTING
|
||||
i_from_row = row
|
||||
i_from_col = i_from_col
|
||||
CHANGING
|
||||
c_worksheet = c_worksheet
|
||||
).
|
||||
|
||||
" Set with for all 31 coulumns
|
||||
WHILE day < 32.
|
||||
day = day + 1.
|
||||
col_int = from_col_int + day + 2.
|
||||
col = zcl_excel_common=>convert_column2alpha( col_int ).
|
||||
" width
|
||||
lo_col_dim = c_worksheet->get_column_dimension( col ).
|
||||
lo_col_dim->set_width( '3.6' ).
|
||||
ENDWHILE.
|
||||
ENDMETHOD. "ADD_CALENDAR_LANDSCAPE
|
||||
|
||||
METHOD add_calender_week.
|
||||
DATA: week TYPE kweek,
|
||||
week_int TYPE i,
|
||||
value TYPE string.
|
||||
" Add Calender Week
|
||||
CALL FUNCTION 'DATE_GET_WEEK'
|
||||
EXPORTING
|
||||
date = i_date " Date for which the week should be calculated
|
||||
IMPORTING
|
||||
week = week. " Week for date (format:YYYYWW)
|
||||
value = week+4(2).
|
||||
week_int = value.
|
||||
value = week_int.
|
||||
CONDENSE value.
|
||||
c_worksheet->set_cell(
|
||||
EXPORTING
|
||||
ip_column = i_col " Cell Column
|
||||
ip_row = i_row " Cell Row
|
||||
ip_value = value " Cell Value
|
||||
ip_style = i_style
|
||||
).
|
||||
ENDMETHOD. "add_calender_week
|
||||
ENDCLASS. "zcl_helper IMPLEMENTATION
|
22
src/zdemo_calendar_classes.prog.xml
Normal file
22
src/zdemo_calendar_classes.prog.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_CALENDAR_CLASSES</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>I</SUBC>
|
||||
<RLOAD>E</RLOAD>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Include ZDEMO_CALENDAR_CLASSES</ENTRY>
|
||||
<LENGTH>30</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
83
src/zdemo_excel.prog.abap
Normal file
83
src/zdemo_excel.prog.abap
Normal file
|
@ -0,0 +1,83 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel.
|
||||
|
||||
DATA: lv_workdir TYPE string,
|
||||
lv_upfile TYPE string.
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = sy-lisel ).
|
||||
CONCATENATE p_path sy-lisel '01_HelloWorld.xlsx' INTO lv_upfile.
|
||||
|
||||
SUBMIT zdemo_excel1 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Hello world
|
||||
SUBMIT zdemo_excel2 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Styles
|
||||
SUBMIT zdemo_excel3 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: iTab binding
|
||||
SUBMIT zdemo_excel4 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Multi sheets, page setup and sheet properties
|
||||
SUBMIT zdemo_excel5 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_excel6 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Formulas
|
||||
SUBMIT zdemo_excel7 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_excel8 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Ranges
|
||||
SUBMIT zdemo_excel9 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Data validation
|
||||
SUBMIT zdemo_excel10 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
|
||||
" zdemo_excel11 is not added because it has a selection screen and
|
||||
" you also need to have business partners maintained in transaction BP
|
||||
SUBMIT zdemo_excel12 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Column size
|
||||
SUBMIT zdemo_excel13 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Merge cell
|
||||
SUBMIT zdemo_excel14 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Alignment
|
||||
" zdemo_excel15 added at the end
|
||||
SUBMIT zdemo_excel16 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Drawing
|
||||
SUBMIT zdemo_excel17 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Lock sheet
|
||||
SUBMIT zdemo_excel18 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Lock workbook
|
||||
SUBMIT zdemo_excel19 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Set active sheet
|
||||
" zdemo_excel20 is not added because it uses ALV and cannot be processed (OLE2)
|
||||
SUBMIT zdemo_excel21 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Color Picker
|
||||
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_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
|
||||
" SUBMIT zdemo_excel29 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Macro enabled workbook
|
||||
SUBMIT zdemo_excel30 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: ABAP Cell data types + leading blanks string
|
||||
SUBMIT zdemo_excel31 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Autosize Column with different Font sizes
|
||||
" zdemo_excel32 is not added because it uses ALV and cannot be processed (Native)
|
||||
SUBMIT zdemo_excel33 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Table autofilter
|
||||
SUBMIT zdemo_excel34 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Static Styles Chess
|
||||
SUBMIT zdemo_excel35 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Static Styles
|
||||
SUBMIT zdemo_excel36 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Style applied to sheet, column and single cell
|
||||
SUBMIT zdemo_excel37 WITH p_upfile = lv_upfile
|
||||
WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Simplest call of the reader and writer - passthrough data
|
||||
SUBMIT zdemo_excel38 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT abap2xlsx Demo: Show off integration of drawings ( here using the SAP-Icons )
|
||||
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
|
||||
"
|
||||
" Reader/Writer Demo must always run at the end
|
||||
" to make sure all documents where created
|
||||
"
|
||||
SUBMIT zdemo_excel15 WITH rb_down = abap_true WITH rb_show = abap_false WITH p_path = p_path AND RETURN. "#EC CI_SUBMIT Read Excel and write it back
|
26
src/zdemo_excel.prog.xml
Normal file
26
src/zdemo_excel.prog.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>Select output path</ENTRY>
|
||||
<LENGTH>26</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
40
src/zdemo_excel1.prog.abap
Normal file
40
src/zdemo_excel1.prog.abap
Normal file
|
@ -0,0 +1,40 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL1
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel1.
|
||||
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '01_HelloWorld.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
* lo_worksheet->set_title( ip_title = 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = sy-datum ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = sy-uzeit ).
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'http://www.abap2xlsx.org' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 4 ip_value = 'Click here to visit abap2xlsx homepage' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'B' ).
|
||||
column_dimension->set_width( ip_width = 11 ).
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
37
src/zdemo_excel1.prog.xml
Normal file
37
src/zdemo_excel1.prog.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL1</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>RB_BACK</KEY>
|
||||
<LENGTH>17</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>28</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
95
src/zdemo_excel10.prog.abap
Normal file
95
src/zdemo_excel10.prog.abap
Normal file
|
@ -0,0 +1,95 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL10
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel10.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_conditional2 TYPE REF TO zcl_excel_style_conditional,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog,
|
||||
ls_table_settings TYPE zexcel_s_table_settings,
|
||||
ls_iconset TYPE zexcel_conditional_iconset.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '10_iTabFieldCatalog.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'Internal table' ).
|
||||
|
||||
ls_iconset-iconset = zcl_excel_style_conditional=>c_iconset_5arrows.
|
||||
ls_iconset-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo1_value = '0'.
|
||||
ls_iconset-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo2_value = '20'.
|
||||
ls_iconset-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo3_value = '40'.
|
||||
ls_iconset-cfvo4_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo4_value = '60'.
|
||||
ls_iconset-cfvo5_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo5_value = '80'.
|
||||
ls_iconset-showvalue = zcl_excel_style_conditional=>c_showvalue_true.
|
||||
|
||||
"Conditional style
|
||||
lo_style_conditional2 = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional2->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional2->mode_iconset = ls_iconset.
|
||||
lo_style_conditional2->priority = 1.
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
SELECT * FROM sflight INTO TABLE lt_test. "#EC CI_NOWHERE
|
||||
|
||||
lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_test ).
|
||||
|
||||
LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>.
|
||||
CASE <fs_field_catalog>-fieldname.
|
||||
WHEN 'CARRID'.
|
||||
<fs_field_catalog>-position = 3.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_count.
|
||||
WHEN 'CONNID'.
|
||||
<fs_field_catalog>-position = 4.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-abap_type = cl_abap_typedescr=>typekind_int.
|
||||
"This avoid the excel warning that the number is formatted as a text: abap2xlsx is not able to recognize numc as a number so it formats the number as a text with
|
||||
"the related warning. You can force the type and the framework will correctly format the number as a number
|
||||
WHEN 'FLDATE'.
|
||||
<fs_field_catalog>-position = 2.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'PRICE'.
|
||||
<fs_field_catalog>-position = 1.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_sum.
|
||||
<fs_field_catalog>-cond_style = lo_style_conditional2.
|
||||
WHEN OTHERS.
|
||||
<fs_field_catalog>-dynpfld = abap_false.
|
||||
ENDCASE.
|
||||
ENDLOOP.
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5.
|
||||
|
||||
lo_worksheet->bind_table( ip_table = lt_test
|
||||
is_table_settings = ls_table_settings
|
||||
it_field_catalog = lt_field_catalog ).
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'D' ). "make date field a bit wider
|
||||
column_dimension->set_width( ip_width = 13 ).
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel10.prog.xml
Normal file
32
src/zdemo_excel10.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL10</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Format internal table with field catalog</ENTRY>
|
||||
<LENGTH>57</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
414
src/zdemo_excel11.prog.abap
Normal file
414
src/zdemo_excel11.prog.abap
Normal file
|
@ -0,0 +1,414 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL11
|
||||
*& Export Organisation and Contact Persons using ABAP2XLSX
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel11.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: central_search TYPE bapibus1006_central_search,
|
||||
addressdata_search TYPE bapibus1006_addr_search,
|
||||
others_search TYPE bapibus1006_other_data.
|
||||
DATA: searchresult TYPE TABLE OF bapibus1006_bp_addr,
|
||||
return TYPE TABLE OF bapiret2.
|
||||
DATA: lines TYPE i.
|
||||
FIELD-SYMBOLS: <searchresult_line> LIKE LINE OF searchresult.
|
||||
DATA: centraldata TYPE bapibus1006_central,
|
||||
centraldataperson TYPE bapibus1006_central_person,
|
||||
centraldataorganization TYPE bapibus1006_central_organ.
|
||||
DATA: addressdata TYPE bapibus1006_address.
|
||||
DATA: relationships TYPE TABLE OF bapibus1006_relations.
|
||||
FIELD-SYMBOLS: <relationship> LIKE LINE OF relationships.
|
||||
DATA: relationship_centraldata TYPE bapibus1006002_central.
|
||||
DATA: relationship_addresses TYPE TABLE OF bapibus1006002_addresses.
|
||||
FIELD-SYMBOLS: <relationship_address> LIKE LINE OF relationship_addresses.
|
||||
|
||||
DATA: lt_download TYPE TABLE OF zexcel_s_org_rel.
|
||||
FIELD-SYMBOLS: <download> LIKE LINE OF lt_download.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '11_Export_Org_and_Contact.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
PARAMETERS: md TYPE flag RADIOBUTTON GROUP act.
|
||||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-00a.
|
||||
PARAMETERS: partnerc TYPE bu_type DEFAULT 2, " Organizations
|
||||
postlcod TYPE ad_pstcd1 DEFAULT '8334*',
|
||||
country TYPE land1 DEFAULT 'DE',
|
||||
maxsel TYPE bu_maxsel DEFAULT 100.
|
||||
SELECTION-SCREEN END OF BLOCK a.
|
||||
|
||||
PARAMETERS: rel TYPE flag RADIOBUTTON GROUP act DEFAULT 'X'.
|
||||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-00b.
|
||||
PARAMETERS: reltyp TYPE bu_reltyp DEFAULT 'BUR011',
|
||||
partner TYPE bu_partner DEFAULT '191'.
|
||||
SELECTION-SCREEN END OF BLOCK b.
|
||||
|
||||
START-OF-SELECTION.
|
||||
IF md = abap_true.
|
||||
" Read all Companies by Master Data
|
||||
central_search-partnercategory = partnerc.
|
||||
addressdata_search-postl_cod1 = postlcod.
|
||||
addressdata_search-country = country.
|
||||
others_search-maxsel = maxsel.
|
||||
others_search-no_search_for_contactperson = 'X'.
|
||||
|
||||
CALL FUNCTION 'BAPI_BUPA_SEARCH_2'
|
||||
EXPORTING
|
||||
centraldata = central_search
|
||||
addressdata = addressdata_search
|
||||
OTHERS = others_search
|
||||
TABLES
|
||||
searchresult = searchresult
|
||||
return = return.
|
||||
|
||||
SORT searchresult BY partner.
|
||||
DELETE ADJACENT DUPLICATES FROM searchresult COMPARING partner.
|
||||
ELSEIF rel = abap_true.
|
||||
" Read by Relationship
|
||||
SELECT but050~partner1 AS partner FROM but050
|
||||
INNER JOIN but000 ON but000~partner = but050~partner1 AND but000~type = '2'
|
||||
INTO CORRESPONDING FIELDS OF TABLE searchresult
|
||||
WHERE but050~partner2 = partner
|
||||
AND but050~reltyp = reltyp.
|
||||
ENDIF.
|
||||
|
||||
DESCRIBE TABLE searchresult LINES lines.
|
||||
WRITE: / 'Number of search results: ', lines.
|
||||
|
||||
LOOP AT searchresult ASSIGNING <searchresult_line>.
|
||||
" Read Details of Organization
|
||||
CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL'
|
||||
EXPORTING
|
||||
businesspartner = <searchresult_line>-partner
|
||||
IMPORTING
|
||||
centraldataorganization = centraldataorganization.
|
||||
" Read Standard Address of Organization
|
||||
CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
|
||||
EXPORTING
|
||||
businesspartner = <searchresult_line>-partner
|
||||
IMPORTING
|
||||
addressdata = addressdata.
|
||||
|
||||
" Add Organization to Download
|
||||
APPEND INITIAL LINE TO lt_download ASSIGNING <download>.
|
||||
" Fill Organization Partner Numbers
|
||||
CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS'
|
||||
EXPORTING
|
||||
businesspartner = <searchresult_line>-partner
|
||||
IMPORTING
|
||||
businesspartnerout = <download>-org_number
|
||||
businesspartnerguidout = <download>-org_guid.
|
||||
|
||||
MOVE-CORRESPONDING centraldataorganization TO <download>.
|
||||
MOVE-CORRESPONDING addressdata TO <download>.
|
||||
CLEAR: addressdata.
|
||||
|
||||
" Read all Relationships
|
||||
CLEAR: relationships.
|
||||
CALL FUNCTION 'BAPI_BUPA_RELATIONSHIPS_GET'
|
||||
EXPORTING
|
||||
businesspartner = <searchresult_line>-partner
|
||||
TABLES
|
||||
relationships = relationships.
|
||||
DELETE relationships WHERE relationshipcategory <> 'BUR001'.
|
||||
LOOP AT relationships ASSIGNING <relationship>.
|
||||
" Read details of Contact person
|
||||
CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL'
|
||||
EXPORTING
|
||||
businesspartner = <relationship>-partner2
|
||||
IMPORTING
|
||||
centraldata = centraldata
|
||||
centraldataperson = centraldataperson.
|
||||
" Read details of the Relationship
|
||||
CALL FUNCTION 'BAPI_BUPR_CONTP_GETDETAIL'
|
||||
EXPORTING
|
||||
businesspartner = <relationship>-partner1
|
||||
contactperson = <relationship>-partner2
|
||||
IMPORTING
|
||||
centraldata = relationship_centraldata.
|
||||
" Read relationship address
|
||||
CLEAR: relationship_addresses.
|
||||
|
||||
CALL FUNCTION 'BAPI_BUPR_CONTP_ADDRESSES_GET'
|
||||
EXPORTING
|
||||
businesspartner = <relationship>-partner1
|
||||
contactperson = <relationship>-partner2
|
||||
TABLES
|
||||
addresses = relationship_addresses.
|
||||
|
||||
READ TABLE relationship_addresses
|
||||
ASSIGNING <relationship_address>
|
||||
WITH KEY standardaddress = 'X'.
|
||||
|
||||
IF <relationship_address> IS ASSIGNED.
|
||||
" Read Relationship Address
|
||||
CLEAR addressdata.
|
||||
CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
|
||||
EXPORTING
|
||||
businesspartner = <searchresult_line>-partner
|
||||
addressguid = <relationship_address>-addressguid
|
||||
IMPORTING
|
||||
addressdata = addressdata.
|
||||
|
||||
APPEND INITIAL LINE TO lt_download ASSIGNING <download>.
|
||||
CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS'
|
||||
EXPORTING
|
||||
businesspartner = <relationship>-partner1
|
||||
IMPORTING
|
||||
businesspartnerout = <download>-org_number
|
||||
businesspartnerguidout = <download>-org_guid.
|
||||
|
||||
CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS'
|
||||
EXPORTING
|
||||
businesspartner = <relationship>-partner2
|
||||
IMPORTING
|
||||
businesspartnerout = <download>-contpers_number
|
||||
businesspartnerguidout = <download>-contpers_guid.
|
||||
|
||||
MOVE-CORRESPONDING centraldataorganization TO <download>.
|
||||
MOVE-CORRESPONDING addressdata TO <download>.
|
||||
MOVE-CORRESPONDING centraldataperson TO <download>.
|
||||
MOVE-CORRESPONDING relationship_centraldata TO <download>.
|
||||
|
||||
WRITE: / <relationship>-partner1, <relationship>-partner2.
|
||||
WRITE: centraldataorganization-name1(20), centraldataorganization-name2(10).
|
||||
WRITE: centraldataperson-firstname(15), centraldataperson-lastname(15).
|
||||
WRITE: addressdata-street(25), addressdata-house_no,
|
||||
addressdata-postl_cod1, addressdata-city(25).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_body TYPE REF TO zcl_excel_style,
|
||||
lo_border_dark TYPE REF TO zcl_excel_style_border,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
|
||||
DATA: lv_style_body_even_guid TYPE zexcel_cell_style,
|
||||
lv_style_body_green TYPE zexcel_cell_style.
|
||||
|
||||
DATA: row TYPE zexcel_cell_row.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog,
|
||||
ls_table_settings TYPE zexcel_s_table_settings.
|
||||
|
||||
DATA: column TYPE zexcel_cell_column,
|
||||
column_alpha TYPE zexcel_cell_column_alpha,
|
||||
value TYPE zexcel_cell_value.
|
||||
|
||||
FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create border object
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black.
|
||||
lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
"Create style with border even
|
||||
lo_style_body = lo_excel->add_new_style( ).
|
||||
lo_style_body->fill->fgcolor-rgb = zcl_excel_style_color=>c_yellow.
|
||||
lo_style_body->borders->allborders = lo_border_dark.
|
||||
lv_style_body_even_guid = lo_style_body->get_guid( ).
|
||||
"Create style with border and green fill
|
||||
lo_style_body = lo_excel->add_new_style( ).
|
||||
lo_style_body->fill->fgcolor-rgb = zcl_excel_style_color=>c_green.
|
||||
lo_style_body->borders->allborders = lo_border_dark.
|
||||
lv_style_body_green = lo_style_body->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'Internal table' ).
|
||||
|
||||
lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_download ).
|
||||
|
||||
LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>.
|
||||
CASE <fs_field_catalog>-fieldname.
|
||||
WHEN 'ORG_NUMBER'.
|
||||
<fs_field_catalog>-position = 1.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'CONTPERS_NUMBER'.
|
||||
<fs_field_catalog>-position = 2.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'NAME1'.
|
||||
<fs_field_catalog>-position = 3.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'NAME2'.
|
||||
<fs_field_catalog>-position = 4.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'STREET'.
|
||||
<fs_field_catalog>-position = 5.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'HOUSE_NO'.
|
||||
<fs_field_catalog>-position = 6.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'POSTL_COD1'.
|
||||
<fs_field_catalog>-position = 7.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'CITY'.
|
||||
<fs_field_catalog>-position = 8.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'COUNTRYISO'.
|
||||
<fs_field_catalog>-position = 9.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'FIRSTNAME'.
|
||||
<fs_field_catalog>-position = 10.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'LASTNAME'.
|
||||
<fs_field_catalog>-position = 11.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'FUNCTIONNAME'.
|
||||
<fs_field_catalog>-position = 12.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'DEPARTMENTNAME'.
|
||||
<fs_field_catalog>-position = 13.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'TEL1_NUMBR'.
|
||||
<fs_field_catalog>-position = 14.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'TEL1_EXT'.
|
||||
<fs_field_catalog>-position = 15.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'FAX_NUMBER'.
|
||||
<fs_field_catalog>-position = 16.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'FAX_EXTENS'.
|
||||
<fs_field_catalog>-position = 17.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN 'E_MAIL'.
|
||||
<fs_field_catalog>-position = 18.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
WHEN OTHERS.
|
||||
<fs_field_catalog>-dynpfld = abap_false.
|
||||
ENDCASE.
|
||||
ENDLOOP.
|
||||
|
||||
ls_table_settings-top_left_column = 'A'.
|
||||
ls_table_settings-top_left_row = '2'.
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5.
|
||||
|
||||
lo_worksheet->bind_table( ip_table = lt_download
|
||||
is_table_settings = ls_table_settings
|
||||
it_field_catalog = lt_field_catalog ).
|
||||
LOOP AT lt_download ASSIGNING <download>.
|
||||
row = sy-tabix + 2.
|
||||
IF NOT <download>-org_number IS INITIAL
|
||||
AND <download>-contpers_number IS INITIAL.
|
||||
" Mark fields of Organization which can be changed green
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'C'
|
||||
ip_row = row
|
||||
ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'D'
|
||||
ip_row = row
|
||||
ip_style = lv_style_body_green
|
||||
).
|
||||
* CATCH zcx_excel. " Exceptions for ABAP2XLSX
|
||||
ELSEIF NOT <download>-org_number IS INITIAL
|
||||
AND NOT <download>-contpers_number IS INITIAL.
|
||||
" Mark fields of Relationship which can be changed green
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'L' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'M' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'N' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'O' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'P' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'Q' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
lo_worksheet->set_cell_style(
|
||||
ip_column = 'R' ip_row = row ip_style = lv_style_body_green
|
||||
).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
" Add Fieldnames in first row and hide the row
|
||||
LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>
|
||||
WHERE position <> '' AND dynpfld = abap_true.
|
||||
column = <fs_field_catalog>-position.
|
||||
column_alpha = zcl_excel_common=>convert_column2alpha( column ).
|
||||
value = <fs_field_catalog>-fieldname.
|
||||
lo_worksheet->set_cell( ip_column = column_alpha
|
||||
ip_row = 1
|
||||
ip_value = value
|
||||
ip_style = lv_style_body_even_guid ).
|
||||
ENDLOOP.
|
||||
" Hide first row
|
||||
row_dimension = lo_worksheet->get_row_dimension( 1 ).
|
||||
row_dimension->set_visible( abap_false ).
|
||||
|
||||
DATA: highest_column TYPE zexcel_cell_column,
|
||||
count TYPE int4,
|
||||
col_alpha TYPE zexcel_cell_column_alpha.
|
||||
|
||||
highest_column = lo_worksheet->get_highest_column( ).
|
||||
count = 1.
|
||||
WHILE count <= highest_column.
|
||||
col_alpha = zcl_excel_common=>convert_column2alpha( ip_column = count ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = col_alpha ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
count = count + 1.
|
||||
ENDWHILE.
|
||||
* " Set Column width manuall
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'A' ).
|
||||
* column_dimension->set_width( ip_width = 11 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'B' ).
|
||||
* column_dimension->set_width( ip_width = 11 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'C' ).
|
||||
* column_dimension->set_width( ip_width = 35 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'E' ).
|
||||
* column_dimension->set_width( ip_width = 18 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'F' ).
|
||||
* column_dimension->set_width( ip_width = 5 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'G' ).
|
||||
* column_dimension->set_width( ip_width = 6 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'H' ).
|
||||
* column_dimension->set_width( ip_width = 12 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'I' ).
|
||||
* column_dimension->set_width( ip_width = 3 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'J' ).
|
||||
* column_dimension->set_width( ip_width = 13 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'K' ).
|
||||
* column_dimension->set_width( ip_width = 13 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'L' ).
|
||||
* column_dimension->set_width( ip_width = 13 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'M' ).
|
||||
* column_dimension->set_width( ip_width = 13 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'N' ).
|
||||
* column_dimension->set_width( ip_width = 12 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'O' ).
|
||||
* column_dimension->set_width( ip_width = 9 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'P' ).
|
||||
* column_dimension->set_width( ip_width = 12 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'Q' ).
|
||||
* column_dimension->set_width( ip_width = 9 ).
|
||||
* column_dimension = lo_worksheet->get_column_dimension( ip_column = 'R' ).
|
||||
* column_dimension->set_width( ip_width = 40 ).
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
98
src/zdemo_excel11.prog.xml
Normal file
98
src/zdemo_excel11.prog.xml
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL11</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>K</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>00A</KEY>
|
||||
<ENTRY>Select by master data</ENTRY>
|
||||
<LENGTH>132</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>00B</KEY>
|
||||
<ENTRY>Select by relationship</ENTRY>
|
||||
<LENGTH>132</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Export Organisation and Contact Persons</ENTRY>
|
||||
<LENGTH>55</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>COUNTRY</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>MAXSEL</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>MD</KEY>
|
||||
<ENTRY>Select by master data</ENTRY>
|
||||
<LENGTH>29</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>PARTNER</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>PARTNERC</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>POSTLCOD</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>21</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>REL</KEY>
|
||||
<ENTRY>Select by relationship</ENTRY>
|
||||
<LENGTH>30</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>RELTYP</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
116
src/zdemo_excel12.prog.abap
Normal file
116
src/zdemo_excel12.prog.abap
Normal file
|
@ -0,0 +1,116 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL12
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel12.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '12_HideSizeOutlineRowsAndColumns.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world in AutoSize column' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Hello world in a column width size 50' ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Hello world (hidden column)' ).
|
||||
lo_worksheet->set_cell( ip_column = 'F' ip_row = 2 ip_value = 'Outline column level 0' ).
|
||||
lo_worksheet->set_cell( ip_column = 'G' ip_row = 2 ip_value = 'Outline column level 1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'H' ip_row = 2 ip_value = 'Outline column level 2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'I' ip_row = 2 ip_value = 'Small' ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Hello world (hidden row)' ).
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = 5 ip_value = 'Hello world in a row height size 20' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Simple outline rows 10-16 ( collapsed )' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 19 ip_value = '3 Outlines - Outlinelevel 1 is collapsed' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 19 ip_value = 'One of the two inner outlines is expanded, one collapsed' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 20 ip_value = 'Inner outline level - expanded' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 24 ip_value = 'Inner outline level - lines 25-28 are collapsed' ).
|
||||
|
||||
lo_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_off. " By default is on
|
||||
lo_worksheet->zif_excel_sheet_properties~summaryright = zif_excel_sheet_properties=>c_right_off. " By default is on
|
||||
|
||||
" Column Settings
|
||||
" Auto size
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'B' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'I' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
" Manual Width
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'C' ).
|
||||
column_dimension->set_width( ip_width = 50 ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'D' ).
|
||||
column_dimension->set_visible( ip_visible = abap_false ).
|
||||
" Implementation in the Writer is not working yet ===== TODO =====
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'F' ).
|
||||
column_dimension->set_outline_level( ip_outline_level = 0 ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'G' ).
|
||||
column_dimension->set_outline_level( ip_outline_level = 1 ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'H' ).
|
||||
column_dimension->set_outline_level( ip_outline_level = 2 ).
|
||||
|
||||
row_dimension = lo_worksheet->get_row_dimension( ip_row = 1 ).
|
||||
row_dimension->set_visible( ip_visible = abap_false ).
|
||||
row_dimension = lo_worksheet->get_row_dimension( ip_row = 5 ).
|
||||
row_dimension->set_row_height( ip_row_height = 20 ).
|
||||
* obsolete, not intuitive. Use new method shown below
|
||||
* " Implementation in the Writer is not working yet ===== TODO =====
|
||||
* row_dimension = lo_worksheet->get_row_dimension( ip_row = 6 ).
|
||||
* row_dimension->set_outline_level( ip_outline_level = 0 ).
|
||||
* row_dimension = lo_worksheet->get_row_dimension( ip_row = 7 ).
|
||||
* row_dimension->set_outline_level( ip_outline_level = 1 ).
|
||||
* row_dimension = lo_worksheet->get_row_dimension( ip_row = 8 ).
|
||||
* row_dimension->set_outline_level( ip_outline_level = 2 ).
|
||||
|
||||
* Define an outline rows 10-16, collapsed on startup
|
||||
lo_worksheet->set_row_outline( iv_row_from = 10
|
||||
iv_row_to = 16
|
||||
iv_collapsed = abap_true ). " collapsed
|
||||
|
||||
* Define an inner outline rows 21-22, expanded when outer outline becomes extended
|
||||
lo_worksheet->set_row_outline( iv_row_from = 21
|
||||
iv_row_to = 22
|
||||
iv_collapsed = abap_false ). " expanded
|
||||
|
||||
* Define an inner outline rows 25-28, collapsed on startup
|
||||
lo_worksheet->set_row_outline( iv_row_from = 25
|
||||
iv_row_to = 28
|
||||
iv_collapsed = abap_true ). " collapsed
|
||||
|
||||
* Define an outer outline rows 20-30, collapsed on startup
|
||||
lo_worksheet->set_row_outline( iv_row_from = 20
|
||||
iv_row_to = 30
|
||||
iv_collapsed = abap_true ). " collapsed
|
||||
|
||||
* Hint: the order you create the outlines can be arbitrary
|
||||
* You can start with inner outlines or with outer outlines
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Hide columns right of column M
|
||||
*--------------------------------------------------------------------*
|
||||
lo_worksheet->zif_excel_sheet_properties~hide_columns_from = 'M'.
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel12.prog.xml
Normal file
32
src/zdemo_excel12.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL12</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hide Columns</ENTRY>
|
||||
<LENGTH>29</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
83
src/zdemo_excel13.prog.abap
Normal file
83
src/zdemo_excel13.prog.abap
Normal file
|
@ -0,0 +1,83 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL13
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Example by: Alvaro "Blag" Tejada Galindo.
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel13.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lv_style_bold_border_guid TYPE zexcel_cell_style,
|
||||
lo_style_bold_border TYPE REF TO zcl_excel_style,
|
||||
lo_border_dark TYPE REF TO zcl_excel_style_border.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '13_MergedCells.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'sheet1' ).
|
||||
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black.
|
||||
lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
|
||||
lo_style_bold_border = lo_excel->add_new_style( ).
|
||||
lo_style_bold_border->font->bold = abap_true.
|
||||
lo_style_bold_border->font->italic = abap_false.
|
||||
lo_style_bold_border->font->color-rgb = zcl_excel_style_color=>c_black.
|
||||
lo_style_bold_border->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_bold_border->borders->allborders = lo_border_dark.
|
||||
lv_style_bold_border_guid = lo_style_bold_border->get_guid( ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = 'Test' ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'B' ip_value = 'Banana' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'C' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'D' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'E' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'F' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'G' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'Apple' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
|
||||
lo_worksheet->set_merge( ip_row = 4 ip_column_start = 'B' ip_column_end = 'G' ).
|
||||
|
||||
" Test also if merge works when oher merged chells are empty
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 'Tomato' ).
|
||||
lo_worksheet->set_merge( ip_row = 6 ip_column_start = 'B' ip_column_end = 'G' ).
|
||||
|
||||
" Test the patch provided by Victor Alekhin to merge cells in one column
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = 'Merge cells also over multiple rows by Victor Alekhin' ).
|
||||
lo_worksheet->set_merge( ip_row = 8 ip_column_start = 'B' ip_column_end = 'G' ip_row_to = 10 ).
|
||||
|
||||
" Test the patch provided by Alexander Budeyev with different column merges
|
||||
lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = 'Merge cells with different merges by Alexander Budeyev' ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = 'Test' ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = 'Banana' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = 'Apple' ip_style = lv_style_bold_border_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = '' ip_style = lv_style_bold_border_guid ).
|
||||
|
||||
" Test merge (issue)
|
||||
lo_worksheet->set_merge( ip_row = 13 ip_column_start = 'B' ip_column_end = 'C' ip_row_to = 15 ).
|
||||
lo_worksheet->set_merge( ip_row = 13 ip_column_start = 'D' ip_column_end = 'D' ip_row_to = 14 ).
|
||||
lo_worksheet->set_merge( ip_row = 13 ip_column_start = 'E' ip_column_end = 'F' ).
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel13.prog.xml
Normal file
32
src/zdemo_excel13.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL13</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Merge cells</ENTRY>
|
||||
<LENGTH>28</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
160
src/zdemo_excel14.prog.abap
Normal file
160
src/zdemo_excel14.prog.abap
Normal file
|
@ -0,0 +1,160 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL14
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel14.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_center TYPE REF TO zcl_excel_style,
|
||||
lo_style_right TYPE REF TO zcl_excel_style,
|
||||
lo_style_left TYPE REF TO zcl_excel_style,
|
||||
lo_style_general TYPE REF TO zcl_excel_style,
|
||||
lo_style_bottom TYPE REF TO zcl_excel_style,
|
||||
lo_style_middle TYPE REF TO zcl_excel_style,
|
||||
lo_style_top TYPE REF TO zcl_excel_style,
|
||||
lo_style_justify TYPE REF TO zcl_excel_style,
|
||||
lo_style_mixed TYPE REF TO zcl_excel_style,
|
||||
lo_style_mixed_wrap TYPE REF TO zcl_excel_style,
|
||||
lo_style_rotated TYPE REF TO zcl_excel_style,
|
||||
lo_style_shrink TYPE REF TO zcl_excel_style,
|
||||
lo_style_indent TYPE REF TO zcl_excel_style,
|
||||
lv_style_center_guid TYPE zexcel_cell_style,
|
||||
lv_style_right_guid TYPE zexcel_cell_style,
|
||||
lv_style_left_guid TYPE zexcel_cell_style,
|
||||
lv_style_general_guid TYPE zexcel_cell_style,
|
||||
lv_style_bottom_guid TYPE zexcel_cell_style,
|
||||
lv_style_middle_guid TYPE zexcel_cell_style,
|
||||
lv_style_top_guid TYPE zexcel_cell_style,
|
||||
lv_style_justify_guid TYPE zexcel_cell_style,
|
||||
lv_style_mixed_guid TYPE zexcel_cell_style,
|
||||
lv_style_mixed_wrap_guid TYPE zexcel_cell_style,
|
||||
lv_style_rotated_guid TYPE zexcel_cell_style,
|
||||
lv_style_shrink_guid TYPE zexcel_cell_style,
|
||||
lv_style_indent_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lo_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '14_Alignment.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'sheet1' ).
|
||||
|
||||
"Center
|
||||
lo_style_center = lo_excel->add_new_style( ).
|
||||
lo_style_center->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lv_style_center_guid = lo_style_center->get_guid( ).
|
||||
"Right
|
||||
lo_style_right = lo_excel->add_new_style( ).
|
||||
lo_style_right->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_right.
|
||||
lv_style_right_guid = lo_style_right->get_guid( ).
|
||||
"Left
|
||||
lo_style_left = lo_excel->add_new_style( ).
|
||||
lo_style_left->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_left.
|
||||
lv_style_left_guid = lo_style_left->get_guid( ).
|
||||
"General
|
||||
lo_style_general = lo_excel->add_new_style( ).
|
||||
lo_style_general->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_general.
|
||||
lv_style_general_guid = lo_style_general->get_guid( ).
|
||||
"Bottom
|
||||
lo_style_bottom = lo_excel->add_new_style( ).
|
||||
lo_style_bottom->alignment->vertical = zcl_excel_style_alignment=>c_vertical_bottom.
|
||||
lv_style_bottom_guid = lo_style_bottom->get_guid( ).
|
||||
"Middle
|
||||
lo_style_middle = lo_excel->add_new_style( ).
|
||||
lo_style_middle->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
|
||||
lv_style_middle_guid = lo_style_middle->get_guid( ).
|
||||
"Top
|
||||
lo_style_top = lo_excel->add_new_style( ).
|
||||
lo_style_top->alignment->vertical = zcl_excel_style_alignment=>c_vertical_top.
|
||||
lv_style_top_guid = lo_style_top->get_guid( ).
|
||||
"Justify
|
||||
lo_style_justify = lo_excel->add_new_style( ).
|
||||
lo_style_justify->alignment->vertical = zcl_excel_style_alignment=>c_vertical_justify.
|
||||
lv_style_justify_guid = lo_style_justify->get_guid( ).
|
||||
|
||||
"Shrink
|
||||
lo_style_shrink = lo_excel->add_new_style( ).
|
||||
lo_style_shrink->alignment->shrinktofit = abap_true.
|
||||
lv_style_shrink_guid = lo_style_shrink->get_guid( ).
|
||||
|
||||
"Indent
|
||||
lo_style_indent = lo_excel->add_new_style( ).
|
||||
lo_style_indent->alignment->indent = 5.
|
||||
lv_style_indent_guid = lo_style_indent->get_guid( ).
|
||||
|
||||
"Middle / Centered / Wrap
|
||||
lo_style_mixed_wrap = lo_excel->add_new_style( ).
|
||||
lo_style_mixed_wrap->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_mixed_wrap->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
|
||||
lo_style_mixed_wrap->alignment->wraptext = abap_true.
|
||||
lv_style_mixed_wrap_guid = lo_style_mixed_wrap->get_guid( ).
|
||||
|
||||
"Middle / Centered / Wrap
|
||||
lo_style_mixed = lo_excel->add_new_style( ).
|
||||
lo_style_mixed->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_mixed->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
|
||||
lv_style_mixed_guid = lo_style_mixed->get_guid( ).
|
||||
|
||||
"Center
|
||||
lo_style_rotated = lo_excel->add_new_style( ).
|
||||
lo_style_rotated->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center.
|
||||
lo_style_rotated->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center.
|
||||
lo_style_rotated->alignment->textrotation = 165. " -75° == 90° + 75°
|
||||
lv_style_rotated_guid = lo_style_rotated->get_guid( ).
|
||||
|
||||
|
||||
" Set row size for first 7 rows to 40
|
||||
DO 7 TIMES.
|
||||
lo_row_dimension = lo_worksheet->get_row_dimension( sy-index ).
|
||||
lo_row_dimension->set_row_height( 40 ).
|
||||
ENDDO.
|
||||
|
||||
"Horizontal alignment
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'Centered Text' ip_style = lv_style_center_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 'Right Text' ip_style = lv_style_right_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 'Left Text' ip_style = lv_style_left_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 'General Text' ip_style = lv_style_general_guid ).
|
||||
|
||||
" Shrink & indent
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'Text shrinked' ip_style = lv_style_shrink_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = 'Text indented' ip_style = lv_style_indent_guid ).
|
||||
|
||||
"Vertical alignment
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'Bottom Text' ip_style = lv_style_bottom_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 'Middle Text' ip_style = lv_style_middle_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 'Top Text' ip_style = lv_style_top_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = 'Justify Text' ip_style = lv_style_justify_guid ).
|
||||
|
||||
" Wrapped
|
||||
lo_worksheet->set_cell( ip_row = 10 ip_column = 'B'
|
||||
ip_value = 'This is a wrapped text centered in the middle'
|
||||
ip_style = lv_style_mixed_wrap_guid ).
|
||||
|
||||
" Rotated
|
||||
lo_worksheet->set_cell( ip_row = 10 ip_column = 'D'
|
||||
ip_value = 'This is a centered text rotated by -75°'
|
||||
ip_style = lv_style_rotated_guid ).
|
||||
|
||||
" forced line break
|
||||
DATA: lv_value TYPE string.
|
||||
CONCATENATE 'This is a wrapped text centered in the middle' cl_abap_char_utilities=>cr_lf
|
||||
'and a manuall line break.' INTO lv_value.
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'B'
|
||||
ip_value = lv_value
|
||||
ip_style = lv_style_mixed_guid ).
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel14.prog.xml
Normal file
32
src/zdemo_excel14.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL14</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Alignment</ENTRY>
|
||||
<LENGTH>26</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
146
src/zdemo_excel15.prog.abap
Normal file
146
src/zdemo_excel15.prog.abap
Normal file
|
@ -0,0 +1,146 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL15
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*& 2010-10-30, Gregor Wolf:
|
||||
*& Added the functionality to ouput the read table content
|
||||
*& 2011-12-19, Shahrin Shahrulzaman:
|
||||
*& Added the functionality to have multiple input and output files
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel15.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF t_demo_excel15,
|
||||
input TYPE string,
|
||||
END OF t_demo_excel15.
|
||||
|
||||
DATA: excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
reader TYPE REF TO zif_excel_reader.
|
||||
|
||||
DATA: ex TYPE REF TO zcx_excel,
|
||||
msg TYPE string.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_workdir TYPE string,
|
||||
output_file_path TYPE string,
|
||||
input_file_path TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
DATA: worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
highest_column TYPE zexcel_cell_column,
|
||||
highest_row TYPE int4,
|
||||
column TYPE zexcel_cell_column VALUE 1,
|
||||
col_str TYPE zexcel_cell_column_alpha,
|
||||
row TYPE int4 VALUE 1,
|
||||
value TYPE zexcel_cell_value.
|
||||
|
||||
DATA:
|
||||
lt_files TYPE TABLE OF t_demo_excel15.
|
||||
FIELD-SYMBOLS: <wa_files> TYPE t_demo_excel15.
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir,
|
||||
p_noout TYPE xfeld DEFAULT abap_true.
|
||||
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '01_HelloWorld.xlsx'.
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '02_Styles.xlsx'.
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '03_iTab.xlsx'.
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '04_Sheets.xlsx'.
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '08_Range.xlsx'.
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '13_MergedCells.xlsx'.
|
||||
APPEND INITIAL LINE TO lt_files ASSIGNING <wa_files>.
|
||||
<wa_files>-input = '31_AutosizeWithDifferentFontSizes.xlsx'.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
|
||||
LOOP AT lt_files ASSIGNING <wa_files>.
|
||||
CONCATENATE p_path lv_file_separator <wa_files>-input INTO input_file_path.
|
||||
CONCATENATE p_path lv_file_separator '15_' <wa_files>-input INTO output_file_path.
|
||||
REPLACE '.xlsx' IN output_file_path WITH 'FromReader.xlsx'.
|
||||
|
||||
TRY.
|
||||
CREATE OBJECT reader TYPE zcl_excel_reader_2007.
|
||||
excel = reader->load_file( input_file_path ).
|
||||
|
||||
IF p_noout EQ abap_false.
|
||||
worksheet = excel->get_active_worksheet( ).
|
||||
highest_column = worksheet->get_highest_column( ).
|
||||
highest_row = worksheet->get_highest_row( ).
|
||||
|
||||
WRITE: 'Highest column: ', highest_column, 'Highest row: ', highest_row.
|
||||
WRITE: /.
|
||||
|
||||
WHILE row <= highest_row.
|
||||
WHILE column <= highest_column.
|
||||
col_str = zcl_excel_common=>convert_column2alpha( column ).
|
||||
worksheet->get_cell(
|
||||
EXPORTING
|
||||
ip_column = col_str
|
||||
ip_row = row
|
||||
IMPORTING
|
||||
ep_value = value
|
||||
).
|
||||
WRITE: value.
|
||||
column = column + 1.
|
||||
ENDWHILE.
|
||||
WRITE: /.
|
||||
column = 1.
|
||||
row = row + 1.
|
||||
ENDWHILE.
|
||||
ENDIF.
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( excel ).
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
* " This method is only available on AS ABAP > 6.40
|
||||
* lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
* lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = output_file_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
||||
|
||||
|
||||
CATCH zcx_excel INTO ex. " Exceptions for ABAP2XLSX
|
||||
msg = ex->get_text( ).
|
||||
WRITE: / msg.
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
38
src/zdemo_excel15.prog.xml
Normal file
38
src/zdemo_excel15.prog.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL15</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Reader</ENTRY>
|
||||
<LENGTH>22</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_NOOUT</KEY>
|
||||
<ENTRY>Hide output</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
136
src/zdemo_excel16.prog.abap
Normal file
136
src/zdemo_excel16.prog.abap
Normal file
|
@ -0,0 +1,136 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL16
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel16.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing.
|
||||
|
||||
|
||||
DATA: ls_io TYPE skwf_io.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '16_Drawings.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
PARAMETERS: p_objid TYPE sdok_docid DEFAULT '456694429165174BE10000000A1550C0', " Question mark in standard Web Dynpro WDT_QUIZ
|
||||
p_class TYPE sdok_class DEFAULT 'M_IMAGE_P',
|
||||
pobjtype TYPE skwf_ioty DEFAULT 'P'.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
"Load samle image
|
||||
DATA: lt_bin TYPE solix_tab,
|
||||
lv_len TYPE i,
|
||||
lv_content TYPE xstring,
|
||||
ls_key TYPE wwwdatatab.
|
||||
|
||||
CALL METHOD cl_gui_frontend_services=>gui_upload
|
||||
EXPORTING
|
||||
filename = 'c:\Program Files\SAP\FrontEnd\SAPgui\wwi\graphics\W_bio.bmp'
|
||||
filetype = 'BIN'
|
||||
IMPORTING
|
||||
filelength = lv_len
|
||||
CHANGING
|
||||
data_tab = lt_bin
|
||||
EXCEPTIONS
|
||||
file_open_error = 1
|
||||
file_read_error = 2
|
||||
no_batch = 3
|
||||
gui_refuse_filetransfer = 4
|
||||
invalid_type = 5
|
||||
no_authority = 6
|
||||
unknown_error = 7
|
||||
bad_data_format = 8
|
||||
header_not_allowed = 9
|
||||
separator_not_allowed = 10
|
||||
header_too_long = 11
|
||||
unknown_dp_error = 12
|
||||
access_denied = 13
|
||||
dp_out_of_memory = 14
|
||||
disk_full = 15
|
||||
dp_timeout = 16
|
||||
not_supported_by_gui = 17
|
||||
error_no_gui = 18
|
||||
OTHERS = 19.
|
||||
IF sy-subrc <> 0.
|
||||
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
|
||||
EXPORTING
|
||||
input_length = lv_len
|
||||
IMPORTING
|
||||
buffer = lv_content
|
||||
TABLES
|
||||
binary_tab = lt_bin
|
||||
EXCEPTIONS
|
||||
failed = 1
|
||||
OTHERS = 2.
|
||||
IF sy-subrc <> 0.
|
||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
ENDIF.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Image from web repository (SMW0)' ).
|
||||
|
||||
" create global drawing, set position and media from web repository
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 3
|
||||
ip_from_col = 'B' ).
|
||||
|
||||
ls_key-relid = 'MI'.
|
||||
ls_key-objid = 'SAPLOGO.GIF'.
|
||||
lo_drawing->set_media_www( ip_key = ls_key
|
||||
ip_width = 166
|
||||
ip_height = 75 ).
|
||||
|
||||
" assign drawing to the worksheet
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" another drawing from a XSTRING read from a file
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 8 ip_value = 'Image from a file (c:\Program Files\SAP\FrontEnd\SAPgui\wwi\graphics\W_bio.bmp)' ).
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 9
|
||||
ip_from_col = 'B' ).
|
||||
lo_drawing->set_media( ip_media = lv_content
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_bmp
|
||||
ip_width = 83
|
||||
ip_height = 160 ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
ls_io-objid = p_objid.
|
||||
ls_io-class = p_class.
|
||||
ls_io-objtype = pobjtype.
|
||||
IF ls_io IS NOT INITIAL.
|
||||
" another drawing from a XSTRING read from a file
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 18 ip_value = 'Mime repository (by default Question mark in standard Web Dynpro WDT_QUIZ)' ).
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 19
|
||||
ip_from_col = 'B' ).
|
||||
lo_drawing->set_media_mime( ip_io = ls_io
|
||||
ip_width = 126
|
||||
ip_height = 145 ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
ENDIF.
|
||||
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
53
src/zdemo_excel16.prog.xml
Normal file
53
src/zdemo_excel16.prog.xml
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL16</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Drawings</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>POBJTYPE</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_CLASS</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_OBJID</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
56
src/zdemo_excel17.prog.abap
Normal file
56
src/zdemo_excel17.prog.abap
Normal file
|
@ -0,0 +1,56 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL17
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel17.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_protection TYPE REF TO zcl_excel_style,
|
||||
lv_style_protection_guid TYPE zexcel_cell_style,
|
||||
lo_style TYPE REF TO zcl_excel_style,
|
||||
lv_style TYPE zexcel_cell_style.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '17_SheetProtection.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
PARAMETERS: p_pwd TYPE zexcel_aes_password LOWER CASE DEFAULT 'secret'.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_protected.
|
||||
* lo_worksheet->zif_excel_sheet_protection~password = 'DAA7'. "it is the encoded word "secret"
|
||||
lo_worksheet->zif_excel_sheet_protection~password = zcl_excel_common=>encrypt_password( p_pwd ).
|
||||
lo_worksheet->zif_excel_sheet_protection~sheet = zif_excel_sheet_protection=>c_active.
|
||||
lo_worksheet->zif_excel_sheet_protection~objects = zif_excel_sheet_protection=>c_active.
|
||||
lo_worksheet->zif_excel_sheet_protection~scenarios = zif_excel_sheet_protection=>c_active.
|
||||
" First style to unlock a cell
|
||||
lo_style_protection = lo_excel->add_new_style( ).
|
||||
lo_style_protection->protection->locked = zcl_excel_style_protection=>c_protection_unlocked.
|
||||
lv_style_protection_guid = lo_style_protection->get_guid( ).
|
||||
" Another style which should not affect the unlock style
|
||||
lo_style = lo_excel->add_new_style( ).
|
||||
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style->fill->fgcolor-rgb = 'FFCC3333'.
|
||||
lv_style = lo_style->get_guid( ).
|
||||
lo_worksheet->set_cell( ip_row = 3 ip_column = 'C' ip_value = 'This cell is locked locked and has the second formating' ip_style = lv_style ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'This cell is unlocked' ip_style = lv_style_protection_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'This cell is locked as all the others empty cell' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'This cell is unlocked' ip_style = lv_style_protection_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'This cell is unlocked' ip_style = lv_style_protection_guid ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'This cell is locked as all the others empty cell' ).
|
||||
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
39
src/zdemo_excel17.prog.xml
Normal file
39
src/zdemo_excel17.prog.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL17</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Sheet Protection</ENTRY>
|
||||
<LENGTH>33</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PWD</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
37
src/zdemo_excel18.prog.abap
Normal file
37
src/zdemo_excel18.prog.abap
Normal file
|
@ -0,0 +1,37 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL18
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel18.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lv_style_protection_guid TYPE zexcel_cell_style.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '18_BookProtection.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_excel->zif_excel_book_protection~protected = zif_excel_book_protection=>c_protected.
|
||||
lo_excel->zif_excel_book_protection~lockrevision = zif_excel_book_protection=>c_locked.
|
||||
lo_excel->zif_excel_book_protection~lockstructure = zif_excel_book_protection=>c_locked.
|
||||
lo_excel->zif_excel_book_protection~lockwindows = zif_excel_book_protection=>c_locked.
|
||||
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'This cell is unlocked' ip_style = lv_style_protection_guid ).
|
||||
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel18.prog.xml
Normal file
32
src/zdemo_excel18.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL18</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Book protection</ENTRY>
|
||||
<LENGTH>32</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
56
src/zdemo_excel19.prog.abap
Normal file
56
src/zdemo_excel19.prog.abap
Normal file
|
@ -0,0 +1,56 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL19
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel19.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '19_SetActiveSheet.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
PARAMETERS: p_noout TYPE xfeld DEFAULT abap_true.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" First Worksheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'First' ).
|
||||
lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = 'This is Sheet 1' ).
|
||||
|
||||
" Second Worksheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( 'Second' ).
|
||||
lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = 'This is Sheet 2' ).
|
||||
|
||||
" Third Worksheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( 'Third' ).
|
||||
lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = 'This is Sheet 3' ).
|
||||
|
||||
IF p_noout EQ abap_false.
|
||||
" lo_excel->set_active_sheet_index_by_name( data_sheet_name ).
|
||||
DATA: active_sheet_index TYPE zexcel_active_worksheet.
|
||||
active_sheet_index = lo_excel->get_active_sheet_index( ).
|
||||
WRITE: 'Sheet Index before: ', active_sheet_index.
|
||||
ENDIF.
|
||||
lo_excel->set_active_sheet_index( '2' ).
|
||||
IF p_noout EQ abap_false.
|
||||
active_sheet_index = lo_excel->get_active_sheet_index( ).
|
||||
WRITE: 'Sheet Index after: ', active_sheet_index.
|
||||
ENDIF.
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
57
src/zdemo_excel19.prog.xml
Normal file
57
src/zdemo_excel19.prog.xml
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL19</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Set active sheet</ENTRY>
|
||||
<LENGTH>33</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_NOOUT</KEY>
|
||||
<ENTRY>Hide output</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>26</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
<I18N_TPOOL>
|
||||
<item>
|
||||
<LANGUAGE>D</LANGUAGE>
|
||||
<TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_NOOUT</KEY>
|
||||
<ENTRY> Hide output</ENTRY>
|
||||
<LENGTH>19</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>D .</ENTRY>
|
||||
<LENGTH>26</LENGTH>
|
||||
</TEXTPOOL>
|
||||
</TEXTPOOL>
|
||||
</item>
|
||||
</I18N_TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
330
src/zdemo_excel2.prog.abap
Normal file
330
src/zdemo_excel2.prog.abap
Normal file
|
@ -0,0 +1,330 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL2
|
||||
*& Test Styles for ABAP2XLSX
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel2.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_bold TYPE REF TO zcl_excel_style,
|
||||
lo_style_underline TYPE REF TO zcl_excel_style,
|
||||
lo_style_filled TYPE REF TO zcl_excel_style,
|
||||
lo_style_border TYPE REF TO zcl_excel_style,
|
||||
lo_style_button TYPE REF TO zcl_excel_style,
|
||||
lo_border_dark TYPE REF TO zcl_excel_style_border,
|
||||
lo_border_light TYPE REF TO zcl_excel_style_border.
|
||||
|
||||
DATA: lv_style_bold_guid TYPE zexcel_cell_style,
|
||||
lv_style_underline_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_green_guid TYPE zexcel_cell_style,
|
||||
lv_style_border_guid TYPE zexcel_cell_style,
|
||||
lv_style_button_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_turquoise_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerlb_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerlt_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerrb_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerrt_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_horizontal90_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_horizontal270_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_horizontalb_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_vertical_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_vertical2_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_fromcenter_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal45_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal45b_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal135_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal135b_guid TYPE zexcel_cell_style .
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
DATA: lo_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '02_Styles.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create border object
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black.
|
||||
lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
CREATE OBJECT lo_border_light.
|
||||
lo_border_light->border_color-rgb = zcl_excel_style_color=>c_gray.
|
||||
lo_border_light->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
" Create a bold / italic style
|
||||
lo_style_bold = lo_excel->add_new_style( ).
|
||||
lo_style_bold->font->bold = abap_true.
|
||||
lo_style_bold->font->italic = abap_true.
|
||||
lo_style_bold->font->name = zcl_excel_style_font=>c_name_arial.
|
||||
lo_style_bold->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_bold->font->color-rgb = zcl_excel_style_color=>c_red.
|
||||
lv_style_bold_guid = lo_style_bold->get_guid( ).
|
||||
" Create an underline double style
|
||||
lo_style_underline = lo_excel->add_new_style( ).
|
||||
lo_style_underline->font->underline = abap_true.
|
||||
lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double.
|
||||
lo_style_underline->font->name = zcl_excel_style_font=>c_name_roman.
|
||||
lo_style_underline->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_underline->font->family = zcl_excel_style_font=>c_family_roman.
|
||||
lv_style_underline_guid = lo_style_underline->get_guid( ).
|
||||
" Create filled style yellow
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-theme = zcl_excel_style_color=>c_theme_accent6.
|
||||
lv_style_filled_guid = lo_style_filled->get_guid( ).
|
||||
" Create border with button effects
|
||||
lo_style_button = lo_excel->add_new_style( ).
|
||||
lo_style_button->borders->right = lo_border_dark.
|
||||
lo_style_button->borders->down = lo_border_dark.
|
||||
lo_style_button->borders->left = lo_border_light.
|
||||
lo_style_button->borders->top = lo_border_light.
|
||||
lv_style_button_guid = lo_style_button->get_guid( ).
|
||||
"Create style with border
|
||||
lo_style_border = lo_excel->add_new_style( ).
|
||||
lo_style_border->borders->allborders = lo_border_dark.
|
||||
lo_style_border->borders->diagonal = lo_border_dark.
|
||||
lo_style_border->borders->diagonal_mode = zcl_excel_style_borders=>c_diagonal_both.
|
||||
lv_style_border_guid = lo_style_border->get_guid( ).
|
||||
" Create filled style green
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_green.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_filled_green_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Create filled with gradients
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerlb.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerlb_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerlt.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerlt_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerrb.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerrb_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerrt.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerrt_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontal90.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_horizontal90_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontal270.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_horizontal270_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontalb.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_horizontalb_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_vertical.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_vertical_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_vertical.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_vertical2_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_fromcenter.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_fromcenter_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal45_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45b.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal45b_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal135_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135b.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal135b_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
|
||||
" Create filled style turquoise using legacy excel ver <= 2003 palette. (https://code.sdn.sap.com/spaces/abap2xlsx/tickets/92)
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_excel->legacy_palette->set_color( "replace built-in color from palette with out custom RGB turquoise
|
||||
ip_index = 16
|
||||
ip_color = '0040E0D0' ).
|
||||
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-indexed = 16.
|
||||
lv_style_filled_turquoise_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Styles' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Modified color for Excel 2003' ip_style = lv_style_filled_turquoise_guid ).
|
||||
" Fill the cell and apply one style
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
" Change the style
|
||||
lo_worksheet->set_cell_style( ip_column = 'B' ip_row = 6 ip_style = lv_style_filled_green_guid ).
|
||||
" Add Style to an empty cell to test Fix for Issue
|
||||
"#44 Exception ZCX_EXCEL thrown when style is set for an empty cell
|
||||
" https://code.sdn.sap.com/spaces/abap2xlsx/tickets/44-exception-zcx_excel-thrown-when-style-is-set-for-an-empty-cell
|
||||
lo_worksheet->set_cell_style( ip_column = 'E' ip_row = 6 ip_style = lv_style_filled_green_guid ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 10 ip_style = lv_style_gr_cornerlb_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerlb ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 10 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 11 ip_style = lv_style_gr_cornerlt_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerlt ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 11 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 12 ip_style = lv_style_gr_cornerrb_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerrb ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 12 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 13 ip_style = lv_style_gr_cornerrt_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerrt ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 13 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 14 ip_style = lv_style_gr_horizontal90_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontal90 ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 14 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 15 ip_style = lv_style_gr_horizontal270_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontal270 ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 15 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 16 ip_style = lv_style_gr_horizontalb_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontalb ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 16 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 17 ip_style = lv_style_gr_vertical_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_vertical ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 17 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 18 ip_style = lv_style_gr_vertical2_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_vertical ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 18 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 19 ip_style = lv_style_gr_fromcenter_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_fromcenter ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 19 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 20 ip_style = lv_style_gr_diagonal45_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal45 ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 20 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 21 ip_style = lv_style_gr_diagonal45b_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal45b ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 21 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 22 ip_style = lv_style_gr_diagonal135_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal135 ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 22 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 23 ip_style = lv_style_gr_diagonal135b_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal135b ).
|
||||
lo_row_dim = lo_worksheet->get_row_dimension( ip_row = 23 ).
|
||||
lo_row_dim->set_row_height( ip_row_height = 30 ).
|
||||
|
||||
|
||||
|
||||
* CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
* lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
*
|
||||
* " Convert to binary
|
||||
* CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
* EXPORTING
|
||||
* buffer = lv_file
|
||||
* IMPORTING
|
||||
* output_length = lv_bytecount
|
||||
* TABLES
|
||||
* binary_tab = lt_file_tab.
|
||||
** " This method is only available on AS ABAP > 6.40
|
||||
** lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
** lv_bytecount = xstrlen( lv_file ).
|
||||
*
|
||||
* " Save the file
|
||||
* cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
* filename = lv_full_path
|
||||
* filetype = 'BIN'
|
||||
* CHANGING data_tab = lt_file_tab ).
|
||||
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel2.prog.xml
Normal file
32
src/zdemo_excel2.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL2</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Styles</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
123
src/zdemo_excel21.prog.abap
Normal file
123
src/zdemo_excel21.prog.abap
Normal file
|
@ -0,0 +1,123 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL21
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel21.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF t_color_style,
|
||||
color TYPE zexcel_style_color_argb,
|
||||
style TYPE zexcel_cell_style,
|
||||
END OF t_color_style.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_filled TYPE REF TO zcl_excel_style.
|
||||
|
||||
DATA: color_styles TYPE TABLE OF t_color_style.
|
||||
|
||||
FIELD-SYMBOLS: <color_style> LIKE LINE OF color_styles.
|
||||
|
||||
CONSTANTS: max TYPE i VALUE 255,
|
||||
step TYPE i VALUE 51.
|
||||
|
||||
DATA: red TYPE i,
|
||||
green TYPE i,
|
||||
blue TYPE i,
|
||||
red_hex(1) TYPE x,
|
||||
green_hex(1) TYPE x,
|
||||
blue_hex(1) TYPE x,
|
||||
red_str TYPE string,
|
||||
green_str TYPE string,
|
||||
blue_str TYPE string.
|
||||
|
||||
DATA: color TYPE zexcel_style_color_argb,
|
||||
tint TYPE zexcel_style_color_tint.
|
||||
|
||||
DATA: row TYPE i,
|
||||
row_tmp TYPE i,
|
||||
column TYPE zexcel_cell_column VALUE 1,
|
||||
col_str TYPE zexcel_cell_column_alpha.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '21_BackgroundColorPicker.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
WHILE red <= max.
|
||||
green = 0.
|
||||
WHILE green <= max.
|
||||
blue = 0.
|
||||
WHILE blue <= max.
|
||||
red_hex = red.
|
||||
red_str = red_hex.
|
||||
green_hex = green.
|
||||
green_str = green_hex.
|
||||
blue_hex = blue.
|
||||
blue_str = blue_hex.
|
||||
" Create filled
|
||||
CONCATENATE 'FF' red_str green_str blue_str INTO color.
|
||||
APPEND INITIAL LINE TO color_styles ASSIGNING <color_style>.
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-rgb = color.
|
||||
<color_style>-color = color.
|
||||
<color_style>-style = lo_style_filled->get_guid( ).
|
||||
blue = blue + step.
|
||||
ENDWHILE.
|
||||
green = green + step.
|
||||
ENDWHILE.
|
||||
red = red + step.
|
||||
ENDWHILE.
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'Color Picker' ).
|
||||
LOOP AT color_styles ASSIGNING <color_style>.
|
||||
row_tmp = ( max / step + 1 ) * 3.
|
||||
IF row = row_tmp.
|
||||
row = 0.
|
||||
column = column + 1.
|
||||
ENDIF.
|
||||
row = row + 1.
|
||||
col_str = zcl_excel_common=>convert_column2alpha( column ).
|
||||
|
||||
" Fill the cell and apply one style
|
||||
lo_worksheet->set_cell( ip_column = col_str
|
||||
ip_row = row
|
||||
ip_value = <color_style>-color
|
||||
ip_style = <color_style>-style ).
|
||||
ENDLOOP.
|
||||
|
||||
row = row + 2.
|
||||
tint = '-0.5'.
|
||||
DO 10 TIMES.
|
||||
column = 1.
|
||||
DO 10 TIMES.
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-theme = sy-index - 1.
|
||||
lo_style_filled->fill->fgcolor-tint = tint.
|
||||
<color_style>-style = lo_style_filled->get_guid( ).
|
||||
col_str = zcl_excel_common=>convert_column2alpha( column ).
|
||||
lo_worksheet->set_cell_style( ip_column = col_str
|
||||
ip_row = row
|
||||
ip_style = <color_style>-style ).
|
||||
|
||||
ADD 1 TO column.
|
||||
ENDDO.
|
||||
ADD '0.1' TO tint.
|
||||
ADD 1 TO row.
|
||||
ENDDO.
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
31
src/zdemo_excel21.prog.xml
Normal file
31
src/zdemo_excel21.prog.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL21</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<LENGTH>38</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
126
src/zdemo_excel22.prog.abap
Normal file
126
src/zdemo_excel22.prog.abap
Normal file
|
@ -0,0 +1,126 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL22
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel22.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style TYPE REF TO zcl_excel_style,
|
||||
lo_style_date TYPE REF TO zcl_excel_style,
|
||||
lo_style_editable TYPE REF TO zcl_excel_style,
|
||||
lo_data_validation TYPE REF TO zcl_excel_data_validation.
|
||||
|
||||
DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog,
|
||||
ls_table_settings TYPE zexcel_s_table_settings,
|
||||
ls_table_settings_out TYPE zexcel_s_table_settings.
|
||||
|
||||
DATA: lv_style_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_row TYPE char10.
|
||||
|
||||
FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '22_itab_fieldcatalog.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'PN_MASSIVE').
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
SELECT * FROM sflight INTO TABLE lt_test. "#EC CI_NOWHERE
|
||||
|
||||
" sheet style (white background)
|
||||
lo_style = lo_excel->add_new_style( ).
|
||||
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style->fill->fgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lv_style_guid = lo_style->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->zif_excel_sheet_properties~set_style( lv_style_guid ).
|
||||
lo_worksheet->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_protected.
|
||||
lo_worksheet->zif_excel_sheet_protection~password = zcl_excel_common=>encrypt_password( 'test' ).
|
||||
lo_worksheet->zif_excel_sheet_protection~sheet = zif_excel_sheet_protection=>c_active.
|
||||
lo_worksheet->zif_excel_sheet_protection~objects = zif_excel_sheet_protection=>c_active.
|
||||
lo_worksheet->zif_excel_sheet_protection~scenarios = zif_excel_sheet_protection=>c_active.
|
||||
|
||||
" Create cell style for display only fields
|
||||
lo_style = lo_excel->add_new_style( ).
|
||||
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style->fill->fgcolor-rgb = zcl_excel_style_color=>c_gray.
|
||||
lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_text.
|
||||
|
||||
" Create cell style for display only date field
|
||||
lo_style_date = lo_excel->add_new_style( ).
|
||||
lo_style_date->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_date->fill->fgcolor-rgb = zcl_excel_style_color=>c_gray.
|
||||
lo_style_date->number_format->format_code = zcl_excel_style_number_format=>c_format_date_ddmmyyyy.
|
||||
|
||||
" Create cell style for editable fields
|
||||
lo_style_editable = lo_excel->add_new_style( ).
|
||||
lo_style_editable->protection->locked = zcl_excel_style_protection=>c_protection_unlocked.
|
||||
|
||||
lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_test ).
|
||||
|
||||
LOOP AT lt_field_catalog ASSIGNING <fs_field_catalog>.
|
||||
CASE <fs_field_catalog>-fieldname.
|
||||
WHEN 'CARRID'.
|
||||
<fs_field_catalog>-position = 3.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-style = lo_style->get_guid( ).
|
||||
WHEN 'CONNID'.
|
||||
<fs_field_catalog>-position = 1.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-style = lo_style->get_guid( ).
|
||||
WHEN 'FLDATE'.
|
||||
<fs_field_catalog>-position = 2.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-style = lo_style_date->get_guid( ).
|
||||
WHEN 'PRICE'.
|
||||
<fs_field_catalog>-position = 4.
|
||||
<fs_field_catalog>-dynpfld = abap_true.
|
||||
<fs_field_catalog>-style = lo_style_editable->get_guid( ).
|
||||
<fs_field_catalog>-totals_function = zcl_excel_table=>totals_function_sum.
|
||||
WHEN OTHERS.
|
||||
<fs_field_catalog>-dynpfld = abap_false.
|
||||
ENDCASE.
|
||||
ENDLOOP.
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2.
|
||||
ls_table_settings-show_row_stripes = abap_true.
|
||||
|
||||
lo_worksheet->bind_table( EXPORTING
|
||||
ip_table = lt_test
|
||||
it_field_catalog = lt_field_catalog
|
||||
is_table_settings = ls_table_settings
|
||||
IMPORTING
|
||||
es_table_settings = ls_table_settings_out ).
|
||||
|
||||
lo_worksheet->freeze_panes( ip_num_rows = 3 ). "freeze column headers when scrolling
|
||||
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_custom.
|
||||
lv_row = ls_table_settings_out-top_left_row.
|
||||
CONDENSE lv_row.
|
||||
CONCATENATE 'ISNUMBER(' ls_table_settings_out-top_left_column lv_row ')' INTO lo_data_validation->formula1.
|
||||
lo_data_validation->cell_row = ls_table_settings_out-top_left_row.
|
||||
lo_data_validation->cell_column = ls_table_settings_out-top_left_column.
|
||||
lo_data_validation->cell_row_to = ls_table_settings_out-bottom_right_row.
|
||||
lo_data_validation->cell_column_to = ls_table_settings_out-bottom_right_column.
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel22.prog.xml
Normal file
32
src/zdemo_excel22.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL22</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Export internal table</ENTRY>
|
||||
<LENGTH>38</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
91
src/zdemo_excel23.prog.abap
Normal file
91
src/zdemo_excel23.prog.abap
Normal file
|
@ -0,0 +1,91 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL23
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel23.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '23_Sheets_with_and_without_grid_lines.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet with grid lines and print centered horizontal & vertical' ).
|
||||
lo_worksheet->set_show_gridlines( i_show_gridlines = abap_true ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet2!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'This is a link to the second sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
lo_worksheet->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_protected.
|
||||
lo_worksheet->zif_excel_sheet_properties~zoomscale = 150.
|
||||
lo_worksheet->ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_NORMAL = 150.
|
||||
|
||||
lo_worksheet->sheet_setup->vertical_centered = abap_true.
|
||||
lo_worksheet->sheet_setup->horizontal_centered = abap_true.
|
||||
|
||||
" Second sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet with grid lines in display and print' ).
|
||||
lo_worksheet->set_show_gridlines( i_show_gridlines = abap_true ).
|
||||
lo_worksheet->set_print_gridlines( i_print_gridlines = abap_true ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet3!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'This is link to the third sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
lo_worksheet->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_protected.
|
||||
lo_worksheet->zif_excel_sheet_properties~zoomscale = 160.
|
||||
lo_worksheet->ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_PAGELAYOUTVIEW = 200.
|
||||
|
||||
" Third sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet3' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the third sheet without grid lines in display and print' ).
|
||||
lo_worksheet->set_show_gridlines( i_show_gridlines = abap_false ).
|
||||
lo_worksheet->set_print_gridlines( i_print_gridlines = abap_false ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet4!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'This is link to the fourth sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
lo_worksheet->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_protected.
|
||||
lo_worksheet->zif_excel_sheet_properties~zoomscale = 170.
|
||||
lo_worksheet->ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_SHEETLAYOUTVIEW = 150.
|
||||
|
||||
" Fourth sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet4' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the fourth sheet with grid lines and print centered ONLY horizontal' ).
|
||||
lo_worksheet->set_show_gridlines( i_show_gridlines = abap_true ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet1!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'This is link to the first sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
lo_worksheet->zif_excel_sheet_protection~protected = zif_excel_sheet_protection=>c_protected.
|
||||
lo_worksheet->zif_excel_sheet_properties~zoomscale = 150.
|
||||
lo_worksheet->ZIF_EXCEL_SHEET_PROPERTIES~ZOOMSCALE_NORMAL = 150.
|
||||
|
||||
" lo_worksheet->sheet_setup->vertical_centered = abap_true.
|
||||
lo_worksheet->sheet_setup->horizontal_centered = abap_true.
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
25
src/zdemo_excel23.prog.xml
Normal file
25
src/zdemo_excel23.prog.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL23</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Multiple sheets with and w/o grid lines, print options</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
111
src/zdemo_excel24.prog.abap
Normal file
111
src/zdemo_excel24.prog.abap
Normal file
|
@ -0,0 +1,111 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL23
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel24.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
DATA: lv_value TYPE string.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '24_Sheets_with_different_default_date_formats.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Default Date Format' ).
|
||||
" Insert current date
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = 'Current Date:' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 4 ip_value = sy-datum ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet2!A1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 6 ip_value = 'This is a link to the second sheet' ip_hyperlink = lo_hyperlink ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'A' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
|
||||
|
||||
" Second sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_default_excel_date_format( zcl_excel_style_number_format=>c_format_date_yyyymmdd ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Date Format set to YYYYMMDD' ).
|
||||
" Insert current date
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = 'Current Date:' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 4 ip_value = sy-datum ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet3!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 6 ip_value = 'This is link to the third sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
" Third sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
" TODO: It seems that the zcl_excel_style_number_format=>c_format_date_yyyymmddslash
|
||||
" does not produce a valid output
|
||||
lo_worksheet->set_default_excel_date_format( zcl_excel_style_number_format=>c_format_date_yyyymmddslash ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet3' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Date Format set to YYYY/MM/DD' ).
|
||||
" Insert current date
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = 'Current Date:' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 4 ip_value = sy-datum ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet4!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 6 ip_value = 'This is link to the 4th sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
" 4th sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
" Illustrate the Problem caused by:
|
||||
" Excel 2000 incorrectly assumes that the year 1900 is a leap year.
|
||||
" http://support.microsoft.com/kb/214326/en-us
|
||||
lo_worksheet->set_title( ip_title = 'Sheet4' ).
|
||||
" Loop from Start Date to the Max Date current data in daily steps
|
||||
CONSTANTS: lv_max type d VALUE '19000302'.
|
||||
|
||||
DATA: lv_date TYPE d VALUE '19000226',
|
||||
lv_row TYPE i.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'Formated date' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Integer value for this date' ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 3 ip_value = 'Date as string' ).
|
||||
|
||||
lv_row = 4.
|
||||
WHILE lv_date < lv_max.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = lv_row ip_value = lv_date ).
|
||||
lv_value = zcl_excel_common=>date_to_excel_string( lv_date ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = lv_row ip_value = lv_value ).
|
||||
lv_value = lv_date.
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = lv_row ip_value = lv_value ).
|
||||
lv_date = lv_date + 1.
|
||||
lv_row = lv_row + 1.
|
||||
ENDWHILE.
|
||||
|
||||
lv_row = lv_row + 1.
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet1!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = lv_row ip_value = 'This is link to the first sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
lo_excel->set_active_sheet_index_by_name( 'Sheet1' ).
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
25
src/zdemo_excel24.prog.xml
Normal file
25
src/zdemo_excel24.prog.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL24</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Multiple sheets with different default date formats</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
46
src/zdemo_excel25.prog.abap
Normal file
46
src/zdemo_excel25.prog.abap
Normal file
|
@ -0,0 +1,46 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL25
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel25.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_exception TYPE REF TO cx_root.
|
||||
|
||||
DATA: lv_file TYPE xstring.
|
||||
|
||||
CONSTANTS: lv_file_name TYPE string VALUE '25_HelloWorld.xlsx'.
|
||||
DATA: lv_default_file_name TYPE string.
|
||||
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
|
||||
IMPORTING
|
||||
file_name_with_path = lv_default_file_name. " File name with path
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
TRY.
|
||||
OPEN DATASET lv_default_file_name FOR OUTPUT IN BINARY MODE.
|
||||
TRANSFER lv_file TO lv_default_file_name.
|
||||
CLOSE DATASET lv_default_file_name.
|
||||
CATCH cx_root INTO lo_exception.
|
||||
lv_error = lo_exception->get_text( ).
|
||||
MESSAGE lv_error TYPE 'I'.
|
||||
ENDTRY.
|
32
src/zdemo_excel25.prog.xml
Normal file
32
src/zdemo_excel25.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL25</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Write Hello World using Logical Path on the App Server</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
103
src/zdemo_excel27.prog.abap
Normal file
103
src/zdemo_excel27.prog.abap
Normal file
|
@ -0,0 +1,103 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL27
|
||||
*& Test Styles for ABAP2XLSX
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel27.
|
||||
|
||||
CONSTANTS: c_fish TYPE string VALUE 'Fish'.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_range TYPE REF TO zcl_excel_range,
|
||||
lo_data_validation TYPE REF TO zcl_excel_data_validation,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
|
||||
lo_style_1 TYPE REF TO zcl_excel_style,
|
||||
lo_style_2 TYPE REF TO zcl_excel_style,
|
||||
lv_style_1_guid TYPE zexcel_cell_style,
|
||||
lv_style_2_guid TYPE zexcel_cell_style,
|
||||
ls_cellis TYPE zexcel_conditional_cellis.
|
||||
|
||||
|
||||
DATA: lv_title TYPE zexcel_sheet_title.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '27_ConditionalFormatting.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
lo_style_1 = lo_excel->add_new_style( ).
|
||||
lo_style_1->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_1->fill->bgcolor-rgb = zcl_excel_style_color=>c_green.
|
||||
lv_style_1_guid = lo_style_1->get_guid( ).
|
||||
|
||||
lo_style_2 = lo_excel->add_new_style( ).
|
||||
lo_style_2->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_2->fill->bgcolor-rgb = zcl_excel_style_color=>c_red.
|
||||
lv_style_2_guid = lo_style_2->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lv_title = 'Data Validation'.
|
||||
lo_worksheet->set_title( lv_title ).
|
||||
" Set values for dropdown
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = c_fish ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Anchovy' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'A' ip_value = 'Carp' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'A' ip_value = 'Catfish' ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'A' ip_value = 'Cod' ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'A' ip_value = 'Eel' ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'A' ip_value = 'Haddock' ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = c_fish.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'A'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'A'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
" 1st validation
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = c_fish.
|
||||
lo_data_validation->cell_row = 2.
|
||||
lo_data_validation->cell_column = 'C'.
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'C' ip_value = 'Select a value' ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_cellis.
|
||||
ls_cellis-formula = '"Anchovy"'.
|
||||
ls_cellis-operator = zcl_excel_style_conditional=>c_operator_equal.
|
||||
ls_cellis-cell_style = lv_style_1_guid.
|
||||
lo_style_conditional->mode_cellis = ls_cellis.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 2
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 2 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_cellis.
|
||||
ls_cellis-formula = '"Carp"'.
|
||||
ls_cellis-operator = zcl_excel_style_conditional=>c_operator_equal.
|
||||
ls_cellis-cell_style = lv_style_2_guid.
|
||||
lo_style_conditional->mode_cellis = ls_cellis.
|
||||
lo_style_conditional->priority = 2.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 2
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 2 ).
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
38
src/zdemo_excel27.prog.xml
Normal file
38
src/zdemo_excel27.prog.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL27</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Data conditional formatting with styles</ENTRY>
|
||||
<LENGTH>56</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_READER</KEY>
|
||||
<ENTRY>Write back after using Reader</ENTRY>
|
||||
<LENGTH>37</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
116
src/zdemo_excel28.prog.abap
Normal file
116
src/zdemo_excel28.prog.abap
Normal file
|
@ -0,0 +1,116 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL28
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel28.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_file_name TYPE string,
|
||||
lv_file_path TYPE string,
|
||||
lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '28_HelloWorld.csv'.
|
||||
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet1' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = sy-datum ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = sy-uzeit ).
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'B' ).
|
||||
column_dimension->set_width( 11 ).
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_csv.
|
||||
zcl_excel_writer_csv=>set_delimiter( ip_value = cl_abap_char_utilities=>horizontal_tab ).
|
||||
zcl_excel_writer_csv=>set_enclosure( ip_value = '''' ).
|
||||
zcl_excel_writer_csv=>set_endofline( ip_value = cl_abap_char_utilities=>cr_lf ).
|
||||
|
||||
zcl_excel_writer_csv=>set_active_sheet_index( i_active_worksheet = 2 ).
|
||||
* zcl_excel_writer_csv=>set_active_sheet_index_by_name( I_WORKSHEET_NAME = 'Sheet2' ).
|
||||
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
* " This method is only available on AS ABAP > 6.40
|
||||
* lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
* lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
REPLACE FIRST OCCURRENCE OF '.csv' IN lv_full_path WITH '_Sheet2.csv'.
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
||||
|
||||
* zcl_excel_writer_csv=>set_active_sheet_index( i_active_worksheet = 2 ).
|
||||
zcl_excel_writer_csv=>set_active_sheet_index_by_name( I_WORKSHEET_NAME = 'Sheet1' ).
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
REPLACE FIRST OCCURRENCE OF '_Sheet2.csv' IN lv_full_path WITH '_Sheet1.csv'.
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
* " This method is only available on AS ABAP > 6.40
|
||||
* lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
* lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
25
src/zdemo_excel28.prog.xml
Normal file
25
src/zdemo_excel28.prog.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL28</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: export in CSV</ENTRY>
|
||||
<LENGTH>29</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
80
src/zdemo_excel29.prog.abap
Normal file
80
src/zdemo_excel29.prog.abap
Normal file
|
@ -0,0 +1,80 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL26
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel29.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_excel_reader TYPE REF TO zif_excel_reader.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_filename TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir OBLIGATORY.
|
||||
|
||||
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'
|
||||
default_extension = '*.xlsm'
|
||||
file_filter = 'Excel Macro-Enabled Workbook (*.xlsm)|*.xlsm'
|
||||
initial_directory = lv_workdir
|
||||
CHANGING
|
||||
file_table = lt_filetable
|
||||
rc = lv_rc
|
||||
EXCEPTIONS
|
||||
file_open_dialog_failed = 1
|
||||
cntl_error = 2
|
||||
error_no_gui = 3
|
||||
not_supported_by_gui = 4
|
||||
OTHERS = 5.
|
||||
IF sy-subrc <> 0.
|
||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
ENDIF.
|
||||
READ TABLE lt_filetable INTO lv_filename INDEX 1.
|
||||
p_path = lv_filename.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
lv_full_path = p_path.
|
||||
|
||||
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 ).
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
REPLACE '.xlsm' IN lv_full_path WITH 'FromReader.xlsm'.
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
31
src/zdemo_excel29.prog.xml
Normal file
31
src/zdemo_excel29.prog.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL29</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Marco-Enabled workbook</ENTRY>
|
||||
<LENGTH>38</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>Macro-enabled Workbook</ENTRY>
|
||||
<LENGTH>30</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
89
src/zdemo_excel3.prog.abap
Normal file
89
src/zdemo_excel3.prog.abap
Normal file
|
@ -0,0 +1,89 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL3
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel3.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
DATA: ls_table_settings TYPE zexcel_s_table_settings.
|
||||
|
||||
|
||||
DATA: lv_title TYPE zexcel_sheet_title,
|
||||
lt_carr TYPE TABLE OF scarr,
|
||||
row TYPE zexcel_cell_row VALUE 2,
|
||||
lo_range TYPE REF TO zcl_excel_range.
|
||||
DATA: lo_data_validation TYPE REF TO zcl_excel_data_validation.
|
||||
FIELD-SYMBOLS: <carr> LIKE LINE OF lt_carr.
|
||||
|
||||
CONSTANTS: c_airlines TYPE string VALUE 'Airlines'.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '03_iTab.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
PARAMETERS: p_empty TYPE flag.
|
||||
|
||||
START-OF-SELECTION.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Internal table').
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
|
||||
IF p_empty <> abap_true.
|
||||
SELECT * FROM sflight INTO TABLE lt_test. "#EC CI_NOWHERE
|
||||
ENDIF.
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2.
|
||||
ls_table_settings-show_row_stripes = abap_true.
|
||||
ls_table_settings-nofilters = abap_true.
|
||||
|
||||
lo_worksheet->bind_table( ip_table = lt_test
|
||||
is_table_settings = ls_table_settings ).
|
||||
|
||||
lo_worksheet->freeze_panes( ip_num_rows = 3 ). "freeze column headers when scrolling
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'E' ). "make date field a bit wider
|
||||
column_dimension->set_width( ip_width = 11 ).
|
||||
" Add another table for data validations
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lv_title = 'Data Validation'.
|
||||
lo_worksheet->set_title( lv_title ).
|
||||
lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = c_airlines ).
|
||||
SELECT * FROM scarr INTO TABLE lt_carr. "#EC CI_NOWHERE
|
||||
LOOP AT lt_carr ASSIGNING <carr>.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'A' ip_value = <carr>-carrid ).
|
||||
row = row + 1.
|
||||
ENDLOOP.
|
||||
row = row - 1.
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = c_airlines.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'A'
|
||||
ip_start_row = 2
|
||||
ip_stop_column = 'A'
|
||||
ip_stop_row = row ).
|
||||
" Set Data Validation
|
||||
lo_excel->set_active_sheet_index( 1 ).
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = c_airlines.
|
||||
lo_data_validation->cell_row = 4.
|
||||
lo_data_validation->cell_column = 'C'.
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
38
src/zdemo_excel3.prog.xml
Normal file
38
src/zdemo_excel3.prog.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL3</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Export internal table</ENTRY>
|
||||
<LENGTH>38</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_EMPTY</KEY>
|
||||
<ENTRY>Leave Table Empty</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
99
src/zdemo_excel30.prog.abap
Normal file
99
src/zdemo_excel30.prog.abap
Normal file
|
@ -0,0 +1,99 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL1
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel30.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
|
||||
DATA: lv_value TYPE string,
|
||||
lv_count TYPE i VALUE 10,
|
||||
lv_packed TYPE p LENGTH 16 DECIMALS 1 VALUE '1234567890.5'.
|
||||
|
||||
CONSTANTS: lc_typekind_string TYPE abap_typekind VALUE cl_abap_typedescr=>typekind_string,
|
||||
lc_typekind_packed TYPE abap_typekind VALUE cl_abap_typedescr=>typekind_packed,
|
||||
lc_typekind_num TYPE abap_typekind VALUE cl_abap_typedescr=>typekind_num,
|
||||
lc_typekind_date TYPE abap_typekind VALUE cl_abap_typedescr=>typekind_date,
|
||||
lc_typekind_s_ls TYPE string VALUE 's_leading_blanks'.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '30_CellDataTypes.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Cell data types' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'Number as String'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 2 ip_value = '11'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 1 ip_value = 'String'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = ' String with leading spaces'
|
||||
ip_data_type = lc_typekind_s_ls ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = ' Negative Value'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 1 ip_value = 'Packed'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 2 ip_value = '50000.01-'
|
||||
ip_abap_type = lc_typekind_packed ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 1 ip_value = 'Number with Percentage'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 2 ip_value = '0 %'
|
||||
ip_abap_type = lc_typekind_num ).
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = 1 ip_value = 'Date'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = 2 ip_value = '20110831'
|
||||
ip_abap_type = lc_typekind_date ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'Positive Value'
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = '5000.02'
|
||||
ip_abap_type = lc_typekind_packed ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 3 ip_value = '50 %'
|
||||
ip_abap_type = lc_typekind_num ).
|
||||
|
||||
WHILE lv_count <= 15.
|
||||
lv_value = lv_count.
|
||||
CONCATENATE 'Positive Value with' lv_value 'Digits' INTO lv_value SEPARATED BY space.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = lv_count ip_value = lv_value
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = lv_count ip_value = lv_packed
|
||||
ip_abap_type = lc_typekind_packed ).
|
||||
CONCATENATE 'Positive Value with' lv_value 'Digits formated as string' INTO lv_value SEPARATED BY space.
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = lv_count ip_value = lv_value
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = lv_count ip_value = lv_packed
|
||||
ip_abap_type = lc_typekind_string ).
|
||||
lv_packed = lv_packed * 10.
|
||||
lv_count = lv_count + 1.
|
||||
ENDWHILE.
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'A' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'B' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'C' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'D' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'E' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel30.prog.xml
Normal file
32
src/zdemo_excel30.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL30</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: ABAP Cell data types</ENTRY>
|
||||
<LENGTH>37</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
157
src/zdemo_excel31.prog.abap
Normal file
157
src/zdemo_excel31.prog.abap
Normal file
|
@ -0,0 +1,157 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL1
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel31.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
|
||||
DATA: fieldval TYPE text80,
|
||||
row TYPE i,
|
||||
style_column_a TYPE REF TO zcl_excel_style,
|
||||
style_column_a_guid TYPE zexcel_cell_style,
|
||||
style_column_b TYPE REF TO zcl_excel_style,
|
||||
style_column_b_guid TYPE zexcel_cell_style,
|
||||
style_column_c TYPE REF TO zcl_excel_style,
|
||||
style_column_c_guid TYPE zexcel_cell_style,
|
||||
style_font TYPE REF TO zcl_excel_style_font.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '31_AutosizeWithDifferentFontSizes.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
" Use active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Regular Font' ).
|
||||
|
||||
style_column_a = lo_excel->add_new_style( ).
|
||||
style_column_a->font->size = 32. " quite large
|
||||
style_column_a_guid = style_column_a->get_guid( ).
|
||||
|
||||
style_column_c = lo_excel->add_new_style( ).
|
||||
style_column_c->font->size = 16. " not so large
|
||||
style_column_c_guid = style_column_c->get_guid( ).
|
||||
|
||||
|
||||
DO 20 TIMES.
|
||||
row = sy-index.
|
||||
CLEAR fieldval.
|
||||
DO sy-index TIMES.
|
||||
CONCATENATE fieldval 'X' INTO fieldval.
|
||||
ENDDO.
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = row ip_value = fieldval ip_style = style_column_a_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = row ip_value = fieldval ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = row ip_value = fieldval ip_style = style_column_c_guid ).
|
||||
ENDDO.
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'A' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'B' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'C' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
|
||||
" Add sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Bold Font' ).
|
||||
|
||||
style_column_a = lo_excel->add_new_style( ).
|
||||
style_column_a->font->size = 32. " quite large
|
||||
style_column_a->font->bold = abap_true.
|
||||
style_column_a_guid = style_column_a->get_guid( ).
|
||||
|
||||
style_column_b = lo_excel->add_new_style( ).
|
||||
style_column_b->font->bold = abap_true.
|
||||
style_column_b_guid = style_column_b->get_guid( ).
|
||||
|
||||
style_column_c = lo_excel->add_new_style( ).
|
||||
style_column_c->font->size = 16. " not so large
|
||||
style_column_c->font->bold = abap_true.
|
||||
style_column_c_guid = style_column_c->get_guid( ).
|
||||
|
||||
DO 20 TIMES.
|
||||
row = sy-index.
|
||||
CLEAR fieldval.
|
||||
DO sy-index TIMES.
|
||||
CONCATENATE fieldval 'X' INTO fieldval.
|
||||
ENDDO.
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = row ip_value = fieldval ip_style = style_column_a_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = row ip_value = fieldval ip_style = style_column_b_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = row ip_value = fieldval ip_style = style_column_c_guid ).
|
||||
ENDDO.
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'A' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'B' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'C' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
|
||||
" Add sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Italic Font' ).
|
||||
|
||||
style_column_a = lo_excel->add_new_style( ).
|
||||
style_column_a->font->size = 32. " quite large
|
||||
style_column_a->font->italic = abap_true.
|
||||
style_column_a_guid = style_column_a->get_guid( ).
|
||||
|
||||
style_column_b = lo_excel->add_new_style( ).
|
||||
style_column_b->font->italic = abap_true.
|
||||
style_column_b_guid = style_column_b->get_guid( ).
|
||||
|
||||
style_column_c = lo_excel->add_new_style( ).
|
||||
style_column_c->font->size = 16. " not so large
|
||||
style_column_c->font->italic = abap_true.
|
||||
style_column_c_guid = style_column_c->get_guid( ).
|
||||
|
||||
DO 20 TIMES.
|
||||
row = sy-index.
|
||||
CLEAR fieldval.
|
||||
DO sy-index TIMES.
|
||||
CONCATENATE fieldval 'X' INTO fieldval.
|
||||
ENDDO.
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = row ip_value = fieldval ip_style = style_column_a_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = row ip_value = fieldval ip_style = style_column_b_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = row ip_value = fieldval ip_style = style_column_c_guid ).
|
||||
ENDDO.
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'A' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'B' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'C' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
|
||||
" Add sheet for merged cells
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Merged cells' ).
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = 'This is a very long header text' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 2 ip_value = 'Some data' ).
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = 'Some more data' ).
|
||||
|
||||
lo_worksheet->set_merge(
|
||||
EXPORTING
|
||||
ip_column_start = 'A'
|
||||
ip_column_end = 'C'
|
||||
ip_row = 1 ).
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'A' ).
|
||||
column_dimension->set_auto_size( ip_auto_size = abap_true ).
|
||||
|
||||
lo_excel->set_active_sheet_index( i_active_worksheet = 1 ).
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel31.prog.xml
Normal file
32
src/zdemo_excel31.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL31</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Autosize Column with different Font sizes</ENTRY>
|
||||
<LENGTH>58</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
69
src/zdemo_excel33.prog.abap
Normal file
69
src/zdemo_excel33.prog.abap
Normal file
|
@ -0,0 +1,69 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL3
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel33.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_converter TYPE REF TO zcl_excel_converter,
|
||||
lo_autofilter TYPE REF TO zcl_excel_autofilter.
|
||||
|
||||
DATA lt_test TYPE TABLE OF t005t.
|
||||
|
||||
DATA: l_cell_value TYPE zexcel_cell_value,
|
||||
ls_area TYPE zexcel_s_autofilter_area.
|
||||
|
||||
CONSTANTS: c_airlines TYPE string VALUE 'Airlines'.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '33_autofilter.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Internal table').
|
||||
|
||||
SELECT * UP TO 2 ROWS FROM t005t INTO TABLE lt_test. "#EC CI_NOWHERE
|
||||
|
||||
CREATE OBJECT lo_converter.
|
||||
|
||||
lo_converter->convert( EXPORTING
|
||||
it_table = lt_test
|
||||
i_row_int = 1
|
||||
i_column_int = 1
|
||||
io_worksheet = lo_worksheet
|
||||
CHANGING
|
||||
co_excel = lo_excel ) .
|
||||
|
||||
lo_autofilter = lo_excel->add_new_autofilter( io_sheet = lo_worksheet ) .
|
||||
|
||||
ls_area-row_start = 1.
|
||||
ls_area-col_start = 1.
|
||||
ls_area-row_end = lo_worksheet->get_highest_row( ).
|
||||
ls_area-col_end = lo_worksheet->get_highest_column( ).
|
||||
|
||||
lo_autofilter->set_filter_area( is_area = ls_area ).
|
||||
|
||||
lo_worksheet->get_cell( EXPORTING
|
||||
ip_column = 'C'
|
||||
ip_row = 2
|
||||
IMPORTING
|
||||
ep_value = l_cell_value ).
|
||||
lo_autofilter->set_value( i_column = 3
|
||||
i_value = l_cell_value ).
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
38
src/zdemo_excel33.prog.xml
Normal file
38
src/zdemo_excel33.prog.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL33</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Autofilter</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_EMPTY</KEY>
|
||||
<ENTRY>Leave Table Empty</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
217
src/zdemo_excel34.prog.abap
Normal file
217
src/zdemo_excel34.prog.abap
Normal file
|
@ -0,0 +1,217 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL2
|
||||
*& Test Styles for ABAP2XLSX
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel34.
|
||||
|
||||
CONSTANTS: width TYPE f VALUE '10.14'.
|
||||
CONSTANTS: height TYPE f VALUE '57.75'.
|
||||
|
||||
DATA: current_row TYPE i,
|
||||
col TYPE i,
|
||||
col_alpha TYPE zexcel_cell_column_alpha,
|
||||
row TYPE i,
|
||||
row_board TYPE i,
|
||||
colorflag TYPE i,
|
||||
color TYPE zexcel_style_color_argb,
|
||||
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi,
|
||||
|
||||
writing1 TYPE string,
|
||||
writing2 TYPE string.
|
||||
|
||||
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '34_Static Styles_Chess.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Spassky_vs_Bronstein' ).
|
||||
|
||||
* Header
|
||||
current_row = 1.
|
||||
|
||||
ADD 1 TO current_row.
|
||||
lo_worksheet->set_cell( ip_row = current_row ip_column = 'B' ip_value = 'White' ).
|
||||
lo_worksheet->set_cell( ip_row = current_row ip_column = 'C' ip_value = 'Spassky, Boris V -- wins in turn 23' ).
|
||||
|
||||
ADD 1 TO current_row.
|
||||
lo_worksheet->set_cell( ip_row = current_row ip_column = 'B' ip_value = 'Black' ).
|
||||
lo_worksheet->set_cell( ip_row = current_row ip_column = 'C' ip_value = 'Bronstein, David I' ).
|
||||
|
||||
ADD 1 TO current_row.
|
||||
* Set size of column + Writing above chessboard
|
||||
DO 8 TIMES.
|
||||
|
||||
writing1 = zcl_excel_common=>convert_column2alpha( sy-index ).
|
||||
writing2 = sy-index .
|
||||
row = current_row + sy-index.
|
||||
|
||||
col = sy-index + 1.
|
||||
col_alpha = zcl_excel_common=>convert_column2alpha( col ).
|
||||
|
||||
* Set size of column
|
||||
column_dimension = lo_worksheet->get_column_dimension( col_alpha ).
|
||||
column_dimension->set_width( width ).
|
||||
|
||||
* Set size of row
|
||||
row_dimension = lo_worksheet->get_row_dimension( row ).
|
||||
row_dimension->set_row_height( height ).
|
||||
|
||||
* Set writing on chessboard
|
||||
lo_worksheet->set_cell( ip_row = row
|
||||
ip_column = 'A'
|
||||
ip_value = writing2 ).
|
||||
lo_worksheet->change_cell_style( ip_column = 'A'
|
||||
ip_row = row
|
||||
ip_alignment_vertical = zcl_excel_style_alignment=>c_vertical_center ).
|
||||
lo_worksheet->set_cell( ip_row = row
|
||||
ip_column = 'J'
|
||||
ip_value = writing2 ).
|
||||
lo_worksheet->change_cell_style( ip_column = 'J'
|
||||
ip_row = row
|
||||
ip_alignment_vertical = zcl_excel_style_alignment=>c_vertical_center ).
|
||||
|
||||
row = current_row + 9.
|
||||
lo_worksheet->set_cell( ip_row = current_row
|
||||
ip_column = col_alpha
|
||||
ip_value = writing1 ).
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = current_row
|
||||
ip_alignment_horizontal = zcl_excel_style_alignment=>c_horizontal_center ).
|
||||
lo_worksheet->set_cell( ip_row = row
|
||||
ip_column = col_alpha
|
||||
ip_value = writing1 ).
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_alignment_horizontal = zcl_excel_style_alignment=>c_horizontal_center ).
|
||||
ENDDO.
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'A' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'J' ).
|
||||
column_dimension->set_auto_size( abap_true ).
|
||||
|
||||
* Set win-position
|
||||
CONSTANTS: c_pawn TYPE string VALUE 'Pawn'.
|
||||
CONSTANTS: c_rook TYPE string VALUE 'Rook'.
|
||||
CONSTANTS: c_knight TYPE string VALUE 'Knight'.
|
||||
CONSTANTS: c_bishop TYPE string VALUE 'Bishop'.
|
||||
CONSTANTS: c_queen TYPE string VALUE 'Queen'.
|
||||
CONSTANTS: c_king TYPE string VALUE 'King'.
|
||||
|
||||
row = current_row + 1.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'B' ip_value = c_rook ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'F' ip_value = c_rook ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'G' ip_value = c_knight ).
|
||||
row = current_row + 2.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'B' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'C' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'D' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'F' ip_value = c_queen ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'H' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'I' ip_value = c_king ).
|
||||
row = current_row + 3.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'I' ip_value = c_pawn ).
|
||||
row = current_row + 4.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'D' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'F' ip_value = c_knight ).
|
||||
row = current_row + 5.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'E' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'F' ip_value = c_queen ).
|
||||
row = current_row + 6.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'C' ip_value = c_bishop ).
|
||||
row = current_row + 7.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'B' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'C' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'H' ip_value = c_pawn ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'I' ip_value = c_pawn ).
|
||||
row = current_row + 8.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'G' ip_value = c_rook ).
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'H' ip_value = c_king ).
|
||||
|
||||
* Set Chessboard
|
||||
DO 8 TIMES.
|
||||
IF sy-index <= 3. " Black
|
||||
color = zcl_excel_style_color=>c_black.
|
||||
ELSE.
|
||||
color = zcl_excel_style_color=>c_white.
|
||||
ENDIF.
|
||||
row_board = sy-index.
|
||||
row = current_row + sy-index.
|
||||
DO 8 TIMES.
|
||||
col = sy-index + 1.
|
||||
col_alpha = zcl_excel_common=>convert_column2alpha( col ).
|
||||
TRY.
|
||||
* Borders around outer limits
|
||||
IF row_board = 1.
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_borders_top_style = zcl_excel_style_border=>c_border_thick
|
||||
ip_borders_top_color_rgb = zcl_excel_style_color=>c_black ).
|
||||
ENDIF.
|
||||
IF row_board = 8.
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_borders_down_style = zcl_excel_style_border=>c_border_thick
|
||||
ip_borders_down_color_rgb = zcl_excel_style_color=>c_black ).
|
||||
ENDIF.
|
||||
IF col = 2.
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_borders_left_style = zcl_excel_style_border=>c_border_thick
|
||||
ip_borders_left_color_rgb = zcl_excel_style_color=>c_black ).
|
||||
ENDIF.
|
||||
IF col = 9.
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_borders_right_style = zcl_excel_style_border=>c_border_thick
|
||||
ip_borders_right_color_rgb = zcl_excel_style_color=>c_black ).
|
||||
ENDIF.
|
||||
* Style for writing
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_font_color_rgb = color
|
||||
ip_font_bold = 'X'
|
||||
ip_font_size = 16
|
||||
ip_alignment_horizontal = zcl_excel_style_alignment=>c_horizontal_center
|
||||
ip_alignment_vertical = zcl_excel_style_alignment=>c_vertical_center
|
||||
ip_fill_filltype = zcl_excel_style_fill=>c_fill_solid ).
|
||||
* Color of field
|
||||
colorflag = ( row + col ) MOD 2.
|
||||
IF colorflag = 0.
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_fill_fgcolor_rgb = 'FFB5866A'
|
||||
ip_fill_filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135 ).
|
||||
ELSE.
|
||||
lo_worksheet->change_cell_style( ip_column = col_alpha
|
||||
ip_row = row
|
||||
ip_fill_fgcolor_rgb = 'FFF5DEBF'
|
||||
ip_fill_filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45 ).
|
||||
ENDIF.
|
||||
|
||||
|
||||
|
||||
CATCH zcx_excel .
|
||||
ENDTRY.
|
||||
|
||||
ENDDO.
|
||||
ENDDO.
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel34.prog.xml
Normal file
32
src/zdemo_excel34.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL34</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Static Styles (Chess)</ENTRY>
|
||||
<LENGTH>37</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
176
src/zdemo_excel35.prog.abap
Normal file
176
src/zdemo_excel35.prog.abap
Normal file
|
@ -0,0 +1,176 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL2
|
||||
*& Test Styles for ABAP2XLSX
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel35.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_bold TYPE REF TO zcl_excel_style,
|
||||
lo_style_underline TYPE REF TO zcl_excel_style,
|
||||
lo_style_filled TYPE REF TO zcl_excel_style,
|
||||
lo_style_border TYPE REF TO zcl_excel_style,
|
||||
lo_style_button TYPE REF TO zcl_excel_style,
|
||||
lo_border_dark TYPE REF TO zcl_excel_style_border,
|
||||
lo_border_light TYPE REF TO zcl_excel_style_border.
|
||||
|
||||
DATA: lv_style_bold_guid TYPE zexcel_cell_style,
|
||||
lv_style_underline_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_green_guid TYPE zexcel_cell_style,
|
||||
lv_style_border_guid TYPE zexcel_cell_style,
|
||||
lv_style_button_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_turquoise_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '35_Static_Styles.xlsx'.
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>GET_DESKTOP_DIRECTORY( CHANGING DESKTOP_DIRECTORY = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
sy-title = 'ZDEMO_EXCEL2;Issue 139: Change cellstyle retroactivly'.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create border object
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black.
|
||||
lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
CREATE OBJECT lo_border_light.
|
||||
lo_border_light->border_color-rgb = zcl_excel_style_color=>c_gray.
|
||||
lo_border_light->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
" Create a bold / italic style
|
||||
lo_style_bold = lo_excel->add_new_style( ).
|
||||
lo_style_bold->font->bold = abap_true.
|
||||
lo_style_bold->font->italic = abap_true.
|
||||
lo_style_bold->font->name = zcl_excel_style_font=>c_name_arial.
|
||||
lo_style_bold->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_bold->font->color-rgb = zcl_excel_style_color=>c_red.
|
||||
lv_style_bold_guid = lo_style_bold->get_guid( ).
|
||||
" Create an underline double style
|
||||
lo_style_underline = lo_excel->add_new_style( ).
|
||||
lo_style_underline->font->underline = abap_true.
|
||||
lo_style_underline->font->underline_mode = zcl_excel_style_font=>c_underline_double.
|
||||
lo_style_underline->font->name = zcl_excel_style_font=>c_name_roman.
|
||||
lo_style_underline->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_underline->font->family = zcl_excel_style_font=>c_family_roman.
|
||||
lv_style_underline_guid = lo_style_underline->get_guid( ).
|
||||
" Create filled style yellow
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-theme = zcl_excel_style_color=>c_theme_accent6.
|
||||
lv_style_filled_guid = lo_style_filled->get_guid( ).
|
||||
" Create border with button effects
|
||||
lo_style_button = lo_excel->add_new_style( ).
|
||||
lo_style_button->borders->right = lo_border_dark.
|
||||
lo_style_button->borders->down = lo_border_dark.
|
||||
lo_style_button->borders->left = lo_border_light.
|
||||
lo_style_button->borders->top = lo_border_light.
|
||||
lv_style_button_guid = lo_style_button->get_guid( ).
|
||||
"Create style with border
|
||||
lo_style_border = lo_excel->add_new_style( ).
|
||||
lo_style_border->borders->allborders = lo_border_dark.
|
||||
lo_style_border->borders->diagonal = lo_border_dark.
|
||||
lo_style_border->borders->diagonal_mode = zcl_excel_style_borders=>c_diagonal_both.
|
||||
lv_style_border_guid = lo_style_border->get_guid( ).
|
||||
" Create filled style green
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_green.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_filled_green_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Create filled style turquoise using legacy excel ver <= 2003 palette. (https://code.sdn.sap.com/spaces/abap2xlsx/tickets/92)
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_excel->legacy_palette->set_color( "replace built-in color from palette with out custom RGB turquoise
|
||||
ip_index = 16
|
||||
ip_color = '0040E0D0' ).
|
||||
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-indexed = 16.
|
||||
lv_style_filled_turquoise_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Styles' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Modified color for Excel 2003' ip_style = lv_style_filled_turquoise_guid ).
|
||||
" Fill the cell and apply one style
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
" Change the style
|
||||
lo_worksheet->set_cell_style( ip_column = 'B' ip_row = 6 ip_style = lv_style_filled_green_guid ).
|
||||
" Add Style to an empty cell to test Fix for Issue
|
||||
"#44 Exception ZCX_EXCEL thrown when style is set for an empty cell
|
||||
" https://code.sdn.sap.com/spaces/abap2xlsx/tickets/44-exception-zcx_excel-thrown-when-style-is-set-for-an-empty-cell
|
||||
lo_worksheet->set_cell_style( ip_column = 'E' ip_row = 6 ip_style = lv_style_filled_green_guid ).
|
||||
|
||||
|
||||
* Demonstrate how to retroactivly change the cellstyle
|
||||
*Filled text and underlinded text
|
||||
lo_worksheet->change_cell_style( ip_column = 'B'
|
||||
ip_row = 5
|
||||
ip_font_bold = abap_true
|
||||
ip_font_italic = abap_true ).
|
||||
|
||||
lo_worksheet->change_cell_style( ip_column = 'D'
|
||||
ip_row = 4
|
||||
ip_font_bold = abap_true
|
||||
ip_font_italic = abap_true ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
* " This method is only available on AS ABAP > 6.40
|
||||
* lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
* lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zdemo_excel35.prog.xml
Normal file
32
src/zdemo_excel35.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL35</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: static styles</ENTRY>
|
||||
<LENGTH>33</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
111
src/zdemo_excel36.prog.abap
Normal file
111
src/zdemo_excel36.prog.abap
Normal file
|
@ -0,0 +1,111 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL36
|
||||
REPORT zdemo_excel36.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
col TYPE i.
|
||||
|
||||
DATA: lo_style_arial20 TYPE REF TO zcl_excel_style,
|
||||
lo_style_times11 TYPE REF TO zcl_excel_style,
|
||||
lo_style_cambria8red TYPE REF TO zcl_excel_style.
|
||||
|
||||
DATA: lv_style_arial20_guid TYPE zexcel_cell_style,
|
||||
lv_style_times11_guid TYPE zexcel_cell_style,
|
||||
lv_style_cambria8red_guid TYPE zexcel_cell_style.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '36_DefaultStyles.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create a bold / italic style
|
||||
lo_style_arial20 = lo_excel->add_new_style( ).
|
||||
lo_style_arial20->font->name = zcl_excel_style_font=>c_name_arial.
|
||||
lo_style_arial20->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_arial20->font->size = 20.
|
||||
lv_style_arial20_guid = lo_style_arial20->get_guid( ).
|
||||
|
||||
lo_style_times11 = lo_excel->add_new_style( ).
|
||||
lo_style_times11->font->name = zcl_excel_style_font=>c_name_roman.
|
||||
lo_style_times11->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_times11->font->size = 11.
|
||||
lv_style_times11_guid = lo_style_times11->get_guid( ).
|
||||
|
||||
lo_style_cambria8red = lo_excel->add_new_style( ).
|
||||
lo_style_cambria8red->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_cambria8red->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_cambria8red->font->size = 8.
|
||||
lo_style_cambria8red->font->color-rgb = zcl_excel_style_color=>c_red.
|
||||
lv_style_cambria8red_guid = lo_style_cambria8red->get_guid( ).
|
||||
|
||||
lo_excel->set_default_style( lv_style_arial20_guid ). " Default for all new worksheets
|
||||
|
||||
* 1st sheet - do not change anything --> defaultstyle from lo_excel should apply
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'Style for complete document' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 4 ip_value = 'All cells in this sheet are set to font Arial, fontsize 20' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 5 ip_value = 'because no separate style was passed for this sheet' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 6 ip_value = 'but a default style was set for the complete instance of zcl_excel' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 1 ip_value = space ). " Missing feature "set active cell - use this to simulate that
|
||||
|
||||
|
||||
* 2nd sheet - defaultstyle for this sheet set explicitly ( set to Times New Roman 11 )
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( 'Style for this sheet' ).
|
||||
lo_worksheet->zif_excel_sheet_properties~set_style( lv_style_times11_guid ).
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 4 ip_value = 'All cells in this sheet are set to font Times New Roman, fontsize 11' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 5 ip_value = 'because this style was passed for this sheet' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 6 ip_value = 'thus the default style from zcl_excel does not apply to this sheet' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 1 ip_value = space ). " Missing feature "set active cell - use this to simulate that
|
||||
|
||||
|
||||
* 3rd sheet - defaultstyle for columns ( set to Times New Roman 11 )
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( 'Style for 3 columns' ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'B' ).
|
||||
column_dimension->set_column_style_by_guid( ip_style_guid = lv_style_times11_guid ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'C' ).
|
||||
column_dimension->set_column_style_by_guid( ip_style_guid = lv_style_times11_guid ).
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'F' ).
|
||||
column_dimension->set_column_style_by_guid( ip_style_guid = lv_style_times11_guid ).
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 4 ip_value = 'The columns B,C and F are set to Times New Roman' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 10 ip_value = 'All other cells in this sheet are set to font Arial, fontsize 20' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 11 ip_value = 'because no separate style was passed for this sheet' ).
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 12 ip_value = 'but a default style was set for the complete instance of zcl_excel' ).
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 8 ip_row = 1 ip_value = 'Of course' ip_style = lv_style_cambria8red_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 8 ip_row = 2 ip_value = 'setting a specific style to a cell' ip_style = lv_style_cambria8red_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 8 ip_row = 3 ip_value = 'takes precedence over all defaults' ip_style = lv_style_cambria8red_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 8 ip_row = 4 ip_value = 'Here: Cambria 8 in red' ip_style = lv_style_cambria8red_guid ).
|
||||
|
||||
|
||||
* Set entry into each of the first 10 columns
|
||||
DO 20 TIMES.
|
||||
col = sy-index.
|
||||
CASE col.
|
||||
WHEN 2 " B
|
||||
OR 3 " C
|
||||
OR 6." F
|
||||
lo_worksheet->set_cell( ip_column = col ip_row = 6 ip_value = 'Times 11' ).
|
||||
WHEN OTHERS.
|
||||
lo_worksheet->set_cell( ip_column = col ip_row = 6 ip_value = 'Arial 20' ).
|
||||
ENDCASE.
|
||||
ENDDO.
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 2 ip_row = 1 ip_value = space ). " Missing feature "set active cell - use this to simulate that
|
||||
|
||||
|
||||
|
||||
lo_excel->set_active_sheet_index( 1 ).
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
25
src/zdemo_excel36.prog.xml
Normal file
25
src/zdemo_excel36.prog.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL36</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Default Styles</ENTRY>
|
||||
<LENGTH>31</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
301
src/zdemo_excel37.prog.abap
Normal file
301
src/zdemo_excel37.prog.abap
Normal file
|
@ -0,0 +1,301 @@
|
|||
REPORT zdemo_excel37.
|
||||
|
||||
TYPE-POOLS: vrm.
|
||||
|
||||
DATA: excel TYPE REF TO zcl_excel,
|
||||
reader TYPE REF TO zif_excel_reader,
|
||||
go_error TYPE REF TO cx_root,
|
||||
gv_memid_gr8 TYPE text255,
|
||||
gv_message TYPE string,
|
||||
lv_extension TYPE string,
|
||||
gv_error_program_name TYPE syrepid,
|
||||
gv_error_include_name TYPE syrepid,
|
||||
gv_error_line TYPE i.
|
||||
|
||||
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.
|
||||
SELECTION-SCREEN END OF BLOCK blx.
|
||||
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK cls WITH FRAME TITLE text-cls.
|
||||
PARAMETERS: lb_read TYPE seoclsname AS LISTBOX VISIBLE LENGTH 40 LOWER CASE OBLIGATORY DEFAULT 'Autodetect'(001).
|
||||
PARAMETERS: lb_write TYPE seoclsname AS LISTBOX VISIBLE LENGTH 40 LOWER CASE OBLIGATORY DEFAULT 'Autodetect'(001).
|
||||
SELECTION-SCREEN END OF BLOCK cls.
|
||||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK bl_err WITH FRAME TITLE text-err.
|
||||
PARAMETERS: cb_errl AS CHECKBOX DEFAULT 'X'.
|
||||
SELECTION-SCREEN BEGIN OF LINE.
|
||||
PARAMETERS: cb_dump AS CHECKBOX DEFAULT space.
|
||||
SELECTION-SCREEN COMMENT (60) cmt_dump FOR FIELD cb_dump.
|
||||
SELECTION-SCREEN END OF LINE.
|
||||
SELECTION-SCREEN END OF BLOCK bl_err.
|
||||
|
||||
INITIALIZATION.
|
||||
PERFORM setup_listboxes.
|
||||
cmt_dump = text-dum.
|
||||
GET PARAMETER ID 'GR8' FIELD gv_memid_gr8.
|
||||
p_upfile = gv_memid_gr8.
|
||||
|
||||
IF p_upfile IS INITIAL.
|
||||
p_upfile = 'c:\temp\whatever.xlsx'.
|
||||
ENDIF.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_upfile.
|
||||
PERFORM f4_p_upfile CHANGING p_upfile.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
IF cb_dump IS INITIAL.
|
||||
TRY.
|
||||
PERFORM read_template.
|
||||
PERFORM write_template.
|
||||
*** Create output
|
||||
CATCH cx_root INTO go_error.
|
||||
MESSAGE 'Error reading excelfile' TYPE 'I'.
|
||||
gv_message = go_error->get_text( ).
|
||||
IF cb_errl = ' '.
|
||||
IF gv_message IS NOT INITIAL.
|
||||
MESSAGE gv_message TYPE 'I'.
|
||||
ENDIF.
|
||||
ELSE.
|
||||
go_error->get_source_position( IMPORTING program_name = gv_error_program_name
|
||||
include_name = gv_error_include_name
|
||||
source_line = gv_error_line ).
|
||||
WRITE:/ 'Errormessage:' ,gv_message.
|
||||
WRITE:/ 'Errorposition:',
|
||||
AT /10 'Program:' ,gv_error_program_name,
|
||||
AT /10 'include_name:' ,gv_error_include_name,
|
||||
AT /10 'source_line:' ,gv_error_line.
|
||||
ENDIF.
|
||||
ENDTRY.
|
||||
ELSE. " This will dump if an error occurs. In some cases the information given in cx_root is not helpful - this will show exactly where the problem is
|
||||
PERFORM read_template.
|
||||
PERFORM write_template.
|
||||
ENDIF.
|
||||
|
||||
|
||||
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Form F4_P_UPFILE
|
||||
*&---------------------------------------------------------------------*
|
||||
FORM f4_p_upfile CHANGING p_upfile TYPE string.
|
||||
|
||||
DATA: lv_repid TYPE syrepid,
|
||||
lt_fields TYPE dynpread_tabtype,
|
||||
ls_field LIKE LINE OF lt_fields,
|
||||
lt_files TYPE filetable,
|
||||
lv_file_filter TYPE string.
|
||||
|
||||
lv_repid = sy-repid.
|
||||
|
||||
CALL FUNCTION 'DYNP_VALUES_READ'
|
||||
EXPORTING
|
||||
dyname = lv_repid
|
||||
dynumb = '1000'
|
||||
request = 'A'
|
||||
TABLES
|
||||
dynpfields = lt_fields
|
||||
EXCEPTIONS
|
||||
invalid_abapworkarea = 01
|
||||
invalid_dynprofield = 02
|
||||
invalid_dynproname = 03
|
||||
invalid_dynpronummer = 04
|
||||
invalid_request = 05
|
||||
no_fielddescription = 06
|
||||
undefind_error = 07.
|
||||
READ TABLE lt_fields INTO ls_field WITH KEY fieldname = 'P_UPFILE'.
|
||||
p_upfile = ls_field-fieldvalue.
|
||||
|
||||
lv_file_filter = 'Excel Files (*.XLSX;*.XLSM)|*.XLSX;*.XLSM'.
|
||||
cl_gui_frontend_services=>file_open_dialog( EXPORTING
|
||||
default_filename = p_upfile
|
||||
file_filter = lv_file_filter
|
||||
CHANGING
|
||||
file_table = lt_files
|
||||
rc = sy-tabix
|
||||
EXCEPTIONS
|
||||
OTHERS = 1 ).
|
||||
READ TABLE lt_files INDEX 1 INTO p_upfile.
|
||||
|
||||
ENDFORM. " F4_P_UPFILE
|
||||
|
||||
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Form SETUP_LISTBOXES
|
||||
*&---------------------------------------------------------------------*
|
||||
FORM setup_listboxes .
|
||||
|
||||
DATA: lv_id TYPE vrm_id,
|
||||
lt_values TYPE vrm_values,
|
||||
lt_implementing_classes TYPE seo_relkeys.
|
||||
|
||||
FIELD-SYMBOLS: <ls_implementing_class> LIKE LINE OF lt_implementing_classes,
|
||||
<ls_value> LIKE LINE OF lt_values.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Possible READER-Classes
|
||||
*--------------------------------------------------------------------*
|
||||
lv_id = 'LB_READ'.
|
||||
APPEND INITIAL LINE TO lt_values ASSIGNING <ls_value>.
|
||||
<ls_value>-key = 'Autodetect'(001).
|
||||
<ls_value>-text = 'Autodetect'(001).
|
||||
|
||||
|
||||
PERFORM get_implementing_classds USING 'ZIF_EXCEL_READER'
|
||||
CHANGING lt_implementing_classes.
|
||||
CLEAR lt_values.
|
||||
LOOP AT lt_implementing_classes ASSIGNING <ls_implementing_class>.
|
||||
|
||||
APPEND INITIAL LINE TO lt_values ASSIGNING <ls_value>.
|
||||
<ls_value>-key = <ls_implementing_class>-clsname.
|
||||
<ls_value>-text = <ls_implementing_class>-clsname.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
CALL FUNCTION 'VRM_SET_VALUES'
|
||||
EXPORTING
|
||||
id = lv_id
|
||||
values = lt_values
|
||||
EXCEPTIONS
|
||||
id_illegal_name = 1
|
||||
OTHERS = 2.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Possible WRITER-Classes
|
||||
*--------------------------------------------------------------------*
|
||||
lv_id = 'LB_WRITE'.
|
||||
APPEND INITIAL LINE TO lt_values ASSIGNING <ls_value>.
|
||||
<ls_value>-key = 'Autodetect'(001).
|
||||
<ls_value>-text = 'Autodetect'(001).
|
||||
|
||||
|
||||
PERFORM get_implementing_classds USING 'ZIF_EXCEL_WRITER'
|
||||
CHANGING lt_implementing_classes.
|
||||
CLEAR lt_values.
|
||||
LOOP AT lt_implementing_classes ASSIGNING <ls_implementing_class>.
|
||||
|
||||
APPEND INITIAL LINE TO lt_values ASSIGNING <ls_value>.
|
||||
<ls_value>-key = <ls_implementing_class>-clsname.
|
||||
<ls_value>-text = <ls_implementing_class>-clsname.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
CALL FUNCTION 'VRM_SET_VALUES'
|
||||
EXPORTING
|
||||
id = lv_id
|
||||
values = lt_values
|
||||
EXCEPTIONS
|
||||
id_illegal_name = 1
|
||||
OTHERS = 2.
|
||||
|
||||
ENDFORM. " SETUP_LISTBOXES
|
||||
|
||||
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Form GET_IMPLEMENTING_CLASSDS
|
||||
*&---------------------------------------------------------------------*
|
||||
FORM get_implementing_classds USING iv_interface_name TYPE clike
|
||||
CHANGING ct_implementing_classes TYPE seo_relkeys.
|
||||
|
||||
DATA: lo_oo_interface TYPE REF TO cl_oo_interface,
|
||||
lo_oo_class TYPE REF TO cl_oo_class,
|
||||
lt_implementing_subclasses TYPE seo_relkeys.
|
||||
|
||||
FIELD-SYMBOLS: <ls_implementing_class> LIKE LINE OF ct_implementing_classes.
|
||||
|
||||
TRY.
|
||||
lo_oo_interface ?= cl_oo_interface=>get_instance( iv_interface_name ).
|
||||
CATCH cx_class_not_existent.
|
||||
RETURN.
|
||||
ENDTRY.
|
||||
ct_implementing_classes = lo_oo_interface->get_implementing_classes( ).
|
||||
|
||||
LOOP AT ct_implementing_classes ASSIGNING <ls_implementing_class>.
|
||||
TRY.
|
||||
lo_oo_class ?= cl_oo_class=>get_instance( <ls_implementing_class>-clsname ).
|
||||
lt_implementing_subclasses = lo_oo_class->get_subclasses( ).
|
||||
APPEND LINES OF lt_implementing_subclasses TO ct_implementing_classes.
|
||||
CATCH cx_class_not_existent.
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
|
||||
|
||||
ENDFORM. " GET_IMPLEMENTING_CLASSDS
|
||||
|
||||
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Form READ_TEMPLATE
|
||||
*&---------------------------------------------------------------------*
|
||||
FORM read_template RAISING zcx_excel .
|
||||
|
||||
CASE lb_read.
|
||||
WHEN 'Autodetect'(001).
|
||||
FIND REGEX '(\.xlsx|\.xlsm)\s*$' IN p_upfile SUBMATCHES lv_extension.
|
||||
TRANSLATE lv_extension TO UPPER CASE.
|
||||
CASE lv_extension.
|
||||
|
||||
WHEN '.XLSX'.
|
||||
CREATE OBJECT reader TYPE zcl_excel_reader_2007.
|
||||
excel = reader->load_file( p_upfile ).
|
||||
"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 ).
|
||||
"Use template for charts
|
||||
excel->use_template = abap_true.
|
||||
|
||||
WHEN OTHERS.
|
||||
MESSAGE 'Unsupported filetype' TYPE 'I'.
|
||||
RETURN.
|
||||
|
||||
ENDCASE.
|
||||
|
||||
WHEN OTHERS.
|
||||
CREATE OBJECT reader TYPE (lb_read).
|
||||
excel = reader->load_file( p_upfile ).
|
||||
"Use template for charts
|
||||
excel->use_template = abap_true.
|
||||
|
||||
ENDCASE.
|
||||
|
||||
ENDFORM. " READ_TEMPLATE
|
||||
|
||||
|
||||
*&---------------------------------------------------------------------*
|
||||
*& Form WRITE_TEMPLATE
|
||||
*&---------------------------------------------------------------------*
|
||||
FORM write_template RAISING zcx_excel.
|
||||
|
||||
CASE lb_write.
|
||||
|
||||
WHEN 'Autodetect'(001).
|
||||
FIND REGEX '(\.xlsx|\.xlsm)\s*$' IN p_upfile SUBMATCHES lv_extension.
|
||||
TRANSLATE lv_extension TO UPPER CASE.
|
||||
CASE lv_extension.
|
||||
|
||||
WHEN '.XLSX'.
|
||||
REPLACE '&' IN gc_save_file_name WITH 'xlsx'. " Pass extension for standard writer
|
||||
lcl_output=>output( excel ).
|
||||
|
||||
WHEN '.XLSM'.
|
||||
REPLACE '&' IN gc_save_file_name WITH 'xlsm'. " Pass extension for macro-writer
|
||||
lcl_output=>output( cl_excel = excel
|
||||
iv_writerclass_name = 'ZCL_EXCEL_WRITER_XLSM' ).
|
||||
|
||||
WHEN OTHERS.
|
||||
MESSAGE 'Unsupported filetype' TYPE 'I'.
|
||||
RETURN.
|
||||
|
||||
ENDCASE.
|
||||
|
||||
WHEN OTHERS.
|
||||
lcl_output=>output( cl_excel = excel
|
||||
iv_writerclass_name = lb_write ).
|
||||
ENDCASE.
|
||||
|
||||
ENDFORM. " WRITE_TEMPLATE
|
133
src/zdemo_excel37.prog.xml
Normal file
133
src/zdemo_excel37.prog.xml
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL37</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>CLS</KEY>
|
||||
<ENTRY>Choose reader- and writerclass to use</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>DUM</KEY>
|
||||
<ENTRY>Dump on uncaught exception - you'll know when you need this</ENTRY>
|
||||
<LENGTH>60</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>I</ID>
|
||||
<KEY>ERR</KEY>
|
||||
<ENTRY>Special switches</ENTRY>
|
||||
<LENGTH>60</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Read xlsx-file and output = using templates</ENTRY>
|
||||
<LENGTH>43</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>CB_DUMP</KEY>
|
||||
<ENTRY>Dump for uncaught exceptions</ENTRY>
|
||||
<LENGTH>36</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>CB_ERRL</KEY>
|
||||
<ENTRY>Show position of exception</ENTRY>
|
||||
<LENGTH>34</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>LB_READ</KEY>
|
||||
<ENTRY>Reader-class</ENTRY>
|
||||
<LENGTH>20</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>LB_WRITE</KEY>
|
||||
<ENTRY>Writer-class</ENTRY>
|
||||
<LENGTH>20</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_UPFILE</KEY>
|
||||
<ENTRY>File to upload</ENTRY>
|
||||
<LENGTH>22</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
<I18N_TPOOL>
|
||||
<item>
|
||||
<LANGUAGE>D</LANGUAGE>
|
||||
<TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>I</ID>
|
||||
<KEY>CLS</KEY>
|
||||
<ENTRY>Auswahl der Reader- und Writerklasse</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>I</ID>
|
||||
<KEY>DUM</KEY>
|
||||
<ENTRY>Dump bei unbeh. Exception. Man weiß wenn man das braucht</ENTRY>
|
||||
<LENGTH>60</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>I</ID>
|
||||
<KEY>ERR</KEY>
|
||||
<ENTRY>Besondere Schalter</ENTRY>
|
||||
<LENGTH>60</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Xlsx-Datei lesen und dann wieder ausgeben = Arbeiten mit Templates</ENTRY>
|
||||
<LENGTH>70</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>CB_DUMP</KEY>
|
||||
<ENTRY> Dump bei unbeh. Exceptions</ENTRY>
|
||||
<LENGTH>36</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>CB_ERRL</KEY>
|
||||
<ENTRY> Exceptionposition anzeigen</ENTRY>
|
||||
<LENGTH>34</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>LB_READ</KEY>
|
||||
<ENTRY> Reader-Klasse</ENTRY>
|
||||
<LENGTH>21</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>LB_WRITE</KEY>
|
||||
<ENTRY> Writer-Klasse</ENTRY>
|
||||
<LENGTH>21</LENGTH>
|
||||
</TEXTPOOL>
|
||||
<TEXTPOOL>
|
||||
<ID>S</ID>
|
||||
<KEY>P_UPFILE</KEY>
|
||||
<ENTRY> Hochzuladende Datei</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</TEXTPOOL>
|
||||
</TEXTPOOL>
|
||||
</item>
|
||||
</I18N_TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
106
src/zdemo_excel38.prog.abap
Normal file
106
src/zdemo_excel38.prog.abap
Normal file
|
@ -0,0 +1,106 @@
|
|||
REPORT.
|
||||
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_column_dimension TYPE REF TO zcl_excel_worksheet_columndime,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing.
|
||||
|
||||
TYPES: BEGIN OF gty_icon,
|
||||
* name TYPE icon_name, "Fix #228
|
||||
name TYPE iconname, "Fix #228
|
||||
objid TYPE w3objid,
|
||||
END OF gty_icon,
|
||||
gtyt_icon TYPE STANDARD TABLE OF gty_icon WITH NON-UNIQUE DEFAULT KEY.
|
||||
|
||||
DATA: lt_icon TYPE gtyt_icon,
|
||||
lv_row TYPE sytabix,
|
||||
ls_wwwdatatab TYPE wwwdatatab,
|
||||
lt_mimedata TYPE STANDARD TABLE OF w3mime WITH NON-UNIQUE DEFAULT KEY,
|
||||
lv_xstring TYPE xstring.
|
||||
|
||||
FIELD-SYMBOLS: <icon> LIKE LINE OF lt_icon,
|
||||
<mimedata> LIKE LINE OF lt_mimedata.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '38_SAP-Icons.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
TABLES: icon.
|
||||
SELECT-OPTIONS: s_icon FOR icon-name DEFAULT 'ICON_LED_*' OPTION CP.
|
||||
|
||||
START-OF-SELECTION.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo Icons' ).
|
||||
lo_column_dimension = lo_worksheet->get_column_dimension( ip_column = 'A' ).
|
||||
lo_column_dimension->set_auto_size( 'X' ).
|
||||
lo_column_dimension = lo_worksheet->get_column_dimension( ip_column = 'B' ).
|
||||
lo_column_dimension->set_auto_size( 'X' ).
|
||||
|
||||
* Get all icons
|
||||
SELECT name
|
||||
INTO TABLE lt_icon
|
||||
FROM icon
|
||||
WHERE name IN s_icon
|
||||
ORDER BY name.
|
||||
LOOP AT lt_icon ASSIGNING <icon>.
|
||||
|
||||
lv_row = sy-tabix.
|
||||
*--------------------------------------------------------------------*
|
||||
* Set name of icon
|
||||
*--------------------------------------------------------------------*
|
||||
lo_worksheet->set_cell( ip_row = lv_row
|
||||
ip_column = 'A'
|
||||
ip_value = <icon>-name ).
|
||||
*--------------------------------------------------------------------*
|
||||
* Check whether the mime-repository holds some icondata for us
|
||||
*--------------------------------------------------------------------*
|
||||
|
||||
* Get key
|
||||
SELECT SINGLE objid
|
||||
INTO <icon>-objid
|
||||
FROM wwwdata
|
||||
WHERE text = <icon>-name.
|
||||
CHECK sy-subrc = 0. " :o(
|
||||
lo_worksheet->set_cell( ip_row = lv_row
|
||||
ip_column = 'B'
|
||||
ip_value = <icon>-objid ).
|
||||
|
||||
* Load mimedata
|
||||
CLEAR lt_mimedata.
|
||||
CLEAR ls_wwwdatatab.
|
||||
ls_wwwdatatab-relid = 'MI' .
|
||||
ls_wwwdatatab-objid = <icon>-objid.
|
||||
CALL FUNCTION 'WWWDATA_IMPORT'
|
||||
EXPORTING
|
||||
key = ls_wwwdatatab
|
||||
TABLES
|
||||
mime = lt_mimedata
|
||||
EXCEPTIONS
|
||||
wrong_object_type = 1
|
||||
import_error = 2
|
||||
OTHERS = 3.
|
||||
CHECK sy-subrc = 0. " :o(
|
||||
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = lv_row
|
||||
ip_from_col = 'C' ).
|
||||
CLEAR lv_xstring.
|
||||
LOOP AT lt_mimedata ASSIGNING <mimedata>.
|
||||
CONCATENATE lv_xstring <mimedata>-line INTO lv_xstring IN BYTE MODE.
|
||||
ENDLOOP.
|
||||
|
||||
lo_drawing->set_media( ip_media = lv_xstring
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_jpg
|
||||
ip_width = 16
|
||||
ip_height = 14 ).
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel38.prog.xml
Normal file
32
src/zdemo_excel38.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL38</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Read file and output</ENTRY>
|
||||
<LENGTH>20</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>S_ICON</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
473
src/zdemo_excel39.prog.abap
Normal file
473
src/zdemo_excel39.prog.abap
Normal file
|
@ -0,0 +1,473 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL16
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel39.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing.
|
||||
|
||||
DATA lv_value TYPE i.
|
||||
|
||||
DATA: ls_io TYPE skwf_io.
|
||||
|
||||
DATA: ls_upper TYPE zexcel_drawing_location,
|
||||
ls_lower TYPE zexcel_drawing_location.
|
||||
|
||||
DATA: lo_bar1 TYPE REF TO zcl_excel_graph_bars,
|
||||
lo_bar1_stacked TYPE REF TO zcl_excel_graph_bars,
|
||||
lo_bar2 TYPE REF TO zcl_excel_graph_bars,
|
||||
lo_pie TYPE REF TO zcl_excel_graph_pie,
|
||||
lo_line TYPE REF TO zcl_excel_graph_line.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '39_Charts.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Create a pie chart and series
|
||||
CREATE OBJECT lo_pie.
|
||||
|
||||
CALL METHOD lo_pie->create_serie
|
||||
EXPORTING
|
||||
ip_order = 0
|
||||
ip_sheet = 'Values'
|
||||
ip_lbl_from_col = 'B'
|
||||
ip_lbl_from_row = '1'
|
||||
ip_lbl_to_col = 'B'
|
||||
ip_lbl_to_row = '3'
|
||||
ip_ref_from_col = 'A'
|
||||
ip_ref_from_row = '1'
|
||||
ip_ref_to_col = 'A'
|
||||
ip_ref_to_row = '3'
|
||||
ip_sername = 'My serie 1'.
|
||||
|
||||
" Set style
|
||||
lo_pie->set_style( zcl_excel_graph=>c_style_15 ).
|
||||
|
||||
" Create a bar chart, series and axes
|
||||
CREATE OBJECT lo_bar1.
|
||||
|
||||
CALL METHOD lo_bar1->create_serie
|
||||
EXPORTING
|
||||
ip_order = 0
|
||||
ip_invertifnegative = zcl_excel_graph_bars=>c_invertifnegative_no
|
||||
ip_lbl = 'Values!$D$1:$D$3'
|
||||
ip_ref = 'Values!$C$1:$C$3'
|
||||
ip_sername = 'My serie 1'.
|
||||
|
||||
CALL METHOD lo_bar1->create_serie
|
||||
EXPORTING
|
||||
ip_order = 1
|
||||
ip_invertifnegative = zcl_excel_graph_bars=>c_invertifnegative_no
|
||||
ip_lbl = 'Values!$B$1:$B$3'
|
||||
ip_ref = 'Values!$A$1:$A$3'
|
||||
ip_sername = 'My serie 2'.
|
||||
|
||||
CALL METHOD lo_bar1->create_ax
|
||||
EXPORTING
|
||||
* ip_axid =
|
||||
ip_type = zcl_excel_graph_bars=>c_catax
|
||||
* ip_orientation =
|
||||
* ip_delete =
|
||||
* ip_axpos =
|
||||
* ip_formatcode =
|
||||
* ip_sourcelinked =
|
||||
* ip_majortickmark =
|
||||
* ip_minortickmark =
|
||||
* ip_ticklblpos =
|
||||
* ip_crossax =
|
||||
* ip_crosses =
|
||||
* ip_auto =
|
||||
* ip_lblalgn =
|
||||
* ip_lbloffset =
|
||||
* ip_nomultilvllbl =
|
||||
* ip_crossbetween =
|
||||
.
|
||||
|
||||
CALL METHOD lo_bar1->create_ax
|
||||
EXPORTING
|
||||
* ip_axid =
|
||||
ip_type = zcl_excel_graph_bars=>c_valax
|
||||
* ip_orientation =
|
||||
* ip_delete =
|
||||
* ip_axpos =
|
||||
* ip_formatcode =
|
||||
* ip_sourcelinked =
|
||||
* ip_majortickmark =
|
||||
* ip_minortickmark =
|
||||
* ip_ticklblpos =
|
||||
* ip_crossax =
|
||||
* ip_crosses =
|
||||
* ip_auto =
|
||||
* ip_lblalgn =
|
||||
* ip_lbloffset =
|
||||
* ip_nomultilvllbl =
|
||||
* ip_crossbetween =
|
||||
.
|
||||
|
||||
" Set style
|
||||
lo_bar1->set_style( zcl_excel_graph=>c_style_default ).
|
||||
|
||||
" Set label to none
|
||||
lo_bar1->set_print_lbl( zcl_excel_graph_bars=>c_show_false ).
|
||||
|
||||
* Same barchart - but this time stacked
|
||||
CREATE OBJECT lo_bar1_stacked.
|
||||
|
||||
CALL METHOD lo_bar1_stacked->create_serie
|
||||
EXPORTING
|
||||
ip_order = 0
|
||||
ip_invertifnegative = zcl_excel_graph_bars=>c_invertifnegative_no
|
||||
ip_lbl = 'Values!$D$1:$D$3'
|
||||
ip_ref = 'Values!$C$1:$C$3'
|
||||
ip_sername = 'My serie 1'.
|
||||
|
||||
CALL METHOD lo_bar1_stacked->create_serie
|
||||
EXPORTING
|
||||
ip_order = 1
|
||||
ip_invertifnegative = zcl_excel_graph_bars=>c_invertifnegative_no
|
||||
ip_lbl = 'Values!$B$1:$B$3'
|
||||
ip_ref = 'Values!$A$1:$A$3'
|
||||
ip_sername = 'My serie 2'.
|
||||
|
||||
CALL METHOD lo_bar1_stacked->create_ax
|
||||
EXPORTING
|
||||
ip_type = zcl_excel_graph_bars=>c_catax .
|
||||
|
||||
CALL METHOD lo_bar1_stacked->create_ax
|
||||
EXPORTING
|
||||
ip_type = zcl_excel_graph_bars=>c_valax.
|
||||
|
||||
" Set style
|
||||
lo_bar1_stacked->set_style( zcl_excel_graph=>c_style_default ).
|
||||
|
||||
" Set label to none
|
||||
lo_bar1_stacked->set_print_lbl( zcl_excel_graph_bars=>c_show_false ).
|
||||
|
||||
" Make it stacked
|
||||
lo_bar1_stacked->ns_groupingval = zcl_excel_graph_bars=>c_groupingval_stacked.
|
||||
|
||||
|
||||
" Create a bar chart, series and axes
|
||||
CREATE OBJECT lo_bar2.
|
||||
|
||||
CALL METHOD lo_bar2->create_serie
|
||||
EXPORTING
|
||||
ip_order = 0
|
||||
ip_invertifnegative = zcl_excel_graph_bars=>c_invertifnegative_yes
|
||||
ip_lbl = 'Values!$D$1:$D$3'
|
||||
ip_ref = 'Values!$C$1:$C$3'
|
||||
ip_sername = 'My serie 1'.
|
||||
|
||||
CALL METHOD lo_bar2->create_ax
|
||||
EXPORTING
|
||||
* ip_axid =
|
||||
ip_type = zcl_excel_graph_bars=>c_catax
|
||||
* ip_orientation =
|
||||
* ip_delete =
|
||||
* ip_axpos =
|
||||
* ip_formatcode =
|
||||
* ip_sourcelinked =
|
||||
* ip_majortickmark =
|
||||
* ip_minortickmark =
|
||||
* ip_ticklblpos =
|
||||
* ip_crossax =
|
||||
* ip_crosses =
|
||||
* ip_auto =
|
||||
* ip_lblalgn =
|
||||
* ip_lbloffset =
|
||||
* ip_nomultilvllbl =
|
||||
* ip_crossbetween =
|
||||
.
|
||||
|
||||
CALL METHOD lo_bar2->create_ax
|
||||
EXPORTING
|
||||
* ip_axid =
|
||||
ip_type = zcl_excel_graph_bars=>c_valax
|
||||
* ip_orientation =
|
||||
* ip_delete =
|
||||
* ip_axpos =
|
||||
* ip_formatcode =
|
||||
* ip_sourcelinked =
|
||||
* ip_majortickmark =
|
||||
* ip_minortickmark =
|
||||
* ip_ticklblpos =
|
||||
* ip_crossax =
|
||||
* ip_crosses =
|
||||
* ip_auto =
|
||||
* ip_lblalgn =
|
||||
* ip_lbloffset =
|
||||
* ip_nomultilvllbl =
|
||||
* ip_crossbetween =
|
||||
.
|
||||
|
||||
" Set layout
|
||||
lo_bar2->set_show_legend_key( zcl_excel_graph_bars=>c_show_true ).
|
||||
lo_bar2->set_show_values( zcl_excel_graph_bars=>c_show_true ).
|
||||
lo_bar2->set_show_cat_name( zcl_excel_graph_bars=>c_show_true ).
|
||||
lo_bar2->set_show_ser_name( zcl_excel_graph_bars=>c_show_true ).
|
||||
lo_bar2->set_show_percent( zcl_excel_graph_bars=>c_show_true ).
|
||||
lo_bar2->set_varycolor( zcl_excel_graph_bars=>c_show_true ).
|
||||
|
||||
" Create a line chart, series and axes
|
||||
CREATE OBJECT lo_line.
|
||||
|
||||
CALL METHOD lo_line->create_serie
|
||||
EXPORTING
|
||||
ip_order = 0
|
||||
ip_symbol = zcl_excel_graph_line=>c_symbol_auto
|
||||
ip_smooth = zcl_excel_graph_line=>c_show_false
|
||||
ip_lbl = 'Values!$D$1:$D$3'
|
||||
ip_ref = 'Values!$C$1:$C$3'
|
||||
ip_sername = 'My serie 1'.
|
||||
|
||||
CALL METHOD lo_line->create_serie
|
||||
EXPORTING
|
||||
ip_order = 1
|
||||
ip_symbol = zcl_excel_graph_line=>c_symbol_none
|
||||
ip_smooth = zcl_excel_graph_line=>c_show_false
|
||||
ip_lbl = 'Values!$B$1:$B$3'
|
||||
ip_ref = 'Values!$A$1:$A$3'
|
||||
ip_sername = 'My serie 2'.
|
||||
|
||||
CALL METHOD lo_line->create_serie
|
||||
EXPORTING
|
||||
ip_order = 2
|
||||
ip_symbol = zcl_excel_graph_line=>c_symbol_auto
|
||||
ip_smooth = zcl_excel_graph_line=>c_show_false
|
||||
ip_lbl = 'Values!$F$1:$F$3'
|
||||
ip_ref = 'Values!$E$1:$E$3'
|
||||
ip_sername = 'My serie 3'.
|
||||
|
||||
CALL METHOD lo_line->create_ax
|
||||
EXPORTING
|
||||
* ip_axid =
|
||||
ip_type = zcl_excel_graph_line=>c_catax
|
||||
* ip_orientation =
|
||||
* ip_delete =
|
||||
* ip_axpos =
|
||||
* ip_majortickmark =
|
||||
* ip_minortickmark =
|
||||
* ip_ticklblpos =
|
||||
* ip_crossax =
|
||||
* ip_crosses =
|
||||
* ip_auto =
|
||||
* ip_lblalgn =
|
||||
* ip_lbloffset =
|
||||
* ip_nomultilvllbl =
|
||||
* ip_crossbetween =
|
||||
.
|
||||
|
||||
CALL METHOD lo_line->create_ax
|
||||
EXPORTING
|
||||
* ip_axid =
|
||||
ip_type = zcl_excel_graph_line=>c_valax
|
||||
* ip_orientation =
|
||||
* ip_delete =
|
||||
* ip_axpos =
|
||||
* ip_formatcode =
|
||||
* ip_sourcelinked =
|
||||
* ip_majortickmark =
|
||||
* ip_minortickmark =
|
||||
* ip_ticklblpos =
|
||||
* ip_crossax =
|
||||
* ip_crosses =
|
||||
* ip_auto =
|
||||
* ip_lblalgn =
|
||||
* ip_lbloffset =
|
||||
* ip_nomultilvllbl =
|
||||
* ip_crossbetween =
|
||||
.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet (Pie sheet)
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( 'PieChart' ).
|
||||
|
||||
" Create global drawing, set type as pie chart, assign chart, set position and media type
|
||||
lo_drawing = lo_worksheet->excel->add_new_drawing(
|
||||
ip_type = zcl_excel_drawing=>type_chart
|
||||
ip_title = 'CHART PIE' ).
|
||||
lo_drawing->graph = lo_pie.
|
||||
lo_drawing->graph_type = zcl_excel_drawing=>c_graph_pie.
|
||||
|
||||
"Set chart position (anchor 2 cells)
|
||||
ls_lower-row = 30.
|
||||
ls_lower-col = 20.
|
||||
lo_drawing->set_position2(
|
||||
EXPORTING
|
||||
ip_from = ls_upper
|
||||
ip_to = ls_lower ).
|
||||
|
||||
lo_drawing->set_media(
|
||||
EXPORTING
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_xml ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" BarChart1 sheet
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'BarChart1' ).
|
||||
|
||||
" Create global drawing, set type as bar chart, assign chart, set position and media type
|
||||
lo_drawing = lo_worksheet->excel->add_new_drawing(
|
||||
ip_type = zcl_excel_drawing=>type_chart
|
||||
ip_title = 'CHART BARS WITH 2 SERIES' ).
|
||||
lo_drawing->graph = lo_bar1.
|
||||
lo_drawing->graph_type = zcl_excel_drawing=>c_graph_bars.
|
||||
|
||||
"Set chart position (anchor 2 cells)
|
||||
ls_upper-row = 0.
|
||||
ls_upper-col = 11.
|
||||
ls_lower-row = 22.
|
||||
ls_lower-col = 21.
|
||||
lo_drawing->set_position2(
|
||||
EXPORTING
|
||||
ip_from = ls_upper
|
||||
ip_to = ls_lower ).
|
||||
|
||||
lo_drawing->set_media(
|
||||
EXPORTING
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_xml ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
lo_drawing = lo_worksheet->excel->add_new_drawing(
|
||||
ip_type = zcl_excel_drawing=>type_chart
|
||||
ip_title = 'Stacked CHART BARS WITH 2 SER.' ).
|
||||
lo_drawing->graph = lo_bar1_stacked.
|
||||
lo_drawing->graph_type = zcl_excel_drawing=>c_graph_bars.
|
||||
|
||||
"Set chart position (anchor 2 cells)
|
||||
ls_upper-row = 0.
|
||||
ls_upper-col = 1.
|
||||
ls_lower-row = 22.
|
||||
ls_lower-col = 10.
|
||||
lo_drawing->set_position2(
|
||||
EXPORTING
|
||||
ip_from = ls_upper
|
||||
ip_to = ls_lower ).
|
||||
|
||||
lo_drawing->set_media(
|
||||
EXPORTING
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_xml ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" BarChart2 sheet
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'BarChart2' ).
|
||||
|
||||
" Create global drawing, set type as bar chart, assign chart, set position and media type
|
||||
lo_drawing = lo_worksheet->excel->add_new_drawing(
|
||||
ip_type = zcl_excel_drawing=>type_chart
|
||||
ip_title = 'CHART BARS WITH 1 SERIE' ).
|
||||
lo_drawing->graph = lo_bar2.
|
||||
lo_drawing->graph_type = zcl_excel_drawing=>c_graph_bars.
|
||||
|
||||
"Set chart position (anchor 2 cells)
|
||||
ls_upper-row = 0.
|
||||
ls_upper-col = 0.
|
||||
ls_lower-row = 30.
|
||||
ls_lower-col = 20.
|
||||
lo_drawing->set_position2(
|
||||
EXPORTING
|
||||
ip_from = ls_upper
|
||||
ip_to = ls_lower ).
|
||||
|
||||
lo_drawing->set_media(
|
||||
EXPORTING
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_xml ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" LineChart sheet
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'LineChart' ).
|
||||
|
||||
" Create global drawing, set type as line chart, assign chart, set position and media type
|
||||
lo_drawing = lo_worksheet->excel->add_new_drawing(
|
||||
ip_type = zcl_excel_drawing=>type_chart
|
||||
ip_title = 'CHART LINES' ).
|
||||
lo_drawing->graph = lo_line.
|
||||
lo_drawing->graph_type = zcl_excel_drawing=>c_graph_line.
|
||||
|
||||
"Set chart position (anchor 2 cells)
|
||||
ls_upper-row = 0.
|
||||
ls_upper-col = 0.
|
||||
ls_lower-row = 30.
|
||||
ls_lower-col = 20.
|
||||
lo_drawing->set_position2(
|
||||
EXPORTING
|
||||
ip_from = ls_upper
|
||||
ip_to = ls_lower ).
|
||||
|
||||
lo_drawing->set_media(
|
||||
EXPORTING
|
||||
ip_media_type = zcl_excel_drawing=>c_media_type_xml ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" Values sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Values' ).
|
||||
|
||||
" Set values for chart
|
||||
lv_value = 1.
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = lv_value ).
|
||||
lv_value = 2.
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 2 ip_value = lv_value ).
|
||||
lv_value = 3.
|
||||
lo_worksheet->set_cell( ip_column = 'A' ip_row = 3 ip_value = lv_value ).
|
||||
|
||||
" Set labels for chart
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 1 ip_value = 'One' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Two' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'Three' ).
|
||||
|
||||
" Set values for chart
|
||||
lv_value = 3.
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 1 ip_value = lv_value ).
|
||||
lv_value = 2.
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 2 ip_value = lv_value ).
|
||||
lv_value = -1.
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = lv_value ).
|
||||
|
||||
" Set labels for chart
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 3 ip_value = 'One (Minus)' ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 2 ip_value = 'Two' ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 1 ip_value = 'Three' ).
|
||||
|
||||
" Set values for chart
|
||||
lv_value = 3.
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = 1 ip_value = lv_value ).
|
||||
lv_value = 1.
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = 2 ip_value = lv_value ).
|
||||
lv_value = 2.
|
||||
lo_worksheet->set_cell( ip_column = 'E' ip_row = 3 ip_value = lv_value ).
|
||||
|
||||
" Set labels for chart
|
||||
lo_worksheet->set_cell( ip_column = 'F' ip_row = 3 ip_value = 'Two' ).
|
||||
lo_worksheet->set_cell( ip_column = 'F' ip_row = 2 ip_value = 'One' ).
|
||||
lo_worksheet->set_cell( ip_column = 'F' ip_row = 1 ip_value = 'Three' ).
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
53
src/zdemo_excel39.prog.xml
Normal file
53
src/zdemo_excel39.prog.xml
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL39</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Drawings</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>POBJTYPE</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_CLASS</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_OBJID</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
115
src/zdemo_excel4.prog.abap
Normal file
115
src/zdemo_excel4.prog.abap
Normal file
|
@ -0,0 +1,115 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL4
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel4.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
|
||||
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
|
||||
|
||||
lv_tabcolor TYPE zexcel_s_tabcolor,
|
||||
|
||||
ls_header TYPE zexcel_s_worksheet_head_foot,
|
||||
ls_footer TYPE zexcel_s_worksheet_head_foot.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '04_Sheets.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet1' ).
|
||||
lo_worksheet->zif_excel_sheet_properties~selected = zif_excel_sheet_properties=>c_selected.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ).
|
||||
* Set color to tab with sheetname - Red
|
||||
lv_tabcolor-rgb = zcl_excel_style_color=>create_new_argb( ip_red = 'FF'
|
||||
ip_green = '00'
|
||||
ip_blu = '00' ).
|
||||
lo_worksheet->set_tabcolor( lv_tabcolor ).
|
||||
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet2!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'This is link to second sheet' ip_hyperlink = lo_hyperlink ).
|
||||
|
||||
" Page printing settings
|
||||
lo_worksheet->sheet_setup->set_page_margins( ip_header = '1' ip_footer = '1' ip_unit = 'cm' ).
|
||||
lo_worksheet->sheet_setup->black_and_white = 'X'.
|
||||
lo_worksheet->sheet_setup->fit_to_page = 'X'. " you should turn this on to activate fit_to_height and fit_to_width
|
||||
lo_worksheet->sheet_setup->fit_to_height = 0. " used only if ip_fit_to_page = 'X'
|
||||
lo_worksheet->sheet_setup->fit_to_width = 2. " used only if ip_fit_to_page = 'X'
|
||||
lo_worksheet->sheet_setup->orientation = zcl_excel_sheet_setup=>c_orientation_landscape.
|
||||
lo_worksheet->sheet_setup->page_order = zcl_excel_sheet_setup=>c_ord_downthenover.
|
||||
lo_worksheet->sheet_setup->paper_size = zcl_excel_sheet_setup=>c_papersize_a4.
|
||||
lo_worksheet->sheet_setup->scale = 80. " used only if ip_fit_to_page = SPACE
|
||||
|
||||
" Header and Footer
|
||||
ls_header-right_value = 'print date &D'.
|
||||
ls_header-right_font-size = 8.
|
||||
ls_header-right_font-name = zcl_excel_style_font=>c_name_arial.
|
||||
|
||||
ls_footer-left_value = '&Z&F'. "Path / Filename
|
||||
ls_footer-left_font = ls_header-right_font.
|
||||
ls_footer-right_value = 'page &P of &N'. "page x of y
|
||||
ls_footer-right_font = ls_header-right_font.
|
||||
|
||||
lo_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_header
|
||||
ip_odd_footer = ls_footer ).
|
||||
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet2' ).
|
||||
* Set color to tab with sheetname - Green
|
||||
lv_tabcolor-rgb = zcl_excel_style_color=>create_new_argb( ip_red = '00'
|
||||
ip_green = 'FF'
|
||||
ip_blu = '00' ).
|
||||
lo_worksheet->set_tabcolor( lv_tabcolor ).
|
||||
lo_worksheet->zif_excel_sheet_properties~selected = zif_excel_sheet_properties=>c_selected.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ).
|
||||
lo_hyperlink = zcl_excel_hyperlink=>create_internal_link( iv_location = 'Sheet1!B2' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 'This is link to first sheet' ip_hyperlink = lo_hyperlink ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 4 ip_value = 'Sheet3 is hidden' ).
|
||||
|
||||
lo_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_header
|
||||
ip_odd_footer = ls_footer ).
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet3' ).
|
||||
* Set color to tab with sheetname - Blue
|
||||
lv_tabcolor-rgb = zcl_excel_style_color=>create_new_argb( ip_red = '00'
|
||||
ip_green = '00'
|
||||
ip_blu = 'FF' ).
|
||||
lo_worksheet->set_tabcolor( lv_tabcolor ).
|
||||
lo_worksheet->zif_excel_sheet_properties~hidden = zif_excel_sheet_properties=>c_hidden.
|
||||
|
||||
lo_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_header
|
||||
ip_odd_footer = ls_footer ).
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Sheet4' ).
|
||||
* Set color to tab with sheetname - other color
|
||||
lv_tabcolor-rgb = zcl_excel_style_color=>create_new_argb( ip_red = '00'
|
||||
ip_green = 'FF'
|
||||
ip_blu = 'FF' ).
|
||||
lo_worksheet->set_tabcolor( lv_tabcolor ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Cell B3 has value 0' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = 0 ).
|
||||
lo_worksheet->zif_excel_sheet_properties~show_zeros = zif_excel_sheet_properties=>c_hidezero.
|
||||
|
||||
lo_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_header
|
||||
ip_odd_footer = ls_footer ).
|
||||
|
||||
lo_excel->set_active_sheet_index_by_name( 'Sheet1' ).
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel4.prog.xml
Normal file
32
src/zdemo_excel4.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL4</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Create XLXS with multiple sheets</ENTRY>
|
||||
<LENGTH>49</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
83
src/zdemo_excel40.prog.abap
Normal file
83
src/zdemo_excel40.prog.abap
Normal file
|
@ -0,0 +1,83 @@
|
|||
REPORT.
|
||||
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lv_row TYPE zexcel_cell_row,
|
||||
lv_col TYPE i,
|
||||
lv_row_char TYPE char10,
|
||||
lv_value TYPE string,
|
||||
ls_fontcolor TYPE zexcel_style_color_argb.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '40_Printsettings.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo Printsettings' ).
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Prepare sheet with trivial data
|
||||
* - first 4 columns will have fontocolor set
|
||||
* - first 3 rows will have fontcolor set
|
||||
* These marked cells will be used for repeatable rows/columns on printpages
|
||||
*--------------------------------------------------------------------*
|
||||
DO 100 TIMES. " Rows
|
||||
|
||||
lv_row = sy-index .
|
||||
WRITE lv_row TO lv_row_char.
|
||||
|
||||
DO 20 TIMES.
|
||||
|
||||
lv_col = sy-index - 1.
|
||||
CONCATENATE sy-abcde+lv_col(1) lv_row_char INTO lv_value.
|
||||
lv_col = sy-index.
|
||||
lo_worksheet->set_cell( ip_row = lv_row
|
||||
ip_column = lv_col
|
||||
ip_value = lv_value ).
|
||||
|
||||
TRY.
|
||||
IF lv_row <= 3.
|
||||
lo_worksheet->change_cell_style( ip_column = lv_col
|
||||
ip_row = lv_row
|
||||
ip_fill_filltype = zcl_excel_style_fill=>c_fill_solid
|
||||
ip_fill_fgcolor_rgb = zcl_excel_style_color=>c_yellow ).
|
||||
ENDIF.
|
||||
IF lv_col <= 4.
|
||||
lo_worksheet->change_cell_style( ip_column = lv_col
|
||||
ip_row = lv_row
|
||||
ip_font_color_rgb = zcl_excel_style_color=>c_red ).
|
||||
ENDIF.
|
||||
CATCH zcx_excel .
|
||||
ENDTRY.
|
||||
|
||||
ENDDO.
|
||||
|
||||
|
||||
|
||||
ENDDO.
|
||||
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Printsettings
|
||||
*--------------------------------------------------------------------*
|
||||
TRY.
|
||||
lo_worksheet->zif_excel_sheet_printsettings~set_print_repeat_columns( iv_columns_from = 'A'
|
||||
iv_columns_to = 'D' ).
|
||||
lo_worksheet->zif_excel_sheet_printsettings~set_print_repeat_rows( iv_rows_from = 1
|
||||
iv_rows_to = 3 ).
|
||||
CATCH zcx_excel .
|
||||
ENDTRY.
|
||||
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel40.prog.xml
Normal file
32
src/zdemo_excel40.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL40</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Print settings</ENTRY>
|
||||
<LENGTH>20</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>S_ICON</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
102
src/zdemo_excel42.prog.abap
Normal file
102
src/zdemo_excel42.prog.abap
Normal file
|
@ -0,0 +1,102 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL42
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT ZDEMO_EXCEL42.
|
||||
type-POOLS: vrm.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_theme TYPE REF TO zcl_excel_theme,
|
||||
lo_style type ref to zcl_excel_style,
|
||||
lv_style_guid type ZEXCEL_CELL_STYLE.
|
||||
DATA: gc_save_file_name TYPE string VALUE '42 Theme Manipulation demo.&'.
|
||||
include zdemo_excel_outputopt_incl.
|
||||
|
||||
initialization.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create a bold / italic style with usage of major font
|
||||
lo_style = lo_excel->add_new_style( ).
|
||||
lo_style->font->bold = abap_true.
|
||||
lo_style->font->italic = abap_true.
|
||||
lo_style->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lo_style->font->color-rgb = zcl_excel_style_color=>c_red.
|
||||
lv_style_guid = lo_style->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Styles' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_guid ).
|
||||
|
||||
"create theme
|
||||
create object lo_theme.
|
||||
lo_theme->set_theme_name( iv_name = 'Theme Demo 42 A2X' ).
|
||||
lo_theme->set_color_scheme_name( iv_name = 'Demo 42 A2X' ).
|
||||
|
||||
"set theme colors
|
||||
lo_theme->set_color(
|
||||
exporting
|
||||
iv_type = zcl_excel_theme_color_scheme=>c_dark1
|
||||
iv_srgb = '5F9EA0'
|
||||
* iv_syscolorname =
|
||||
* iv_syscolorlast =
|
||||
).
|
||||
lo_theme->set_color(
|
||||
exporting
|
||||
iv_type = zcl_excel_theme_color_scheme=>c_dark2
|
||||
iv_srgb = 'FFA500'
|
||||
* iv_syscolorname =
|
||||
* iv_syscolorlast =
|
||||
).
|
||||
lo_theme->set_color(
|
||||
exporting
|
||||
iv_type = zcl_excel_theme_color_scheme=>c_light1
|
||||
iv_srgb = '778899'
|
||||
* iv_syscolorname =
|
||||
* iv_syscolorlast =
|
||||
).
|
||||
|
||||
lo_theme->set_color(
|
||||
exporting
|
||||
iv_type = zcl_excel_theme_color_scheme=>c_light1
|
||||
iv_srgb = '9932CC'
|
||||
* iv_syscolorname =
|
||||
* iv_syscolorlast =
|
||||
).
|
||||
lo_theme->set_font_scheme_name( iv_name = 'Demo 42 A2X' ).
|
||||
|
||||
|
||||
"set theme latin fonts - major and minor
|
||||
lo_theme->set_latin_font(
|
||||
exporting
|
||||
iv_type = zcl_excel_theme_font_scheme=>c_major
|
||||
iv_typeface = 'Britannic Bold'
|
||||
* iv_panose =
|
||||
* iv_pitchfamily =
|
||||
* iv_charset =
|
||||
).
|
||||
lo_theme->set_latin_font(
|
||||
exporting
|
||||
iv_type = zcl_excel_theme_font_scheme=>c_minor
|
||||
iv_typeface = 'Broadway'
|
||||
* iv_panose =
|
||||
* iv_pitchfamily =
|
||||
* iv_charset =
|
||||
).
|
||||
"push theme to file
|
||||
lo_excel->set_theme( io_theme = lo_theme ).
|
||||
|
||||
"output
|
||||
lcl_output=>output( cl_excel = lo_excel ).
|
26
src/zdemo_excel42.prog.xml
Normal file
26
src/zdemo_excel42.prog.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL42</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<APPL>*</APPL>
|
||||
<RSTAT>K</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Theme manipulation demo</ENTRY>
|
||||
<LENGTH>23</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
79
src/zdemo_excel5.prog.abap
Normal file
79
src/zdemo_excel5.prog.abap
Normal file
|
@ -0,0 +1,79 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL5
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel5.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional.
|
||||
|
||||
DATA: ls_iconset TYPE zexcel_conditional_iconset.
|
||||
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '05_Conditional.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
|
||||
|
||||
ls_iconset-iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
ls_iconset-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo1_value = '0'.
|
||||
ls_iconset-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo2_value = '33'.
|
||||
ls_iconset-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset-cfvo3_value = '66'.
|
||||
ls_iconset-showvalue = zcl_excel_style_conditional=>c_showvalue_true.
|
||||
|
||||
lo_style_conditional->mode_iconset = ls_iconset.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 100 ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 1000 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 150 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 500 ).
|
||||
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset-iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
ls_iconset-showvalue = zcl_excel_style_conditional=>c_showvalue_false.
|
||||
lo_style_conditional->mode_iconset = ls_iconset.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 100 ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = 1000 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = 150 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = 500 ).
|
||||
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
25
src/zdemo_excel5.prog.xml
Normal file
25
src/zdemo_excel5.prog.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL5</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Conditinal formating</ENTRY>
|
||||
<LENGTH>37</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
61
src/zdemo_excel6.prog.abap
Normal file
61
src/zdemo_excel6.prog.abap
Normal file
|
@ -0,0 +1,61 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL6
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel6.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lv_row TYPE syindex,
|
||||
lv_formula TYPE string.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '06_Formulas.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Get some testdata
|
||||
*--------------------------------------------------------------------*
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 100 ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 1000 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 150 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = -10 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 500 ).
|
||||
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Demonstrate using formulas
|
||||
*--------------------------------------------------------------------*
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_formula = 'SUM(C4:C8)' ).
|
||||
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* Demonstrate standard EXCEL-behaviour when copying a formula to another cell
|
||||
* by calculating the resulting formula to put into another cell
|
||||
*--------------------------------------------------------------------*
|
||||
DO 10 TIMES.
|
||||
|
||||
lv_formula = zcl_excel_common=>shift_formula( iv_reference_formula = 'SUM(C4:C8)'
|
||||
iv_shift_cols = 0 " Offset in Columns - here we copy in same column --> 0
|
||||
iv_shift_rows = sy-index ). " Offset in Row - here we copy downward --> sy-index
|
||||
lv_row = 9 + sy-index. " Absolute row = sy-index rows below reference cell
|
||||
lo_worksheet->set_cell( ip_row = lv_row ip_column = 'C' ip_formula = lv_formula ).
|
||||
|
||||
ENDDO.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
*** Create output
|
||||
*--------------------------------------------------------------------*
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel6.prog.xml
Normal file
32
src/zdemo_excel6.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL6</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Formulas</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
425
src/zdemo_excel7.prog.abap
Normal file
425
src/zdemo_excel7.prog.abap
Normal file
|
@ -0,0 +1,425 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL7
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel7.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional.
|
||||
|
||||
DATA: ls_iconset3 TYPE zexcel_conditional_iconset,
|
||||
ls_iconset4 TYPE zexcel_conditional_iconset,
|
||||
ls_iconset5 TYPE zexcel_conditional_iconset,
|
||||
ls_databar TYPE zexcel_conditional_databar,
|
||||
ls_colorscale2 TYPE zexcel_conditional_colorscale,
|
||||
ls_colorscale3 TYPE zexcel_conditional_colorscale.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '07_ConditionalAll.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
ls_iconset3-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset3-cfvo1_value = '0'.
|
||||
ls_iconset3-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset3-cfvo2_value = '33'.
|
||||
ls_iconset3-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset3-cfvo3_value = '66'.
|
||||
ls_iconset3-showvalue = zcl_excel_style_conditional=>c_showvalue_true.
|
||||
|
||||
ls_iconset4-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset4-cfvo1_value = '0'.
|
||||
ls_iconset4-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset4-cfvo2_value = '25'.
|
||||
ls_iconset4-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset4-cfvo3_value = '50'.
|
||||
ls_iconset4-cfvo4_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset4-cfvo4_value = '75'.
|
||||
ls_iconset4-showvalue = zcl_excel_style_conditional=>c_showvalue_true.
|
||||
|
||||
ls_iconset5-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset5-cfvo1_value = '0'.
|
||||
ls_iconset5-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset5-cfvo2_value = '20'.
|
||||
ls_iconset5-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset5-cfvo3_value = '40'.
|
||||
ls_iconset5-cfvo4_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset5-cfvo4_value = '60'.
|
||||
ls_iconset5-cfvo5_type = zcl_excel_style_conditional=>c_cfvo_type_percent.
|
||||
ls_iconset5-cfvo5_value = '80'.
|
||||
ls_iconset5-showvalue = zcl_excel_style_conditional=>c_showvalue_true.
|
||||
|
||||
ls_databar-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_min.
|
||||
ls_databar-cfvo1_value = '0'.
|
||||
ls_databar-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_max.
|
||||
ls_databar-cfvo2_value = '0'.
|
||||
ls_databar-colorrgb = 'FF638EC6'.
|
||||
|
||||
ls_colorscale2-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_min.
|
||||
ls_colorscale2-cfvo1_value = '0'.
|
||||
ls_colorscale2-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percentile.
|
||||
ls_colorscale2-cfvo2_value = '50'.
|
||||
ls_colorscale2-colorrgb1 = 'FFF8696B'.
|
||||
ls_colorscale2-colorrgb2 = 'FF63BE7B'.
|
||||
|
||||
ls_colorscale3-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_min.
|
||||
ls_colorscale3-cfvo1_value = '0'.
|
||||
ls_colorscale3-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percentile.
|
||||
ls_colorscale3-cfvo2_value = '50'.
|
||||
ls_colorscale3-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_max.
|
||||
ls_colorscale3-cfvo3_value = '0'.
|
||||
ls_colorscale3-colorrgb1 = 'FFF8696B'.
|
||||
ls_colorscale3-colorrgb2 = 'FFFFEB84'.
|
||||
ls_colorscale3-colorrgb3 = 'FF63BE7B'.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
* ICONSET
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3arrows.
|
||||
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_value = 50 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3flags.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'C_ICONSET_3FLAGS' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'D' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'D' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'D' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'C_ICONSET_3TRAFFICLIGHTS' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'E' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'E' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'E' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'E' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'F'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'F'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'F' ip_value = 'C_ICONSET_3TRAFFICLIGHTS2' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'F' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'F' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'F' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'F' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'F' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3signs.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'G'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'G'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'G' ip_value = 'C_ICONSET_3SIGNS' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'G' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'G' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'G' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'G' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'G' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3symbols.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'H'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'H'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'H' ip_value = 'C_ICONSET_3SYMBOLS' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'H' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'H' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'H' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'H' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'H' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3symbols2.
|
||||
lo_style_conditional->mode_iconset = ls_iconset3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'I'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'I'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'I' ip_value = 'C_ICONSET_3SYMBOLS2' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'I' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'I' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'I' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'I' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'I' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset4-iconset = zcl_excel_style_conditional=>c_iconset_4arrows.
|
||||
lo_style_conditional->mode_iconset = ls_iconset4.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 16 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = 'C_ICONSET_4ARROWS' ).
|
||||
lo_worksheet->set_cell( ip_row = 12 ip_column = 'B' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'B' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 14 ip_column = 'B' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 15 ip_column = 'B' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 16 ip_column = 'B' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset4-iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray.
|
||||
lo_style_conditional->mode_iconset = ls_iconset4.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 16 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'C' ip_value = 'C_ICONSET_4ARROWSGRAY' ).
|
||||
lo_worksheet->set_cell( ip_row = 12 ip_column = 'C' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'C' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 14 ip_column = 'C' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 15 ip_column = 'C' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 16 ip_column = 'C' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset4-iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack.
|
||||
lo_style_conditional->mode_iconset = ls_iconset4.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 16 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'D' ip_value = 'C_ICONSET_4REDTOBLACK' ).
|
||||
lo_worksheet->set_cell( ip_row = 12 ip_column = 'D' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'D' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 14 ip_column = 'D' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 15 ip_column = 'D' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 16 ip_column = 'D' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset4-iconset = zcl_excel_style_conditional=>c_iconset_4rating.
|
||||
lo_style_conditional->mode_iconset = ls_iconset4.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 16 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'E' ip_value = 'C_ICONSET_4RATING' ).
|
||||
lo_worksheet->set_cell( ip_row = 12 ip_column = 'E' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'E' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 14 ip_column = 'E' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 15 ip_column = 'E' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 16 ip_column = 'E' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset4-iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights.
|
||||
lo_style_conditional->mode_iconset = ls_iconset4.
|
||||
lo_style_conditional->set_range( ip_start_column = 'F'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'F'
|
||||
ip_stop_row = 16 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'F' ip_value = 'C_ICONSET_4TRAFFICLIGHTS' ).
|
||||
lo_worksheet->set_cell( ip_row = 12 ip_column = 'F' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 13 ip_column = 'F' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 14 ip_column = 'F' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 15 ip_column = 'F' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 16 ip_column = 'F' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset5-iconset = zcl_excel_style_conditional=>c_iconset_5arrows.
|
||||
lo_style_conditional->mode_iconset = ls_iconset5.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 23 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 18 ip_column = 'B' ip_value = 'C_ICONSET_5ARROWS' ).
|
||||
lo_worksheet->set_cell( ip_row = 19 ip_column = 'B' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 20 ip_column = 'B' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 21 ip_column = 'B' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 22 ip_column = 'B' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 23 ip_column = 'B' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset5-iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray.
|
||||
lo_style_conditional->mode_iconset = ls_iconset5.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 23 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 18 ip_column = 'C' ip_value = 'C_ICONSET_5ARROWSGRAY' ).
|
||||
lo_worksheet->set_cell( ip_row = 19 ip_column = 'C' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 20 ip_column = 'C' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 21 ip_column = 'C' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 22 ip_column = 'C' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 23 ip_column = 'C' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset5-iconset = zcl_excel_style_conditional=>c_iconset_5rating.
|
||||
lo_style_conditional->mode_iconset = ls_iconset5.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 23 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 18 ip_column = 'D' ip_value = 'C_ICONSET_5RATING' ).
|
||||
lo_worksheet->set_cell( ip_row = 19 ip_column = 'D' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 20 ip_column = 'D' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 21 ip_column = 'D' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 22 ip_column = 'D' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 23 ip_column = 'D' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->priority = 1.
|
||||
ls_iconset5-iconset = zcl_excel_style_conditional=>c_iconset_5quarters.
|
||||
lo_style_conditional->mode_iconset = ls_iconset5.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 23 ).
|
||||
|
||||
* DATABAR
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 25 ip_column = 'B' ip_value = 'DATABAR' ).
|
||||
lo_worksheet->set_cell( ip_row = 26 ip_column = 'B' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 27 ip_column = 'B' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 28 ip_column = 'B' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 29 ip_column = 'B' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 30 ip_column = 'B' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_databar.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->mode_databar = ls_databar.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 26
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 30 ).
|
||||
|
||||
* COLORSCALE
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 25 ip_column = 'C' ip_value = 'COLORSCALE 2 COLORS' ).
|
||||
lo_worksheet->set_cell( ip_row = 26 ip_column = 'C' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 27 ip_column = 'C' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 28 ip_column = 'C' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 29 ip_column = 'C' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 30 ip_column = 'C' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_colorscale.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->mode_colorscale = ls_colorscale2.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 26
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 30 ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 25 ip_column = 'D' ip_value = 'COLORSCALE 3 COLORS' ).
|
||||
lo_worksheet->set_cell( ip_row = 26 ip_column = 'D' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 27 ip_column = 'D' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 28 ip_column = 'D' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 29 ip_column = 'D' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 30 ip_column = 'D' ip_value = 50 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_colorscale.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->mode_colorscale = ls_colorscale3.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 26
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 30 ).
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel7.prog.xml
Normal file
32
src/zdemo_excel7.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL7</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: All conditional formating possibilities</ENTRY>
|
||||
<LENGTH>56</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
71
src/zdemo_excel8.prog.abap
Normal file
71
src/zdemo_excel8.prog.abap
Normal file
|
@ -0,0 +1,71 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL8
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel8.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_range TYPE REF TO zcl_excel_range.
|
||||
|
||||
DATA: lv_title TYPE zexcel_sheet_title.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '08_Range.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lv_title = 'Sheet1'.
|
||||
lo_worksheet->set_title( lv_title ).
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'range'.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ).
|
||||
|
||||
" Define another Range with a name longer than 40 characters that
|
||||
" tests the fix of issue #168 ranges namescan be only up to 20 chars
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'A_range_with_a_name_that_is_longer_than_20_characters'.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'D'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 5 ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'Range Value 1' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 'Range Value 2' ).
|
||||
|
||||
" issue #163
|
||||
" Define another Range with sheet visibility
|
||||
lo_range = lo_worksheet->add_new_range( ).
|
||||
lo_range->name = 'A_range_with_sheet_visibility'.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'E'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 5 ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'E' ip_value = 'Range Value 3' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'E' ip_value = 'Range Value 4' ).
|
||||
" issue #163
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_excel8.prog.xml
Normal file
32
src/zdemo_excel8.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL8</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Define a range</ENTRY>
|
||||
<LENGTH>31</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
203
src/zdemo_excel9.prog.abap
Normal file
203
src/zdemo_excel9.prog.abap
Normal file
|
@ -0,0 +1,203 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_EXCEL9
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*& abap2xlsx Demo: Data validations
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_excel9.
|
||||
|
||||
CONSTANTS: c_fruits TYPE string VALUE 'Fruits',
|
||||
c_vegetables TYPE string VALUE 'Vegetables',
|
||||
c_meat TYPE string VALUE 'Meat',
|
||||
c_fish TYPE string VALUE 'Fish'.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_range TYPE REF TO zcl_excel_range,
|
||||
lo_data_validation TYPE REF TO zcl_excel_data_validation.
|
||||
|
||||
DATA: row TYPE zexcel_cell_row.
|
||||
|
||||
|
||||
DATA: lv_title TYPE zexcel_sheet_title.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '09_DataValidation.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
PARAMETERS: p_sbook TYPE flag.
|
||||
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lv_title = 'Data Validation'.
|
||||
lo_worksheet->set_title( lv_title ).
|
||||
" Set values for dropdown
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = c_fish ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Anchovy' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'A' ip_value = 'Carp' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'A' ip_value = 'Catfish' ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'A' ip_value = 'Cod' ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'A' ip_value = 'Eel' ).
|
||||
lo_worksheet->set_cell( ip_row = 9 ip_column = 'A' ip_value = 'Haddock' ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = c_fish.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'A'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'A'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'B' ip_value = c_meat ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'Pork' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 'Beef' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 'Chicken' ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 'Turkey' ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = c_meat.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'B'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 7 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'C' ip_value = c_fruits ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'Apple' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 'Banana' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 'Blueberry' ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Ananas' ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Grapes' ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = c_fruits.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'D' ip_value = c_vegetables ).
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'D' ip_value = 'Cucumber' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'D' ip_value = 'Sweet pepper ' ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'D' ip_value = 'Lettuce' ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = c_vegetables.
|
||||
lo_range->set_value( ip_sheet_name = lv_title
|
||||
ip_start_column = 'D'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 6 ).
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lv_title = 'Table with Data Validation'.
|
||||
lo_worksheet->set_title( lv_title ).
|
||||
|
||||
" Maximum Text length
|
||||
lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = 'Validate Maximum Text length of <= 10 in Cell A2:' ).
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = 'abcdefghij' ).
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_textlength.
|
||||
lo_data_validation->operator = zcl_excel_data_validation=>c_operator_lessthanorequal.
|
||||
lo_data_validation->formula1 = 10.
|
||||
lo_data_validation->cell_row = 2.
|
||||
lo_data_validation->cell_column = 'A'.
|
||||
|
||||
" Integer Value between 1 and 10
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Validate Integer Value between 1 and 10 in Cell A5:' ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'A' ip_value = '5' ).
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_whole.
|
||||
lo_data_validation->operator = zcl_excel_data_validation=>c_operator_between.
|
||||
lo_data_validation->formula1 = 1.
|
||||
lo_data_validation->formula2 = 10.
|
||||
lo_data_validation->prompttitle = 'Range'.
|
||||
lo_data_validation->prompt = 'Enter a value between 1 and 10'.
|
||||
lo_data_validation->errortitle = 'Error'.
|
||||
lo_data_validation->error = 'You have entered a wrong value. Please use only numbers between 1 and 10.'.
|
||||
lo_data_validation->cell_row = 5.
|
||||
lo_data_validation->cell_column = 'A'.
|
||||
|
||||
" Evaluation by Formula from issue #161
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'A' ip_value = 'Validate if B8 contains a "-":' ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'A' ip_value = 'Text' ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = '-' ).
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_custom.
|
||||
lo_data_validation->formula1 = '"IF(B8<>"""";INDIRECT(LEFT(B8;SEARCH(""-"";B8;1)));EMPTY)"'.
|
||||
lo_data_validation->cell_row = 8.
|
||||
lo_data_validation->cell_column = 'A'.
|
||||
|
||||
" There was an error when data validation was combined with cell merges this should test that:
|
||||
lo_worksheet->set_cell( ip_row = 10 ip_column = 'A' ip_value = 'Demo for data validation with a dropdown list' ).
|
||||
lo_worksheet->set_merge( ip_row = 10 ip_column_start = 'A' ip_column_end = 'F' ).
|
||||
|
||||
" Headlines
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'A' ip_value = c_fruits ).
|
||||
lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = c_vegetables ).
|
||||
|
||||
row = 12.
|
||||
WHILE row < 20. " Starting with 14500 the data validation is dropped 14000 are still ok
|
||||
" 1st validation
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = c_fruits.
|
||||
lo_data_validation->cell_row = row.
|
||||
lo_data_validation->cell_column = 'A'.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'A' ip_value = 'Select a value' ).
|
||||
" 2nd
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = c_vegetables.
|
||||
lo_data_validation->cell_row = row.
|
||||
lo_data_validation->cell_column = 'B'.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'B' ip_value = 'Select a value' ).
|
||||
" 3rd
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = c_meat.
|
||||
lo_data_validation->cell_row = row.
|
||||
lo_data_validation->cell_column = 'C'.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'C' ip_value = 'Select a value' ).
|
||||
" 4th
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = c_fish.
|
||||
lo_data_validation->cell_row = row.
|
||||
lo_data_validation->cell_column = 'D'.
|
||||
lo_worksheet->set_cell( ip_row = row ip_column = 'D' ip_value = 'Select a value' ).
|
||||
" Increment row
|
||||
row = row + 1.
|
||||
ENDWHILE.
|
||||
|
||||
IF p_sbook = abap_true.
|
||||
DATA: bookings type TABLE OF sbook.
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lv_title = 'SBOOK'.
|
||||
lo_worksheet->set_title( lv_title ).
|
||||
|
||||
SELECT * from sbook INTO TABLE bookings UP TO 4000 ROWS.
|
||||
|
||||
lo_worksheet->bind_table(
|
||||
EXPORTING
|
||||
ip_table = bookings
|
||||
* it_field_catalog = " Table binding field catalog
|
||||
* is_table_settings = " Excel table binding settings
|
||||
* IMPORTING
|
||||
* es_table_settings = " Excel table binding settings
|
||||
).
|
||||
ENDIF.
|
||||
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
38
src/zdemo_excel9.prog.xml
Normal file
38
src/zdemo_excel9.prog.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL9</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Data validations</ENTRY>
|
||||
<LENGTH>33</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_SBOOK</KEY>
|
||||
<ENTRY>Export SBOOK to Excel?</ENTRY>
|
||||
<LENGTH>30</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
372
src/zdemo_excel_outputopt_incl.prog.abap
Normal file
372
src/zdemo_excel_outputopt_incl.prog.abap
Normal file
|
@ -0,0 +1,372 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZDEMO_EXCEL_OUTPUTOPT_INCL
|
||||
*&---------------------------------------------------------------------*
|
||||
CLASS lcl_output DEFINITION CREATE PRIVATE.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS:
|
||||
output IMPORTING cl_excel TYPE REF TO zcl_excel
|
||||
iv_writerclass_name TYPE clike OPTIONAL,
|
||||
f4_path RETURNING VALUE(selected_folder) TYPE string,
|
||||
parametertexts.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS:
|
||||
download_frontend,
|
||||
download_backend,
|
||||
display_online,
|
||||
send_email.
|
||||
|
||||
DATA: xdata TYPE xstring, " Will be used for sending as email
|
||||
t_rawdata TYPE solix_tab, " Will be used for downloading or open directly
|
||||
bytecount TYPE i. " Will be used for downloading or open directly
|
||||
ENDCLASS. "lcl_output DEFINITION
|
||||
|
||||
|
||||
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE txt_bl1.
|
||||
PARAMETERS: rb_down RADIOBUTTON GROUP rb1 USER-COMMAND space.
|
||||
|
||||
PARAMETERS: rb_back RADIOBUTTON GROUP rb1.
|
||||
|
||||
PARAMETERS: rb_show RADIOBUTTON GROUP rb1 DEFAULT 'X' .
|
||||
|
||||
PARAMETERS: rb_send RADIOBUTTON GROUP rb1.
|
||||
|
||||
PARAMETERS: p_path TYPE string LOWER CASE MODIF ID pat.
|
||||
PARAMETERS: p_email TYPE string LOWER CASE MODIF ID ema OBLIGATORY DEFAULT 'insert_your_emailadress@here'.
|
||||
PARAMETERS: p_backfn TYPE text40 NO-DISPLAY.
|
||||
SELECTION-SCREEN END OF BLOCK bl1.
|
||||
|
||||
|
||||
AT SELECTION-SCREEN OUTPUT.
|
||||
LOOP AT SCREEN.
|
||||
|
||||
IF rb_down IS INITIAL AND screen-group1 = 'PAT'.
|
||||
screen-input = 0.
|
||||
screen-invisible = 1.
|
||||
ENDIF.
|
||||
|
||||
IF rb_send IS INITIAL AND screen-group1 = 'EMA'.
|
||||
screen-input = 0.
|
||||
screen-invisible = 1.
|
||||
ENDIF.
|
||||
|
||||
MODIFY SCREEN.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
INITIALIZATION.
|
||||
IF sy-batch IS INITIAL.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = p_path ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
ENDIF.
|
||||
lcl_output=>parametertexts( ). " If started in language w/o textelements translated set defaults
|
||||
sy-title = gc_save_file_name.
|
||||
txt_bl1 = 'Output options'(bl1).
|
||||
p_backfn = gc_save_file_name. " Use as default if nothing else is supplied by submit
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
p_path = lcl_output=>f4_path( ).
|
||||
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS lcl_output IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_output IMPLEMENTATION.
|
||||
METHOD output.
|
||||
|
||||
DATA: cl_output TYPE REF TO lcl_output,
|
||||
cl_writer TYPE REF TO zif_excel_writer.
|
||||
|
||||
IF iv_writerclass_name IS INITIAL.
|
||||
CREATE OBJECT cl_output.
|
||||
CREATE OBJECT cl_writer TYPE zcl_excel_writer_2007.
|
||||
ELSE.
|
||||
CREATE OBJECT cl_output.
|
||||
CREATE OBJECT cl_writer TYPE (iv_writerclass_name).
|
||||
ENDIF.
|
||||
cl_output->xdata = cl_writer->write_file( cl_excel ).
|
||||
|
||||
* After 6.40 via cl_bcs_convert
|
||||
cl_output->t_rawdata = cl_bcs_convert=>xstring_to_solix( iv_xstring = cl_output->xdata ).
|
||||
cl_output->bytecount = xstrlen( cl_output->xdata ).
|
||||
|
||||
* before 6.40
|
||||
* CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
* EXPORTING
|
||||
* buffer = cl_output->xdata
|
||||
* IMPORTING
|
||||
* output_length = cl_output->bytecount
|
||||
* TABLES
|
||||
* binary_tab = cl_output->t_rawdata.
|
||||
|
||||
CASE 'X'.
|
||||
WHEN rb_down.
|
||||
IF sy-batch IS INITIAL.
|
||||
cl_output->download_frontend( ).
|
||||
ELSE.
|
||||
MESSAGE e001(00) WITH 'Frontenddownload impossible in background processing'.
|
||||
ENDIF.
|
||||
|
||||
WHEN rb_back.
|
||||
cl_output->download_backend( ).
|
||||
|
||||
WHEN rb_show.
|
||||
IF sy-batch IS INITIAL.
|
||||
cl_output->display_online( ).
|
||||
ELSE.
|
||||
MESSAGE e001(00) WITH 'Online display absurd in background processing'.
|
||||
ENDIF.
|
||||
|
||||
WHEN rb_send.
|
||||
cl_output->send_email( ).
|
||||
|
||||
ENDCASE.
|
||||
ENDMETHOD. "output
|
||||
|
||||
METHOD f4_path.
|
||||
DATA: new_path TYPE string,
|
||||
repid TYPE syrepid,
|
||||
dynnr TYPE sydynnr,
|
||||
lt_dynpfields TYPE TABLE OF dynpread,
|
||||
ls_dynpfields LIKE LINE OF lt_dynpfields.
|
||||
|
||||
* Get current value
|
||||
dynnr = sy-dynnr.
|
||||
repid = sy-repid.
|
||||
ls_dynpfields-fieldname = 'P_PATH'.
|
||||
APPEND ls_dynpfields TO lt_dynpfields.
|
||||
|
||||
CALL FUNCTION 'DYNP_VALUES_READ'
|
||||
EXPORTING
|
||||
dyname = repid
|
||||
dynumb = dynnr
|
||||
TABLES
|
||||
dynpfields = lt_dynpfields
|
||||
EXCEPTIONS
|
||||
invalid_abapworkarea = 1
|
||||
invalid_dynprofield = 2
|
||||
invalid_dynproname = 3
|
||||
invalid_dynpronummer = 4
|
||||
invalid_request = 5
|
||||
no_fielddescription = 6
|
||||
invalid_parameter = 7
|
||||
undefind_error = 8
|
||||
double_conversion = 9
|
||||
stepl_not_found = 10
|
||||
OTHERS = 11.
|
||||
IF sy-subrc <> 0.
|
||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_dynpfields INTO ls_dynpfields INDEX 1.
|
||||
|
||||
new_path = ls_dynpfields-fieldvalue.
|
||||
selected_folder = new_path.
|
||||
|
||||
cl_gui_frontend_services=>directory_browse(
|
||||
EXPORTING
|
||||
window_title = 'Select path to download EXCEL-file'
|
||||
initial_folder = new_path
|
||||
CHANGING
|
||||
selected_folder = new_path
|
||||
EXCEPTIONS
|
||||
cntl_error = 1
|
||||
error_no_gui = 2
|
||||
not_supported_by_gui = 3
|
||||
OTHERS = 4
|
||||
).
|
||||
cl_gui_cfw=>flush( ).
|
||||
CHECK new_path IS NOT INITIAL.
|
||||
selected_folder = new_path.
|
||||
|
||||
ENDMETHOD. "f4_path
|
||||
|
||||
METHOD parametertexts.
|
||||
* If started in language w/o textelements translated set defaults
|
||||
* Furthermore I don't have to change the selectiontexts of all demoreports.
|
||||
DEFINE default_parametertext.
|
||||
if %_&1_%_app_%-text = '&1' or
|
||||
%_&1_%_app_%-text is initial.
|
||||
%_&1_%_app_%-text = &2.
|
||||
endif.
|
||||
END-OF-DEFINITION.
|
||||
|
||||
default_parametertext: rb_down 'Save to frontend',
|
||||
rb_back 'Save to backend',
|
||||
rb_show 'Direct display',
|
||||
rb_send 'Send via email',
|
||||
|
||||
p_path 'Frontend-path to download to',
|
||||
p_email 'Email to send xlsx to'.
|
||||
|
||||
ENDMETHOD. "parametertexts
|
||||
|
||||
METHOD: download_frontend.
|
||||
DATA: filename TYPE string.
|
||||
* I don't like p_path here - but for this include it's ok
|
||||
filename = p_path.
|
||||
* Add trailing "\" or "/"
|
||||
IF filename CA '/'.
|
||||
REPLACE REGEX '([^/])\s*$' IN filename WITH '$1/' .
|
||||
ELSE.
|
||||
REPLACE REGEX '([^\\])\s*$' IN filename WITH '$1\\'.
|
||||
ENDIF.
|
||||
|
||||
CONCATENATE filename gc_save_file_name INTO filename.
|
||||
* Get trailing blank
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = bytecount
|
||||
filename = filename
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = t_rawdata ).
|
||||
ENDMETHOD. "download_frontend
|
||||
|
||||
METHOD download_backend.
|
||||
DATA: bytes_remain TYPE i.
|
||||
FIELD-SYMBOLS: <rawdata> LIKE LINE OF t_rawdata.
|
||||
|
||||
OPEN DATASET p_backfn FOR OUTPUT IN BINARY MODE.
|
||||
CHECK sy-subrc = 0.
|
||||
|
||||
bytes_remain = bytecount.
|
||||
|
||||
LOOP AT t_rawdata ASSIGNING <rawdata>.
|
||||
|
||||
AT LAST.
|
||||
CHECK bytes_remain >= 0.
|
||||
TRANSFER <rawdata> TO p_backfn LENGTH bytes_remain.
|
||||
EXIT.
|
||||
ENDAT.
|
||||
|
||||
TRANSFER <rawdata> TO p_backfn.
|
||||
SUBTRACT 255 FROM bytes_remain. " Solix has length 255
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
CLOSE DATASET p_backfn.
|
||||
|
||||
|
||||
|
||||
|
||||
IF sy-repid <> sy-cprog AND sy-cprog IS NOT INITIAL. " no need to display anything if download was selected and report was called for demo purposes
|
||||
LEAVE PROGRAM.
|
||||
ELSE.
|
||||
MESSAGE 'Data transferred to default backend directory' TYPE 'S'.
|
||||
ENDIF.
|
||||
ENDMETHOD. "download_backend
|
||||
|
||||
METHOD display_online.
|
||||
DATA:error TYPE REF TO i_oi_error,
|
||||
t_errors TYPE STANDARD TABLE OF REF TO i_oi_error WITH NON-UNIQUE DEFAULT KEY,
|
||||
cl_control TYPE REF TO i_oi_container_control, "OIContainerCtrl
|
||||
cl_document TYPE REF TO i_oi_document_proxy. "Office Dokument
|
||||
|
||||
c_oi_container_control_creator=>get_container_control( IMPORTING control = cl_control
|
||||
error = error ).
|
||||
APPEND error TO t_errors.
|
||||
|
||||
cl_control->init_control( EXPORTING inplace_enabled = 'X'
|
||||
no_flush = 'X'
|
||||
r3_application_name = 'Demo Document Container'
|
||||
parent = cl_gui_container=>screen0
|
||||
IMPORTING error = error
|
||||
EXCEPTIONS OTHERS = 2 ).
|
||||
APPEND error TO t_errors.
|
||||
|
||||
cl_control->get_document_proxy( EXPORTING document_type = 'Excel.Sheet' " EXCEL
|
||||
no_flush = ' '
|
||||
IMPORTING document_proxy = cl_document
|
||||
error = error ).
|
||||
APPEND error TO t_errors.
|
||||
* Errorhandling should be inserted here
|
||||
|
||||
cl_document->open_document_from_table( EXPORTING document_size = bytecount
|
||||
document_table = t_rawdata
|
||||
open_inplace = 'X' ).
|
||||
|
||||
WRITE: '.'. " To create an output. That way screen0 will exist
|
||||
ENDMETHOD. "display_online
|
||||
|
||||
METHOD send_email.
|
||||
* Needed to send emails
|
||||
DATA: bcs_exception TYPE REF TO cx_bcs,
|
||||
errortext TYPE string,
|
||||
cl_send_request TYPE REF TO cl_bcs,
|
||||
cl_document TYPE REF TO cl_document_bcs,
|
||||
cl_recipient TYPE REF TO if_recipient_bcs,
|
||||
cl_sender TYPE REF TO cl_cam_address_bcs,
|
||||
t_attachment_header TYPE soli_tab,
|
||||
wa_attachment_header LIKE LINE OF t_attachment_header,
|
||||
attachment_subject TYPE sood-objdes,
|
||||
|
||||
sood_bytecount TYPE sood-objlen,
|
||||
mail_title TYPE so_obj_des,
|
||||
t_mailtext TYPE soli_tab,
|
||||
wa_mailtext LIKE LINE OF t_mailtext,
|
||||
send_to TYPE adr6-smtp_addr,
|
||||
sent TYPE os_boolean.
|
||||
|
||||
|
||||
mail_title = 'Mail title'.
|
||||
wa_mailtext = 'Mailtext'.
|
||||
APPEND wa_mailtext TO t_mailtext.
|
||||
|
||||
TRY.
|
||||
* Create send request
|
||||
cl_send_request = cl_bcs=>create_persistent( ).
|
||||
* Create new document with mailtitle and mailtextg
|
||||
cl_document = cl_document_bcs=>create_document( i_type = 'RAW' "#EC NOTEXT
|
||||
i_text = t_mailtext
|
||||
i_subject = mail_title ).
|
||||
* Add attachment to document
|
||||
* since the new excelfiles have an 4-character extension .xlsx but the attachment-type only holds 3 charactes .xls,
|
||||
* we have to specify the real filename via attachment header
|
||||
* Use attachment_type xls to have SAP display attachment with the excel-icon
|
||||
attachment_subject = gc_save_file_name.
|
||||
CONCATENATE '&SO_FILENAME=' attachment_subject INTO wa_attachment_header.
|
||||
APPEND wa_attachment_header TO t_attachment_header.
|
||||
* Attachment
|
||||
sood_bytecount = bytecount. " next method expects sood_bytecount instead of any positive integer *sigh*
|
||||
cl_document->add_attachment( i_attachment_type = 'XLS' "#EC NOTEXT
|
||||
i_attachment_subject = attachment_subject
|
||||
i_attachment_size = sood_bytecount
|
||||
i_att_content_hex = t_rawdata
|
||||
i_attachment_header = t_attachment_header ).
|
||||
|
||||
* add document to send request
|
||||
cl_send_request->set_document( cl_document ).
|
||||
|
||||
* set sender in case if no own email is availabe
|
||||
* cl_sender = cl_cam_address_bcs=>create_internet_address( 'sender@sender.sender' ).
|
||||
* cl_send_request->set_sender( cl_sender ).
|
||||
|
||||
* add recipient(s) - here only 1 will be needed
|
||||
send_to = p_email.
|
||||
IF send_to IS INITIAL.
|
||||
send_to = 'no_email@no_email.no_email'. " Place into SOST in any case for demonstration purposes
|
||||
ENDIF.
|
||||
cl_recipient = cl_cam_address_bcs=>create_internet_address( send_to ).
|
||||
cl_send_request->add_recipient( cl_recipient ).
|
||||
|
||||
* Und abschicken
|
||||
sent = cl_send_request->send( i_with_error_screen = 'X' ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
IF sent IS INITIAL.
|
||||
MESSAGE i500(sbcoms) WITH p_email.
|
||||
ELSE.
|
||||
MESSAGE s022(so).
|
||||
MESSAGE 'Document ready to be sent - Check SOST or SCOT' TYPE 'I'.
|
||||
ENDIF.
|
||||
|
||||
CATCH cx_bcs INTO bcs_exception.
|
||||
errortext = bcs_exception->if_message~get_text( ).
|
||||
MESSAGE errortext TYPE 'I'.
|
||||
|
||||
ENDTRY.
|
||||
ENDMETHOD. "send_email
|
||||
|
||||
|
||||
ENDCLASS. "lcl_output IMPLEMENTATION
|
22
src/zdemo_excel_outputopt_incl.prog.xml
Normal file
22
src/zdemo_excel_outputopt_incl.prog.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_EXCEL_OUTPUTOPT_INCL</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>I</SUBC>
|
||||
<RLOAD>E</RLOAD>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>Include ZDEMO_EXCEL_OUTPUTOPT_INCL</ENTRY>
|
||||
<LENGTH>34</LENGTH>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
83
src/zdemo_teched1.prog.abap
Normal file
83
src/zdemo_teched1.prog.abap
Normal file
|
@ -0,0 +1,83 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_TECHED1
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_teched1.
|
||||
|
||||
*******************************
|
||||
* Data Object declaration *
|
||||
*******************************
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'TechEd01.xlsx'.
|
||||
|
||||
*******************************
|
||||
* Selection screen management *
|
||||
*******************************
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
|
||||
*******************************
|
||||
* abap2xlsx create XLSX *
|
||||
*******************************
|
||||
|
||||
" Create excel instance
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo01' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
|
||||
" Create xlsx stream
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
*******************************
|
||||
* Output *
|
||||
*******************************
|
||||
|
||||
" Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zdemo_teched1.prog.xml
Normal file
32
src/zdemo_teched1.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_TECHED1</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
49
src/zdemo_teched10.prog.abap
Normal file
49
src/zdemo_teched10.prog.abap
Normal file
|
@ -0,0 +1,49 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_TECHED3
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_teched3.
|
||||
|
||||
*******************************
|
||||
* Data Object declaration *
|
||||
*******************************
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_reader TYPE REF TO zif_excel_reader,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
DATA: lt_files TYPE filetable,
|
||||
ls_file TYPE file_table,
|
||||
lv_rc TYPE i,
|
||||
lv_value TYPE zexcel_cell_value.
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE 'TechEd01.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
*******************************
|
||||
* abap2xlsx read XLSX *
|
||||
*******************************
|
||||
CREATE OBJECT lo_excel_reader TYPE zcl_excel_reader_2007.
|
||||
lo_excel = lo_excel_reader->load_file( lv_full_path ).
|
||||
|
||||
lo_excel->set_active_sheet_index( 1 ).
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
lo_worksheet->get_cell( EXPORTING ip_column = 'C'
|
||||
ip_row = 10
|
||||
IMPORTING ep_value = lv_value ).
|
||||
|
||||
WRITE: 'abap2xlsx total score is ', lv_value.
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).
|
32
src/zdemo_teched10.prog.xml
Normal file
32
src/zdemo_teched10.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_TECHED10</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
91
src/zdemo_teched2.prog.abap
Normal file
91
src/zdemo_teched2.prog.abap
Normal file
|
@ -0,0 +1,91 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_TECHED2
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_teched2.
|
||||
|
||||
*******************************
|
||||
* Data Object declaration *
|
||||
*******************************
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lo_style_title TYPE REF TO zcl_excel_style,
|
||||
lv_style_title_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'TechEd01.xlsx'.
|
||||
|
||||
*******************************
|
||||
* Selection screen management *
|
||||
*******************************
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
*******************************
|
||||
* abap2xlsx create XLSX *
|
||||
*******************************
|
||||
|
||||
" Create excel instance
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Styles
|
||||
lo_style_title = lo_excel->add_new_style( ).
|
||||
lo_style_title->font->bold = abap_true.
|
||||
lo_style_title->font->color-rgb = zcl_excel_style_color=>c_blue.
|
||||
lv_style_title_guid = lo_style_title->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo TechEd' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'TechEd demo' ip_style = lv_style_title_guid ).
|
||||
|
||||
" Create xlsx stream
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
*******************************
|
||||
* Output *
|
||||
*******************************
|
||||
|
||||
" Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zdemo_teched2.prog.xml
Normal file
32
src/zdemo_teched2.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_TECHED2</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
107
src/zdemo_teched3.prog.abap
Normal file
107
src/zdemo_teched3.prog.abap
Normal file
|
@ -0,0 +1,107 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_TECHED3
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_teched3.
|
||||
|
||||
*******************************
|
||||
* Data Object declaration *
|
||||
*******************************
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lo_style_title TYPE REF TO zcl_excel_style,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing,
|
||||
lv_style_title_guid TYPE zexcel_cell_style,
|
||||
ls_key TYPE wwwdatatab.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'TechEd01.xlsx'.
|
||||
|
||||
*******************************
|
||||
* Selection screen management *
|
||||
*******************************
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
*******************************
|
||||
* abap2xlsx create XLSX *
|
||||
*******************************
|
||||
|
||||
" Create excel instance
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Styles
|
||||
lo_style_title = lo_excel->add_new_style( ).
|
||||
lo_style_title->font->bold = abap_true.
|
||||
lo_style_title->font->color-rgb = zcl_excel_style_color=>c_blue.
|
||||
lv_style_title_guid = lo_style_title->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo TechEd' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'TechEd demo' ip_style = lv_style_title_guid ).
|
||||
|
||||
" add logo from SMWO
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 2
|
||||
ip_from_col = 'B' ).
|
||||
|
||||
ls_key-relid = 'MI'.
|
||||
ls_key-objid = 'WBLOGO'.
|
||||
lo_drawing->set_media_www( ip_key = ls_key
|
||||
ip_width = 140
|
||||
ip_height = 64 ).
|
||||
|
||||
" assign drawing to the worksheet
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" Create xlsx stream
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
*******************************
|
||||
* Output *
|
||||
*******************************
|
||||
|
||||
" Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zdemo_teched3.prog.xml
Normal file
32
src/zdemo_teched3.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_TECHED3</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
129
src/zdemo_teched4.prog.abap
Normal file
129
src/zdemo_teched4.prog.abap
Normal file
|
@ -0,0 +1,129 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_TECHED3
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_teched3.
|
||||
|
||||
*******************************
|
||||
* Data Object declaration *
|
||||
*******************************
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lo_style_title TYPE REF TO zcl_excel_style,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing,
|
||||
lo_range TYPE REF TO zcl_excel_range,
|
||||
lv_style_title_guid TYPE zexcel_cell_style,
|
||||
ls_key TYPE wwwdatatab.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'TechEd01.xlsx'.
|
||||
|
||||
*******************************
|
||||
* Selection screen management *
|
||||
*******************************
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
*******************************
|
||||
* abap2xlsx create XLSX *
|
||||
*******************************
|
||||
|
||||
" Create excel instance
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Styles
|
||||
lo_style_title = lo_excel->add_new_style( ).
|
||||
lo_style_title->font->bold = abap_true.
|
||||
lo_style_title->font->color-rgb = zcl_excel_style_color=>c_blue.
|
||||
lv_style_title_guid = lo_style_title->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo TechEd' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'TechEd demo' ip_style = lv_style_title_guid ).
|
||||
|
||||
" add logo from SMWO
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 2
|
||||
ip_from_col = 'B' ).
|
||||
|
||||
ls_key-relid = 'MI'.
|
||||
ls_key-objid = 'WBLOGO'.
|
||||
lo_drawing->set_media_www( ip_key = ls_key
|
||||
ip_width = 140
|
||||
ip_height = 64 ).
|
||||
|
||||
" assign drawing to the worksheet
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" Add new sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Values' ).
|
||||
|
||||
" Set values for range
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 1 ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'A' ip_value = 2 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'A' ip_value = 3 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'A' ip_value = 4 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'A' ip_value = 5 ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'Values'.
|
||||
lo_range->set_value( ip_sheet_name = 'Values'
|
||||
ip_start_column = 'A'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'A'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
lo_excel->set_active_sheet_index( 1 ).
|
||||
|
||||
" Create xlsx stream
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
*******************************
|
||||
* Output *
|
||||
*******************************
|
||||
|
||||
" Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zdemo_teched4.prog.xml
Normal file
32
src/zdemo_teched4.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_TECHED4</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
150
src/zdemo_teched5.prog.abap
Normal file
150
src/zdemo_teched5.prog.abap
Normal file
|
@ -0,0 +1,150 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Report ZDEMO_TECHED3
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
*&
|
||||
*&
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
REPORT zdemo_teched3.
|
||||
|
||||
*******************************
|
||||
* Data Object declaration *
|
||||
*******************************
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
||||
|
||||
DATA: lo_style_title TYPE REF TO zcl_excel_style,
|
||||
lo_drawing TYPE REF TO zcl_excel_drawing,
|
||||
lo_range TYPE REF TO zcl_excel_range,
|
||||
lo_data_validation TYPE REF TO zcl_excel_data_validation,
|
||||
lv_style_title_guid TYPE zexcel_cell_style,
|
||||
ls_key TYPE wwwdatatab.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
DATA: lv_full_path TYPE string,
|
||||
lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE 'TechEd01.xlsx'.
|
||||
|
||||
*******************************
|
||||
* Selection screen management *
|
||||
*******************************
|
||||
|
||||
PARAMETERS: p_path TYPE zexcel_export_dir.
|
||||
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
lv_workdir = p_path.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir
|
||||
CHANGING selected_folder = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
cl_gui_cfw=>flush( ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
|
||||
|
||||
*******************************
|
||||
* abap2xlsx create XLSX *
|
||||
*******************************
|
||||
|
||||
" Create excel instance
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Styles
|
||||
lo_style_title = lo_excel->add_new_style( ).
|
||||
lo_style_title->font->bold = abap_true.
|
||||
lo_style_title->font->color-rgb = zcl_excel_style_color=>c_blue.
|
||||
lv_style_title_guid = lo_style_title->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Demo TechEd' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'TechEd demo' ip_style = lv_style_title_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 7 ip_value = 'Is abap2xlsx simple' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 8 ip_value = 'Is abap2xlsx CooL' ).
|
||||
|
||||
" add logo from SMWO
|
||||
lo_drawing = lo_excel->add_new_drawing( ).
|
||||
lo_drawing->set_position( ip_from_row = 2
|
||||
ip_from_col = 'B' ).
|
||||
|
||||
ls_key-relid = 'MI'.
|
||||
ls_key-objid = 'WBLOGO'.
|
||||
lo_drawing->set_media_www( ip_key = ls_key
|
||||
ip_width = 140
|
||||
ip_height = 64 ).
|
||||
|
||||
" assign drawing to the worksheet
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
" Add new sheet
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Values' ).
|
||||
|
||||
" Set values for range
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 1 ).
|
||||
lo_worksheet->set_cell( ip_row = 5 ip_column = 'A' ip_value = 2 ).
|
||||
lo_worksheet->set_cell( ip_row = 6 ip_column = 'A' ip_value = 3 ).
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'A' ip_value = 4 ).
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'A' ip_value = 5 ).
|
||||
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'Values'.
|
||||
lo_range->set_value( ip_sheet_name = 'Values'
|
||||
ip_start_column = 'A'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'A'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
lo_excel->set_active_sheet_index( 1 ).
|
||||
|
||||
" add data validation
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = 'Values'.
|
||||
lo_data_validation->cell_row = 7.
|
||||
lo_data_validation->cell_column = 'C'.
|
||||
lo_worksheet->set_cell( ip_row = 7 ip_column = 'C' ip_value = 'Select a value' ).
|
||||
|
||||
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->type = zcl_excel_data_validation=>c_type_list.
|
||||
lo_data_validation->formula1 = 'Values'.
|
||||
lo_data_validation->cell_row = 8.
|
||||
lo_data_validation->cell_column = 'C'.
|
||||
lo_worksheet->set_cell( ip_row = 8 ip_column = 'C' ip_value = 'Select a value' ).
|
||||
|
||||
" Create xlsx stream
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
*******************************
|
||||
* Output *
|
||||
*******************************
|
||||
|
||||
" Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = lv_full_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
32
src/zdemo_teched5.prog.xml
Normal file
32
src/zdemo_teched5.prog.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZDEMO_TECHED5</NAME>
|
||||
<STATE>A</STATE>
|
||||
<VARCL>X</VARCL>
|
||||
<SUBC>1</SUBC>
|
||||
<RSTAT>T</RSTAT>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT>X</FIXPT>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<DYNPROS/>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<ENTRY>abap2xlsx Demo: Hello World</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
</item>
|
||||
<item>
|
||||
<ID>S</ID>
|
||||
<KEY>P_PATH</KEY>
|
||||
<ENTRY>.</ENTRY>
|
||||
<LENGTH>9</LENGTH>
|
||||
<SPLIT>D</SPLIT>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user