mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-04 20:19:46 +08:00
Demo reports have no longer fixed output
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@22 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
parent
e6f84e7b51
commit
72b99e10da
|
@ -1,8 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100817" UNAM="FEMIA" UDAT="20100923" VERN="000018" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100923" STIME="233645" IDATE="20100923" ITIME="233645" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100817" UNAM="FEMIA" UDAT="20100924" VERN="000023" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153901" IDATE="20100924" ITIME="153901" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Run all ABAP2XLSX Demo Programs" LENGTH="31 "/>
|
||||
<textElement ID="S" KEY="P_PATH" ENTRY=" Select output path" LENGTH="26 "/>
|
||||
</language>
|
||||
</textPool>
|
||||
<source>*&---------------------------------------------------------------------*
|
||||
|
@ -15,23 +16,42 @@
|
|||
|
||||
REPORT zdemo_excel.
|
||||
|
||||
SUBMIT zdemo_excel1 AND RETURN. " Hello world
|
||||
SUBMIT zdemo_excel2 AND RETURN. " Styles
|
||||
SUBMIT zdemo_excel3 AND RETURN. " iTab binding
|
||||
SUBMIT zdemo_excel4 AND RETURN. " Multi sheets and page setup
|
||||
SUBMIT zdemo_excel5 AND RETURN. " Conditional formatting
|
||||
SUBMIT zdemo_excel6 AND RETURN. " Formulas
|
||||
SUBMIT zdemo_excel7 AND RETURN. " Conditional formatting
|
||||
SUBMIT zdemo_excel8 AND RETURN. " Ranges
|
||||
SUBMIT zdemo_excel9 AND RETURN. " Data validation
|
||||
SUBMIT zdemo_excel10 AND RETURN. " 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 AND RETURN. " Column size
|
||||
SUBMIT zdemo_excel13 AND RETURN. " Merge cell
|
||||
SUBMIT zdemo_excel14 AND RETURN. " Alignment
|
||||
SUBMIT zdemo_excel15 AND RETURN. " Read Excel and write it back
|
||||
SUBMIT zdemo_excel16 AND RETURN. " Read Excel and write it back
|
||||
SUBMIT zdemo_excel17 AND RETURN. " Lock sheet
|
||||
SUBMIT zdemo_excel18 AND RETURN. " Lock workbook</source>
|
||||
DATA: lv_workdir TYPE string.
|
||||
|
||||
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 ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
START-OF-SELECTION.
|
||||
|
||||
IF p_path IS INITIAL.
|
||||
p_path = lv_workdir.
|
||||
ENDIF.
|
||||
|
||||
SUBMIT zdemo_excel1 with p_path = p_path AND RETURN. " Hello world
|
||||
SUBMIT zdemo_excel2 with p_path = p_path AND RETURN. " Styles
|
||||
SUBMIT zdemo_excel3 with p_path = p_path AND RETURN. " iTab binding
|
||||
SUBMIT zdemo_excel4 with p_path = p_path AND RETURN. " Multi sheets and page setup
|
||||
SUBMIT zdemo_excel5 with p_path = p_path AND RETURN. " Conditional formatting
|
||||
SUBMIT zdemo_excel6 with p_path = p_path AND RETURN. " Formulas
|
||||
SUBMIT zdemo_excel7 with p_path = p_path AND RETURN. " Conditional formatting
|
||||
SUBMIT zdemo_excel8 with p_path = p_path AND RETURN. " Ranges
|
||||
SUBMIT zdemo_excel9 with p_path = p_path AND RETURN. " Data validation
|
||||
SUBMIT zdemo_excel10 with p_path = p_path AND RETURN. " 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 p_path = p_path AND RETURN. " Column size
|
||||
SUBMIT zdemo_excel13 with p_path = p_path AND RETURN. " Merge cell
|
||||
SUBMIT zdemo_excel14 with p_path = p_path AND RETURN. " Alignment
|
||||
SUBMIT zdemo_excel15 with p_path = p_path AND RETURN. " Read Excel and write it back
|
||||
SUBMIT zdemo_excel16 with p_path = p_path AND RETURN. " Drawing
|
||||
SUBMIT zdemo_excel17 with p_path = p_path AND RETURN. " Lock sheet
|
||||
SUBMIT zdemo_excel18 with p_path = p_path AND RETURN. " Lock workbook</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL1" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100904" VERN="000036" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163357" IDATE="20100904" ITIME="183249" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL1" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000062" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153901" IDATE="20100924" ITIME="153901" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -21,36 +21,55 @@ DATA: lo_excel TYPE REF TO zcl_excel,
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->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 ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '01_HelloWorld.xlsx'.
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\HelloWorld.xlsx'
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->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 ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL10" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100719" UNAM="VONDRUSKA" UDAT="20100917" VERN="000058" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100917" STIME="105913" IDATE="20100917" ITIME="105913" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL10" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100719" UNAM="FEMIA" UDAT="20100924" VERN="000061" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153901" IDATE="20100924" ITIME="153901" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,87 +16,108 @@
|
|||
REPORT zdemo_excel10.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
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_field_catalog TYPE zexcel_s_fieldcatalog,
|
||||
ls_table_settings TYPE zexcel_s_table_settings.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_field_catalog TYPE zexcel_t_fieldcatalog,
|
||||
ls_field_catalog TYPE zexcel_s_fieldcatalog,
|
||||
ls_table_settings TYPE zexcel_s_table_settings,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog.
|
||||
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.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '10_iTabFieldCatalog.xlsx'.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Internal table'.
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
"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->iconset = zcl_excel_style_conditional=>c_iconset_5arrows.
|
||||
lo_style_conditional2->priority = 1.
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
SELECT * FROM sflight INTO TABLE lt_test.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
lt_field_catalog = zcl_excel_common=>get_fieldcatalog( ip_table = lt_test ).
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
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.
|
||||
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.
|
||||
START-OF-SELECTION.
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium5.
|
||||
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 p_path.
|
||||
|
||||
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( 'D' ). "make date field a bit wider
|
||||
column_dimension->set_width( ip_width = 13 ).
|
||||
FIELD-SYMBOLS: <fs_field_catalog> TYPE zexcel_s_fieldcatalog.
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
" Creates active sheet
|
||||
CREATE OBJECT 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.
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Internal table'.
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\iTabFieldCatalog.xlsx'
|
||||
"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->iconset = zcl_excel_style_conditional=>c_iconset_5arrows.
|
||||
lo_style_conditional2->priority = 1.
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
SELECT * FROM sflight INTO TABLE lt_test.
|
||||
|
||||
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.
|
||||
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( 'D' ). "make date field a bit wider
|
||||
column_dimension->set_width( ip_width = 13 ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL11" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100809" UNAM="VONDRUSKA" UDAT="20100917" VERN="000041" RSTAT="K" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100917" STIME="110149" IDATE="20100917" ITIME="110149" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL11" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100809" UNAM="FEMIA" UDAT="20100924" VERN="000043" RSTAT="K" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153901" IDATE="20100924" ITIME="153901" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Export Organisation and Contact Persons using ABAP2XLSX" LENGTH="55 "/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL12" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100811" UNAM="VONDRUSKA" UDAT="20100917" VERN="000024" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100917" STIME="110247" IDATE="20100917" ITIME="110247" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL12" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100811" UNAM="FEMIA" UDAT="20100924" VERN="000027" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Hide Columns" LENGTH="12 "/>
|
||||
|
@ -23,7 +23,35 @@ DATA: lo_excel TYPE REF TO zcl_excel,
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
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 '12_HideSizeOutlineRowsAndColumns.xlsx'.
|
||||
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
@ -75,21 +103,13 @@ row_dimension->set_outline_level( 2 ).
|
|||
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.
|
||||
* Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = xstrlen( lv_file ).
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\HideSizeOutlineRowsAndColumns.xlsx'
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
cl_gui_frontend_services=>gui_download( exporting bin_filesize = lv_bytecount
|
||||
filename = p_path
|
||||
filetype = 'BIN'
|
||||
changing data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL13" VARCL="X" SUBC="1" CNAM="ATEJADA" CDAT="20100812" UNAM="FEMIA" UDAT="20100905" VERN="000018" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="164207" IDATE="20100905" ITIME="164207" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL13" VARCL="X" SUBC="1" CNAM="ATEJADA" CDAT="20100812" UNAM="FEMIA" UDAT="20100924" VERN="000022" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,62 +16,83 @@
|
|||
REPORT zdemo_excel13.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_range TYPE REF TO zcl_excel_range,
|
||||
lv_file TYPE xstring,
|
||||
lv_style_number_guid TYPE zexcel_cell_style,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1,
|
||||
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.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
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.
|
||||
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color = zcl_excel_style_color=>c_black.
|
||||
lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin.
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '13_MergedCells.xlsx'.
|
||||
|
||||
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 = 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( ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = 'Test' ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
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_merge( ip_row = 2 ip_column_start = 'B' ip_column_end = 'G' ).
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Merged_Cells.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 ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO p_path.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color = 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 = 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_merge( ip_row = 2 ip_column_start = 'B' ip_column_end = 'G' ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL14" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100817" UNAM="FEMIA" UDAT="20100912" VERN="000038" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100912" STIME="205336" IDATE="20100912" ITIME="205336" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL14" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100817" UNAM="FEMIA" UDAT="20100924" VERN="000041" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -18,9 +18,6 @@ REPORT zdemo_excel14.
|
|||
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,
|
||||
lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1,
|
||||
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,
|
||||
|
@ -48,121 +45,144 @@ DATA: lo_excel TYPE REF TO zcl_excel,
|
|||
|
||||
DATA: lo_row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '14_Alignment.xlsx'.
|
||||
|
||||
"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( ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
"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( ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
"Indent
|
||||
lo_style_indent = lo_excel->add_new_style( ).
|
||||
lo_style_indent->alignment->indent = 5.
|
||||
lv_style_indent_guid = lo_style_indent->get_guid( ).
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
"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.
|
||||
lo_style_mixed->alignment->wraptext = abap_true.
|
||||
lv_style_mixed_guid = lo_style_mixed->get_guid( ).
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
"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( ).
|
||||
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 p_path.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->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 = 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.
|
||||
lo_style_mixed->alignment->wraptext = abap_true.
|
||||
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.
|
||||
" 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 ).
|
||||
"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 ).
|
||||
" 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
|
||||
"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 ).
|
||||
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_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_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 ).
|
||||
" 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 ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Alignment.xlsx'
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL15" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100820" UNAM="FEMIA" UDAT="20100905" VERN="000007" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100915" STIME="094448" IDATE="20100905" ITIME="164325" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL15" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100820" UNAM="FEMIA" UDAT="20100924" VERN="000012" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="ABAP2XLSX Reader Demo" LENGTH="21 "/>
|
||||
|
@ -21,33 +21,52 @@ DATA: excel TYPE REF TO zcl_excel,
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
TRY.
|
||||
CREATE OBJECT reader TYPE zcl_excel_reader_2007.
|
||||
excel = reader->load_file( 'C:\iTab.xlsx' ).
|
||||
DATA: lv_workdir TYPE string,
|
||||
lv_path TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( excel ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '15_iTabFromReader.xlsx',
|
||||
lv_default_input TYPE string VALUE '03_iTab.xlsx'.
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\iTabFromReader.xlsx'
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
CATCH zcx_excel. " Exceptions for ABAP2XLSX
|
||||
ENDTRY.</source>
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
TRY.
|
||||
CONCATENATE p_path lv_file_separator lv_default_input INTO lv_path.
|
||||
CREATE OBJECT reader TYPE zcl_excel_reader_2007.
|
||||
excel = reader->load_file( lv_path ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).
|
||||
|
||||
CATCH zcx_excel. " Exceptions for ABAP2XLSX
|
||||
ENDTRY.</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL16" VARCL="X" SUBC="1" CNAM="VONDRUSKA" CDAT="20100914" UNAM="VONDRUSKA" UDAT="20100917" VERN="000051" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100917" STIME="082516" IDATE="20100917" ITIME="082516" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL16" VARCL="X" SUBC="1" CNAM="VONDRUSKA" CDAT="20100914" UNAM="FEMIA" UDAT="20100924" VERN="000054" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel - drawings" LENGTH="25 "/>
|
||||
|
@ -23,111 +23,127 @@ DATA: lo_excel TYPE REF TO zcl_excel,
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
DATA: lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
"Load samle image
|
||||
DATA: lt_bin TYPE solix_tab,
|
||||
lv_len TYPE i,
|
||||
lv_content TYPE xstring,
|
||||
ls_key TYPE wwwdatatab.
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '16_Drawings.xlsx'.
|
||||
|
||||
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.
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
" 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.
|
||||
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.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Sheet1'.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Image from web repository (SMW0)' ).
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->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' ).
|
||||
" 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 ).
|
||||
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 ).
|
||||
" 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 = 'bmp'
|
||||
ip_width = 83
|
||||
ip_height = 160 ).
|
||||
" 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 = 'bmp'
|
||||
ip_width = 83
|
||||
ip_height = 160 ).
|
||||
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
lo_worksheet->add_drawing( lo_drawing ).
|
||||
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
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.
|
||||
* Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = XSTRLEN( lv_file ).
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Drawings.xlsx'
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL17" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100921" UNAM="FEMIA" UDAT="20100922" VERN="000016" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100922" STIME="001419" IDATE="20100922" ITIME="001419" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL17" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100921" UNAM="FEMIA" UDAT="20100924" VERN="000018" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -19,46 +19,64 @@ 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_protection TYPE REF TO zcl_excel_style,
|
||||
lv_style_protection_guid TYPE zexcel_cell_style,
|
||||
lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lv_style_protection_guid TYPE zexcel_cell_style.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" 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"
|
||||
DATA: lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
"Center
|
||||
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( ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '17_SheetProtection.xlsx'.
|
||||
|
||||
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' ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Protection.xlsx'
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
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"
|
||||
|
||||
"Center
|
||||
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( ).
|
||||
|
||||
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 OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL18" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100923" UNAM="FEMIA" UDAT="20100923" VERN="000016" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100923" STIME="233508" IDATE="20100923" ITIME="233508" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL18" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100923" UNAM="FEMIA" UDAT="20100924" VERN="000019" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -19,40 +19,58 @@ 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_protection TYPE REF TO zcl_excel_style,
|
||||
lv_style_protection_guid TYPE zexcel_cell_style,
|
||||
lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lv_style_protection_guid TYPE zexcel_cell_style.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" 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.
|
||||
DATA: lv_workdir TYPE string,
|
||||
lv_file_separator TYPE c.
|
||||
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '18_BookProtection.xlsx'.
|
||||
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
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 ).
|
||||
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 OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Protection.xlsx'
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL2" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100905" VERN="000017" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163545" IDATE="20100905" ITIME="163545" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL2" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000022" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test Styles for ABAP2XLSX" LENGTH="25 "/>
|
||||
|
@ -16,7 +16,7 @@
|
|||
REPORT zdemo_excel2.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
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,
|
||||
|
@ -35,83 +35,102 @@ DATA: lv_style_bold_guid TYPE zexcel_cell_style,
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Create border object
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color = 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 = 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->color = 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.
|
||||
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 = zcl_excel_style_color=>c_yellow.
|
||||
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.
|
||||
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 = zcl_excel_style_color=>c_green.
|
||||
lv_style_filled_green_guid = lo_style_filled->get_guid( ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '02_Styles.xlsx'.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->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 ).
|
||||
" 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 ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Styles.xlsx'
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
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 p_path.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Create border object
|
||||
CREATE OBJECT lo_border_dark.
|
||||
lo_border_dark->border_color = 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 = 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->color = 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.
|
||||
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 = zcl_excel_style_color=>c_yellow.
|
||||
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.
|
||||
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 = zcl_excel_style_color=>c_green.
|
||||
lv_style_filled_green_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->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 ).
|
||||
" 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 ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL3" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100905" VERN="000019" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163630" IDATE="20100905" ITIME="163630" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL3" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000024" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool/>
|
||||
<source>*&---------------------------------------------------------------------*
|
||||
*& Report ZIFE_TEST_EXCEL
|
||||
|
@ -12,7 +12,7 @@
|
|||
REPORT zdemo_excel3.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
|
@ -20,47 +20,66 @@ DATA: ls_table_settings TYPE zexcel_s_table_settings.
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Internal table'.
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '03_iTab.xlsx'.
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
SELECT * FROM sflight INTO TABLE lt_test.
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2.
|
||||
ls_table_settings-show_row_stripes = abap_true.
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
lo_worksheet->bind_table( ip_table = lt_test
|
||||
is_table_settings = ls_table_settings ).
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
lo_worksheet->freeze_panes( ip_num_rows = 3 ). "freeze column headers when scrolling
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
column_dimension = lo_worksheet->get_column_dimension( 'E' ). "make date field a bit wider
|
||||
column_dimension->set_width( 11 ).
|
||||
START-OF-SELECTION.
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
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 p_path.
|
||||
|
||||
" Convert to binary
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\iTab.xlsx'
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Internal table'.
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
SELECT * FROM sflight INTO TABLE lt_test.
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2.
|
||||
ls_table_settings-show_row_stripes = 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( 'E' ). "make date field a bit wider
|
||||
column_dimension->set_width( 11 ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL4" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="VONDRUSKA" UDAT="20100921" VERN="000034" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100921" STIME="073036" IDATE="20100921" ITIME="073036" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL4" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000040" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -21,50 +21,69 @@ DATA: lo_excel TYPE REF TO zcl_excel,
|
|||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Sheet1'.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '04_Sheets.xlsx'.
|
||||
|
||||
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
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'Sheet1'.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the first sheet' ).
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->title = 'Sheet2'.
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'This is the second sheet' ).
|
||||
lo_worksheet = lo_excel->add_new_worksheet( ).
|
||||
lo_worksheet->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_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
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.
|
||||
* Convert to binary
|
||||
lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ).
|
||||
lv_bytecount = XSTRLEN( lv_file ).
|
||||
|
||||
" Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Sheets.xlsx'
|
||||
" Save the file
|
||||
cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount
|
||||
filename = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL5" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100905" VERN="000015" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163754" IDATE="20100905" ITIME="163754" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL5" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000020" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,51 +16,72 @@
|
|||
REPORT zdemo_excel5.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
|
||||
lv_file TYPE xstring,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '05_Conditional.xlsx'.
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
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->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
lo_style_conditional->priority = 1.
|
||||
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_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 ).
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\CondFormatting.xlsx'
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL6" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100905" VERN="000021" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163817" IDATE="20100905" ITIME="163817" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL6" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000026" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,41 +16,62 @@
|
|||
REPORT zdemo_excel6.
|
||||
|
||||
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,
|
||||
lv_file TYPE xstring,
|
||||
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 STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '06_Formulas.xlsx'.
|
||||
|
||||
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_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_formula = 'SUM(C4:C8)' ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Formula.xlsx'
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
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_worksheet->set_cell( ip_row = 9 ip_column = 'C' ip_formula = 'SUM(C4:C8)' ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL7" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100905" VERN="000017" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163844" IDATE="20100905" ITIME="163844" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL7" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20100924" VERN="000022" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,306 +16,327 @@
|
|||
REPORT zdemo_excel7.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional,
|
||||
lv_file TYPE xstring,
|
||||
lo_style_conditional TYPE REF TO zcl_excel_style_conditional.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '07_ConditionalAll.xlsx'.
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrows.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 9 ).
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
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 ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 9 ).
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
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->iconset = zcl_excel_style_conditional=>c_iconset_3flags.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 9 ).
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
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 ).
|
||||
START-OF-SELECTION.
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 9 ).
|
||||
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 p_path.
|
||||
|
||||
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 ).
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'F'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'F'
|
||||
ip_stop_row = 9 ).
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
|
||||
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->iconset = zcl_excel_style_conditional=>c_iconset_3arrows.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = '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_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->iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 9 ).
|
||||
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = '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->iconset = zcl_excel_style_conditional=>c_iconset_3flags.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = '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_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->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'I'
|
||||
ip_start_row = 5
|
||||
ip_stop_column = 'I'
|
||||
ip_stop_row = 9 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = '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_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->iconset = zcl_excel_style_conditional=>c_iconset_4arrows.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 16 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3trafficlights2.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 16 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3signs.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 16 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_4rating.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 16 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_3symbols2.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'F'
|
||||
ip_start_row = 12
|
||||
ip_stop_column = 'F'
|
||||
ip_stop_row = 16 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrows.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = '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_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->iconset = zcl_excel_style_conditional=>c_iconset_5arrows.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 23 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4arrowsgray.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'C'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 23 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4redtoblack.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_5rating.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'D'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'D'
|
||||
ip_stop_row = 23 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4rating.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 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_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->iconset = zcl_excel_style_conditional=>c_iconset_5quarters.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 23 ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_4trafficlights.
|
||||
lo_style_conditional->priority = 1.
|
||||
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 = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ).
|
||||
lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = 50 ).
|
||||
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 ).
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
lo_style_conditional = lo_worksheet->add_new_conditional_style( ).
|
||||
lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset.
|
||||
lo_style_conditional->iconset = zcl_excel_style_conditional=>c_iconset_5arrows.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'B'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'B'
|
||||
ip_stop_row = 23 ).
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Iconset.xlsx'
|
||||
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->iconset = zcl_excel_style_conditional=>c_iconset_5arrowsgray.
|
||||
lo_style_conditional->priority = 1.
|
||||
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->iconset = zcl_excel_style_conditional=>c_iconset_5rating.
|
||||
lo_style_conditional->priority = 1.
|
||||
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->iconset = zcl_excel_style_conditional=>c_iconset_5quarters.
|
||||
lo_style_conditional->priority = 1.
|
||||
lo_style_conditional->set_range( ip_start_column = 'E'
|
||||
ip_start_row = 19
|
||||
ip_stop_column = 'E'
|
||||
ip_stop_row = 23 ).
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 18 ip_column = 'E' ip_value = 'C_ICONSET_5QUARTERS' ).
|
||||
lo_worksheet->set_cell( ip_row = 19 ip_column = 'E' ip_value = 10 ).
|
||||
lo_worksheet->set_cell( ip_row = 20 ip_column = 'E' ip_value = 20 ).
|
||||
lo_worksheet->set_cell( ip_row = 21 ip_column = 'E' ip_value = 30 ).
|
||||
lo_worksheet->set_cell( ip_row = 22 ip_column = 'E' ip_value = 40 ).
|
||||
lo_worksheet->set_cell( ip_row = 23 ip_column = 'E' ip_value = 50 ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL8" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100713" UNAM="FEMIA" UDAT="20100905" VERN="000016" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163905" IDATE="20100905" ITIME="163905" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL8" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100713" UNAM="FEMIA" UDAT="20100924" VERN="000020" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,51 +16,72 @@
|
|||
REPORT zdemo_excel8.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
lo_range TYPE REF TO zcl_excel_range,
|
||||
lv_file TYPE xstring,
|
||||
lv_style_number_guid TYPE zexcel_cell_style,
|
||||
lv_style_number_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'range'.
|
||||
lo_range->set_value( ip_sheet_name = lo_worksheet->title
|
||||
ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '08_Range.xlsx'.
|
||||
|
||||
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 ).
|
||||
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 p_path.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'range'.
|
||||
lo_range->set_value( ip_sheet_name = lo_worksheet->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' ).
|
||||
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' ).
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\Range.xlsx'
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-16"?>
|
||||
<PROG NAME="ZDEMO_EXCEL9" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100713" UNAM="FEMIA" UDAT="20100905" VERN="000017" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100905" STIME="163927" IDATE="20100905" ITIME="163927" UCCHECK="X">
|
||||
<PROG NAME="ZDEMO_EXCEL9" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100713" UNAM="FEMIA" UDAT="20100924" VERN="000021" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20100924" STIME="153902" IDATE="20100924" ITIME="153902" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
||||
|
@ -16,58 +16,80 @@
|
|||
REPORT zdemo_excel9.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_excel_writer type ref to zif_excel_writer,
|
||||
lo_excel_writer TYPE REF TO zif_excel_writer,
|
||||
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,
|
||||
lv_file TYPE xstring,
|
||||
lv_style_number_guid TYPE zexcel_cell_style,
|
||||
lv_style_number_guid TYPE zexcel_cell_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
||||
lt_file_tab TYPE solix_tab.
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
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.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'range'.
|
||||
lo_range->set_value( ip_sheet_name = lo_worksheet->title
|
||||
ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
CONSTANTS: lv_default_file_name TYPE string VALUE '09_DataValidation.xlsx'.
|
||||
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->value = lo_range->name.
|
||||
lo_data_validation->cell_row = 4.
|
||||
lo_data_validation->cell_column = 'A'.
|
||||
PARAMETERS: p_path TYPE string.
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Select a value' ).
|
||||
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
|
||||
|
||||
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' ).
|
||||
cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = p_path
|
||||
CHANGING selected_folder = p_path ).
|
||||
|
||||
create object lo_excel_writer type zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
INITIALIZATION.
|
||||
cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
|
||||
p_path = lv_workdir.
|
||||
|
||||
"convert to table
|
||||
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
|
||||
EXPORTING
|
||||
buffer = lv_file
|
||||
IMPORTING
|
||||
output_length = lv_bytecount
|
||||
TABLES
|
||||
binary_tab = lt_file_tab.
|
||||
"Save the file
|
||||
CALL FUNCTION 'GUI_DOWNLOAD'
|
||||
EXPORTING
|
||||
bin_filesize = lv_bytecount
|
||||
filename = 'C:\DataValidation.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 ).
|
||||
CONCATENATE p_path lv_file_separator lv_default_file_name INTO p_path.
|
||||
|
||||
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->title = 'sheet1'.
|
||||
lo_range = lo_excel->add_new_range( ).
|
||||
lo_range->name = 'range'.
|
||||
lo_range->set_value( ip_sheet_name = lo_worksheet->title
|
||||
ip_start_column = 'C'
|
||||
ip_start_row = 4
|
||||
ip_stop_column = 'C'
|
||||
ip_stop_row = 8 ).
|
||||
|
||||
lo_data_validation = lo_worksheet->add_new_data_validation( ).
|
||||
lo_data_validation->value = lo_range->name.
|
||||
lo_data_validation->cell_row = 4.
|
||||
lo_data_validation->cell_column = 'A'.
|
||||
|
||||
lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Select a value' ).
|
||||
|
||||
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' ).
|
||||
|
||||
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
|
||||
lv_file = lo_excel_writer->write_file( lo_excel ).
|
||||
|
||||
* 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 = p_path
|
||||
filetype = 'BIN'
|
||||
TABLES
|
||||
data_tab = lt_file_tab.</source>
|
||||
CHANGING data_tab = lt_file_tab ).</source>
|
||||
</PROG>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
abap2xlsx"
|
||||
abap2xlsx
|
||||
|
||||
Copyright (c) 2010 - 2011 Plinky.it
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
@category ABAP xlsx Manager
|
||||
@package ZABAP2XLSX
|
||||
@package ZA2X
|
||||
@author Ivan Femia
|
||||
@company Techedge SpA
|
||||
@homepage http://www.plinky.it/software
|
||||
|
|
|
@ -1 +1 @@
|
|||
Check out the Installation Guide at http://code.google.com/p/abap2xlsx/wiki/InstallationGuide
|
||||
Check out the Installation Guide at http://wiki.sdn.sap.com/wiki/display/ABAP/Installation+Guide
|
Loading…
Reference in New Issue
Block a user