Fixed Reading styles demos moved to demo 26 and 27

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@165 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
Ivan Femia 2011-04-26 03:09:42 +00:00
parent e8aa4ec888
commit e0d60fe706
5 changed files with 305 additions and 63 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_EXCEL" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100817" UNAM="FEMIA" UDAT="20110401" VERN="000042" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20110401" STIME="154539" IDATE="20110401" ITIME="154539" UCCHECK="X">
<PROG NAME="ZDEMO_EXCEL" VARCL="X" SUBC="1" CNAM="BCUSER" CDAT="20100817" UNAM="FEMIA" UDAT="20110426" VERN="000043" RSTAT="T" RMAND="000" RLOAD="E" FIXPT="X" SDATE="20110426" STIME="050556" IDATE="20110426" ITIME="050556" UCCHECK="X">
<textPool>
<language SPRAS="E">
<textElement ID="R" ENTRY="Run all ABAP2XLSX Demo Programs" LENGTH="31 "/>
@ -61,5 +61,7 @@ START-OF-SELECTION.
SUBMIT zdemo_excel22 WITH p_path = p_path AND RETURN. &quot; Bind table with field catalog &amp; sheet style
SUBMIT zdemo_excel23 WITH p_path = p_path AND RETURN. &quot; abap2xlsx Demo: Multiple sheets with and w/o grid lines, print options
SUBMIT zdemo_excel24 WITH p_path = p_path AND RETURN. &quot; abap2xlsx Demo: Multiple sheets with different default date formats
SUBMIT zdemo_excel25 AND RETURN. &quot; abap2xlsx Demo: Create and xlsx on Application Server (could be executed in batch mode)</source>
SUBMIT zdemo_excel25 AND RETURN. &quot; abap2xlsx Demo: Create and xlsx on Application Server (could be executed in batch mode)
SUBMIT zdemo_excel26 WITH p_path = p_path WITH p_reader = abap_true AND RETURN. &quot; abap2xlsx Demo: Read cell format
SUBMIT zdemo_excel27 WITH p_path = p_path WITH p_reader = abap_true AND RETURN. &quot; abap2xlsx Demo: Read style format</source>
</PROG>

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_EXCEL1" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="BCUSER" UDAT="20110425" VERN="000061" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110425" STIME="232351" IDATE="20110425" ITIME="232351" UCCHECK="X">
<PROG NAME="ZDEMO_EXCEL1" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20110205" VERN="000058" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110414" STIME="095128" IDATE="20110205" ITIME="113106" UCCHECK="X">
<textPool>
<language SPRAS="E">
<textElement ID="R" ENTRY="abap2xlsx Demo: Hello World" LENGTH="27 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="24 "/>
<textElement ID="S" KEY="P_READER" ENTRY=" Write back after using Reader" LENGTH="37 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="9 "/>
</language>
</textPool>
<source>*&amp;---------------------------------------------------------------------*
@ -19,7 +18,6 @@ REPORT zdemo_excel1.
DATA: lo_excel TYPE REF TO zcl_excel,
lo_excel_writer TYPE REF TO zif_excel_writer,
lo_excel_reader TYPE REF TO zif_excel_reader,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
@ -34,8 +32,7 @@ DATA: lv_full_path TYPE string,
CONSTANTS: lv_default_file_name TYPE string VALUE &apos;01_HelloWorld.xlsx&apos;.
PARAMETERS: p_path TYPE zexcel_export_dir,
p_reader TYPE abap_bool AS CHECKBOX.
PARAMETERS: p_path TYPE zexcel_export_dir.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
lv_workdir = p_path.
@ -90,28 +87,5 @@ START-OF-SELECTION.
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
IF p_reader = abap_true.
CREATE OBJECT lo_excel_reader TYPE zcl_excel_reader_2007.
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
lo_excel = lo_excel_reader-&gt;load_file( lv_full_path ).
lv_file = lo_excel_writer-&gt;write_file( lo_excel ).
REPLACE &apos;.xlsx&apos; IN lv_full_path WITH &apos;FromReader.xlsx&apos;.
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
&quot; Save the file
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
ENDIF.</source>
CHANGING data_tab = lt_file_tab ).</source>
</PROG>

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_EXCEL2" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="BCUSER" UDAT="20110425" VERN="000042" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110425" STIME="232237" IDATE="20110425" ITIME="232237" UCCHECK="X">
<PROG NAME="ZDEMO_EXCEL2" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20110205" VERN="000034" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110414" STIME="095128" IDATE="20110205" ITIME="113106" UCCHECK="X">
<textPool>
<language SPRAS="E">
<textElement ID="R" ENTRY="abap2xlsx Demo: Styles" LENGTH="22 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="24 "/>
<textElement ID="S" KEY="P_READER" ENTRY=" Write back after using Reader" LENGTH="37 "/>
<textElement ID="R" ENTRY="abap2xlsx Demo: Styles" LENGTH="25 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="9 "/>
</language>
</textPool>
<source>*&amp;---------------------------------------------------------------------*
@ -19,7 +18,6 @@ REPORT zdemo_excel2.
DATA: lo_excel TYPE REF TO zcl_excel,
lo_excel_writer TYPE REF TO zif_excel_writer,
lo_excel_reader TYPE REF TO zif_excel_reader,
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,
@ -46,8 +44,7 @@ DATA: lv_full_path TYPE string,
CONSTANTS: lv_default_file_name TYPE string VALUE &apos;02_Styles.xlsx&apos;.
PARAMETERS: p_path TYPE zexcel_export_dir,
p_reader TYPE abap_bool AS CHECKBOX.
PARAMETERS: p_path TYPE zexcel_export_dir.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
lv_workdir = p_path.
@ -148,28 +145,5 @@ START-OF-SELECTION.
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
IF p_reader = abap_true.
CREATE OBJECT lo_excel_reader TYPE zcl_excel_reader_2007.
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
lo_excel = lo_excel_reader-&gt;load_file( lv_full_path ).
lv_file = lo_excel_writer-&gt;write_file( lo_excel ).
REPLACE &apos;.xlsx&apos; IN lv_full_path WITH &apos;FromReader.xlsx&apos;.
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
&quot; Save the file
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
ENDIF.</source>
CHANGING data_tab = lt_file_tab ).</source>
</PROG>

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_EXCEL26" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20110426" VERN="000063" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110426" STIME="050556" IDATE="20110426" ITIME="050556" UCCHECK="X">
<textPool>
<language SPRAS="E">
<textElement ID="R" ENTRY="abap2xlsx Demo: Hello World" LENGTH="27 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="24 "/>
<textElement ID="S" KEY="P_READER" ENTRY=" Write back after using Reader" LENGTH="37 "/>
</language>
</textPool>
<source>*&amp;---------------------------------------------------------------------*
*&amp; Report ZDEMO_EXCEL26
*&amp;
*&amp;---------------------------------------------------------------------*
*&amp;
*&amp;
*&amp;---------------------------------------------------------------------*
REPORT zdemo_excel26.
DATA: lo_excel TYPE REF TO zcl_excel,
lo_excel_writer TYPE REF TO zif_excel_writer,
lo_excel_reader TYPE REF TO zif_excel_reader,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
DATA: lv_file TYPE xstring,
lv_bytecount TYPE i,
lt_file_tab TYPE solix_tab.
DATA: lv_full_path TYPE string,
lv_workdir TYPE string,
lv_file_separator TYPE c.
CONSTANTS: lv_default_file_name TYPE string VALUE &apos;26_HelloWorld.xlsx&apos;.
PARAMETERS: p_path TYPE zexcel_export_dir,
p_reader TYPE abap_bool AS CHECKBOX.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
lv_workdir = p_path.
cl_gui_frontend_services=&gt;directory_browse( EXPORTING initial_folder = lv_workdir
CHANGING selected_folder = lv_workdir ).
p_path = lv_workdir.
INITIALIZATION.
cl_gui_frontend_services=&gt;get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
cl_gui_cfw=&gt;flush( ).
p_path = lv_workdir.
START-OF-SELECTION.
IF p_path IS INITIAL.
p_path = lv_workdir.
ENDIF.
cl_gui_frontend_services=&gt;get_file_separator( CHANGING file_separator = lv_file_separator ).
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
&quot; Creates active sheet
CREATE OBJECT lo_excel.
&quot; Get active sheet
lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
lo_worksheet-&gt;set_title( ip_title = &apos;Sheet1&apos; ).
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 2 ip_value = &apos;Hello world&apos; ).
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 3 ip_value = sy-datum ).
lo_worksheet-&gt;set_cell( ip_column = &apos;C&apos; ip_row = 3 ip_value = sy-uzeit ).
lo_hyperlink = zcl_excel_hyperlink=&gt;create_external_link( iv_url = &apos;https://cw.sdn.sap.com/cw/groups/abap2xlsx&apos; ).
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 4 ip_value = &apos;Click here to visit abap2xlsx homepage&apos; ip_hyperlink = lo_hyperlink ).
column_dimension = lo_worksheet-&gt;get_column_dimension( ip_column = &apos;B&apos; ).
column_dimension-&gt;set_width( ip_width = 11 ).
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
lv_file = lo_excel_writer-&gt;write_file( lo_excel ).
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
* &quot; This method is only available on AS ABAP &gt; 6.40
* lt_file_tab = cl_bcs_convert=&gt;xstring_to_solix( iv_xstring = lv_file ).
* lv_bytecount = xstrlen( lv_file ).
&quot; Save the file
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
IF p_reader = abap_true.
CREATE OBJECT lo_excel_reader TYPE zcl_excel_reader_2007.
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
lo_excel = lo_excel_reader-&gt;load_file( lv_full_path ).
lv_file = lo_excel_writer-&gt;write_file( lo_excel ).
REPLACE &apos;.xlsx&apos; IN lv_full_path WITH &apos;FromReader.xlsx&apos;.
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
&quot; Save the file
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
ENDIF.</source>
</PROG>

View File

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_EXCEL27" VARCL="X" SUBC="1" CNAM="FEMIA" CDAT="20100711" UNAM="FEMIA" UDAT="20110426" VERN="000044" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110426" STIME="050557" IDATE="20110426" ITIME="050557" UCCHECK="X">
<textPool>
<language SPRAS="E">
<textElement ID="R" ENTRY="abap2xlsx Demo: Styles" LENGTH="22 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="24 "/>
<textElement ID="S" KEY="P_READER" ENTRY=" Write back after using Reader" LENGTH="37 "/>
</language>
</textPool>
<source>*&amp;---------------------------------------------------------------------*
*&amp; Report ZDEMO_EXCEL27
*&amp; Test Styles for ABAP2XLSX
*&amp;---------------------------------------------------------------------*
*&amp;
*&amp;
*&amp;---------------------------------------------------------------------*
REPORT zdemo_excel27.
DATA: lo_excel TYPE REF TO zcl_excel,
lo_excel_writer TYPE REF TO zif_excel_writer,
lo_excel_reader TYPE REF TO zif_excel_reader,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_style_bold TYPE REF TO zcl_excel_style,
lo_style_underline TYPE REF TO zcl_excel_style,
lo_style_filled TYPE REF TO zcl_excel_style,
lo_style_border TYPE REF TO zcl_excel_style,
lo_style_button TYPE REF TO zcl_excel_style,
lo_border_dark TYPE REF TO zcl_excel_style_border,
lo_border_light TYPE REF TO zcl_excel_style_border.
DATA: lv_style_bold_guid TYPE zexcel_cell_style,
lv_style_underline_guid TYPE zexcel_cell_style,
lv_style_filled_guid TYPE zexcel_cell_style,
lv_style_filled_green_guid TYPE zexcel_cell_style,
lv_style_border_guid TYPE zexcel_cell_style,
lv_style_button_guid TYPE zexcel_cell_style.
DATA: lv_file TYPE xstring,
lv_bytecount TYPE i,
lt_file_tab TYPE solix_tab.
DATA: lv_full_path TYPE string,
lv_workdir TYPE string,
lv_file_separator TYPE c.
CONSTANTS: lv_default_file_name TYPE string VALUE &apos;27_Styles.xlsx&apos;.
PARAMETERS: p_path TYPE zexcel_export_dir,
p_reader TYPE abap_bool AS CHECKBOX.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
lv_workdir = p_path.
cl_gui_frontend_services=&gt;directory_browse( EXPORTING initial_folder = lv_workdir
CHANGING selected_folder = lv_workdir ).
p_path = lv_workdir.
INITIALIZATION.
cl_gui_frontend_services=&gt;get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
cl_gui_cfw=&gt;flush( ).
p_path = lv_workdir.
START-OF-SELECTION.
IF p_path IS INITIAL.
p_path = lv_workdir.
ENDIF.
cl_gui_frontend_services=&gt;get_file_separator( CHANGING file_separator = lv_file_separator ).
CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path.
&quot; Creates active sheet
CREATE OBJECT lo_excel.
&quot; Create border object
CREATE OBJECT lo_border_dark.
lo_border_dark-&gt;border_color = zcl_excel_style_color=&gt;c_black.
lo_border_dark-&gt;border_style = zcl_excel_style_border=&gt;c_border_thin.
CREATE OBJECT lo_border_light.
lo_border_light-&gt;border_color = zcl_excel_style_color=&gt;c_gray.
lo_border_light-&gt;border_style = zcl_excel_style_border=&gt;c_border_thin.
&quot; Create a bold / italic style
lo_style_bold = lo_excel-&gt;add_new_style( ).
lo_style_bold-&gt;font-&gt;bold = abap_true.
lo_style_bold-&gt;font-&gt;italic = abap_true.
lo_style_bold-&gt;font-&gt;color = zcl_excel_style_color=&gt;c_red.
lv_style_bold_guid = lo_style_bold-&gt;get_guid( ).
&quot; Create an underline double style
lo_style_underline = lo_excel-&gt;add_new_style( ).
lo_style_underline-&gt;font-&gt;underline = abap_true.
lo_style_underline-&gt;font-&gt;underline_mode = zcl_excel_style_font=&gt;c_underline_double.
lv_style_underline_guid = lo_style_underline-&gt;get_guid( ).
&quot; Create filled style yellow
lo_style_filled = lo_excel-&gt;add_new_style( ).
lo_style_filled-&gt;fill-&gt;filltype = zcl_excel_style_fill=&gt;c_fill_solid.
lo_style_filled-&gt;fill-&gt;fgcolor = zcl_excel_style_color=&gt;c_yellow.
lv_style_filled_guid = lo_style_filled-&gt;get_guid( ).
&quot; Create border with button effects
lo_style_button = lo_excel-&gt;add_new_style( ).
lo_style_button-&gt;borders-&gt;right = lo_border_dark.
lo_style_button-&gt;borders-&gt;down = lo_border_dark.
lo_style_button-&gt;borders-&gt;left = lo_border_light.
lo_style_button-&gt;borders-&gt;top = lo_border_light.
lv_style_button_guid = lo_style_button-&gt;get_guid( ).
&quot;Create style with border
lo_style_border = lo_excel-&gt;add_new_style( ).
lo_style_border-&gt;borders-&gt;allborders = lo_border_dark.
lv_style_border_guid = lo_style_border-&gt;get_guid( ).
&quot; Create filled style green
lo_style_filled = lo_excel-&gt;add_new_style( ).
lo_style_filled-&gt;fill-&gt;filltype = zcl_excel_style_fill=&gt;c_fill_solid.
lo_style_filled-&gt;fill-&gt;fgcolor = zcl_excel_style_color=&gt;c_green.
lv_style_filled_green_guid = lo_style_filled-&gt;get_guid( ).
&quot; Get active sheet
lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
lo_worksheet-&gt;set_title( ip_title = &apos;Styles&apos; ).
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 2 ip_value = &apos;Hello world&apos; ).
lo_worksheet-&gt;set_cell( ip_column = &apos;C&apos; ip_row = 3 ip_value = &apos;Bold text&apos; ip_style = lv_style_bold_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;D&apos; ip_row = 4 ip_value = &apos;Underlined text&apos; ip_style = lv_style_underline_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 5 ip_value = &apos;Filled text&apos; ip_style = lv_style_filled_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;C&apos; ip_row = 6 ip_value = &apos;Borders&apos; ip_style = lv_style_border_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;D&apos; ip_row = 7 ip_value = &apos;I&apos;&apos;m not a button :)&apos; ip_style = lv_style_button_guid ).
&quot; Fill the cell and apply one style
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 6 ip_value = &apos;Filled text&apos; ip_style = lv_style_filled_guid ).
&quot; Change the style
lo_worksheet-&gt;set_cell_style( ip_column = &apos;B&apos; ip_row = 6 ip_style = lv_style_filled_green_guid ).
&quot; Add Style to an empty cell to test Fix for Issue
&quot;#44 Exception ZCX_EXCEL thrown when style is set for an empty cell
&quot; https://code.sdn.sap.com/spaces/abap2xlsx/tickets/44-exception-zcx_excel-thrown-when-style-is-set-for-an-empty-cell
lo_worksheet-&gt;set_cell_style( ip_column = &apos;E&apos; 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-&gt;write_file( lo_excel ).
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
* &quot; This method is only available on AS ABAP &gt; 6.40
* lt_file_tab = cl_bcs_convert=&gt;xstring_to_solix( iv_xstring = lv_file ).
* lv_bytecount = xstrlen( lv_file ).
&quot; Save the file
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
IF p_reader = abap_true.
CREATE OBJECT lo_excel_reader TYPE zcl_excel_reader_2007.
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
lo_excel = lo_excel_reader-&gt;load_file( lv_full_path ).
lv_file = lo_excel_writer-&gt;write_file( lo_excel ).
REPLACE &apos;.xlsx&apos; IN lv_full_path WITH &apos;FromReader.xlsx&apos;.
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
EXPORTING
buffer = lv_file
IMPORTING
output_length = lv_bytecount
TABLES
binary_tab = lt_file_tab.
&quot; Save the file
cl_gui_frontend_services=&gt;gui_download( EXPORTING bin_filesize = lv_bytecount
filename = lv_full_path
filetype = &apos;BIN&apos;
CHANGING data_tab = lt_file_tab ).
ENDIF.</source>
</PROG>