mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 05:16:16 +08:00

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@22 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
77 lines
3.0 KiB
XML
77 lines
3.0 KiB
XML
<?xml version="1.0" encoding="utf-16"?>
|
|
<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 "/>
|
|
</language>
|
|
</textPool>
|
|
<source>*&---------------------------------------------------------------------*
|
|
*& Report ZIFE_TEST_EXCEL
|
|
*&
|
|
*&---------------------------------------------------------------------*
|
|
*&
|
|
*&
|
|
*&---------------------------------------------------------------------*
|
|
|
|
REPORT zdemo_excel18.
|
|
|
|
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.
|
|
|
|
DATA: lv_file TYPE xstring,
|
|
lv_bytecount TYPE i,
|
|
lt_file_tab TYPE solix_tab.
|
|
|
|
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 ).
|
|
|
|
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>
|