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

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@13 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
65 lines
3.0 KiB
XML
65 lines
3.0 KiB
XML
<?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">
|
|
<textPool>
|
|
<language SPRAS="E">
|
|
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
|
</language>
|
|
</textPool>
|
|
<source>*&---------------------------------------------------------------------*
|
|
*& Report ZIFE_TEST_EXCEL
|
|
*&
|
|
*&---------------------------------------------------------------------*
|
|
*&
|
|
*&
|
|
*&---------------------------------------------------------------------*
|
|
|
|
REPORT zdemo_excel17.
|
|
|
|
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.
|
|
|
|
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 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'
|
|
filetype = 'BIN'
|
|
TABLES
|
|
data_tab = lt_file_tab.</source>
|
|
</PROG>
|