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
71 lines
3.1 KiB
XML
71 lines
3.1 KiB
XML
<?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">
|
|
<textPool>
|
|
<language SPRAS="E">
|
|
<textElement ID="R" ENTRY="Test for excel" LENGTH="14 "/>
|
|
</language>
|
|
</textPool>
|
|
<source>*&---------------------------------------------------------------------*
|
|
*& Report ZIFE_TEST_EXCEL
|
|
*&
|
|
*&---------------------------------------------------------------------*
|
|
*&
|
|
*&
|
|
*&---------------------------------------------------------------------*
|
|
|
|
REPORT zdemo_excel4.
|
|
|
|
DATA: lo_excel TYPE REF TO zcl_excel,
|
|
lo_excel_writer TYPE REF TO zif_excel_writer,
|
|
lo_worksheet TYPE REF TO zcl_excel_worksheet.
|
|
|
|
DATA: lv_file TYPE xstring,
|
|
lv_bytecount TYPE i,
|
|
lt_file_tab TYPE STANDARD TABLE OF solisti1.
|
|
|
|
" 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' ).
|
|
|
|
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.
|
|
|
|
" Save the file
|
|
CALL FUNCTION 'GUI_DOWNLOAD'
|
|
EXPORTING
|
|
bin_filesize = lv_bytecount
|
|
filename = 'C:\Sheets.xlsx'
|
|
filetype = 'BIN'
|
|
TABLES
|
|
data_tab = lt_file_tab.</source>
|
|
</PROG>
|