Ready to test #185

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@320 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
Gregor Wolf 2012-07-01 10:44:33 +00:00
parent cd1b8f99e6
commit 2d5fb26d4e
2 changed files with 723 additions and 707 deletions

View File

@ -1,359 +1,365 @@
<?xml version="1.0" encoding="utf-16"?> <?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_CALENDAR" VARCL="X" SUBC="1" CNAM="DEVELOPER" CDAT="20111229" UNAM="DEVELOPER" UDAT="20111230" VERN="000116" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20111230" STIME="102417" IDATE="20111230" ITIME="102249" UCCHECK="X"> <PROG NAME="ZDEMO_CALENDAR" VARCL="X" SUBC="1" CNAM="DEVELOPER" CDAT="20111229" UNAM="DEVELOPER" UDAT="20120619" VERN="000127" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20120619" STIME="063434" IDATE="20120619" ITIME="063434" UCCHECK="X">
<textPool> <textPool>
<language SPRAS="D"> <language SPRAS="D">
<textElement ID="I" KEY="001" ENTRY="KW" LENGTH="4 "/> <textElement ID="I" KEY="001" ENTRY="KW" LENGTH="4 "/>
<textElement ID="I" KEY="002" ENTRY="Erzeugt mit abap2xlsx. Weitere Informationen unter http://abap2xlsx.org." LENGTH="100 "/> <textElement ID="I" KEY="002" ENTRY="Erzeugt mit abap2xlsx. Weitere Informationen unter http://abap2xlsx.org." LENGTH="100 "/>
<textElement ID="R" ENTRY="abap2xlsx Demo: Erzeugen eines Kalenders mit Bildern" LENGTH="70 "/> <textElement ID="R" ENTRY="abap2xlsx Demo: Erzeugen eines Kalenders mit Bildern" LENGTH="70 "/>
</language> </language>
<language SPRAS="E"> <language SPRAS="E">
<textElement ID="I" KEY="001" ENTRY="CW" LENGTH="4 "/> <textElement ID="I" KEY="001" ENTRY="CW" LENGTH="4 "/>
<textElement ID="I" KEY="002" ENTRY="Created with abap2xlsx. Find more information at http://abap2xlsx.org." LENGTH="100 "/> <textElement ID="I" KEY="002" ENTRY="Created with abap2xlsx. Find more information at http://abap2xlsx.org." LENGTH="100 "/>
<textElement ID="R" ENTRY="abap2xlsx Demo: Create Calendar with Pictures" LENGTH="45 "/> <textElement ID="R" ENTRY="abap2xlsx Demo: Create Calendar with Pictures" LENGTH="45 "/>
<textElement ID="S" KEY="P_FROM" ENTRY="D ." LENGTH="9 "/> <textElement ID="S" KEY="P_FROM" ENTRY="D ." LENGTH="9 "/>
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="9 "/> <textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="9 "/>
<textElement ID="S" KEY="P_TO" ENTRY="D ." LENGTH="9 "/> <textElement ID="S" KEY="P_TO" ENTRY="D ." LENGTH="9 "/>
</language> </language>
</textPool> </textPool>
<source>*&amp;---------------------------------------------------------------------* <source>*&amp;---------------------------------------------------------------------*
*&amp; Report ZDEMO_CALENDAR *&amp; Report ZDEMO_CALENDAR
*&amp; abap2xlsx Demo: Create Calendar with Pictures *&amp; abap2xlsx Demo: Create Calendar with Pictures
*&amp;---------------------------------------------------------------------* *&amp;---------------------------------------------------------------------*
*&amp; This report creates a monthly calendar in the specified date range. *&amp; This report creates a monthly calendar in the specified date range.
*&amp; Each month is put on a seperate worksheet. The pictures for each *&amp; Each month is put on a seperate worksheet. The pictures for each
*&amp; month can be specified in a tab delimited file called &quot;Calendar.txt&quot; *&amp; month can be specified in a tab delimited file called &quot;Calendar.txt&quot;
*&amp; which is saved in the Export Directory. By default this is the SAP *&amp; which is saved in the Export Directory. By default this is the SAP
*&amp; Workdir. The file contains 3 fields: *&amp; Workdir. The file contains 3 fields:
*&amp; *&amp;
*&amp; Month (with leading 0) *&amp; Month (with leading 0)
*&amp; Image Filename *&amp; Image Filename
*&amp; Image Description *&amp; Image Description
*&amp; *&amp;
*&amp; The Images should be landscape JPEG&apos;s with a 3:2 ratio and min. *&amp; The Images should be landscape JPEG&apos;s with a 3:2 ratio and min.
*&amp; 450 pixel height. They must also be saved in the Export Directory. *&amp; 450 pixel height. They must also be saved in the Export Directory.
*&amp; In my tests I&apos;ve discovered a limit of 20 MB in the *&amp; In my tests I&apos;ve discovered a limit of 20 MB in the
*&amp; cl_gui_frontend_services=&gt;gui_download method. So keep your images *&amp; cl_gui_frontend_services=&gt;gui_download method. So keep your images
*&amp; smaller or chnage to a server export using OPEN DATASET. *&amp; smaller or chnage to a server export using OPEN DATASET.
*&amp;---------------------------------------------------------------------* *&amp;---------------------------------------------------------------------*
REPORT zdemo_calendar. REPORT zdemo_calendar.
TYPE-POOLS: abap. TYPE-POOLS: abap.
INCLUDE zdemo_calendar_classes. INCLUDE zdemo_calendar_classes.
DATA: lv_workdir TYPE string. DATA: lv_workdir TYPE string.
PARAMETERS: p_path TYPE zexcel_export_dir. PARAMETERS: p_path TYPE zexcel_export_dir.
PARAMETERS: p_from TYPE demo_cr_date_from DEFAULT &apos;20120101&apos;, PARAMETERS: p_from TYPE dfrom DEFAULT &apos;20120101&apos;,
p_to TYPE demo_cr_date_to DEFAULT &apos;20121231&apos;. p_to TYPE dto DEFAULT &apos;20121231&apos;.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
lv_workdir = p_path. lv_workdir = p_path.
cl_gui_frontend_services=&gt;directory_browse( EXPORTING initial_folder = lv_workdir cl_gui_frontend_services=&gt;directory_browse( EXPORTING initial_folder = lv_workdir
CHANGING selected_folder = lv_workdir ). CHANGING selected_folder = lv_workdir ).
p_path = lv_workdir. p_path = lv_workdir.
INITIALIZATION. INITIALIZATION.
cl_gui_frontend_services=&gt;get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ). cl_gui_frontend_services=&gt;get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ).
cl_gui_cfw=&gt;flush( ). cl_gui_cfw=&gt;flush( ).
p_path = lv_workdir. p_path = lv_workdir.
START-OF-SELECTION. START-OF-SELECTION.
DATA: lo_excel TYPE REF TO zcl_excel, 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_worksheet TYPE REF TO zcl_excel_worksheet,
lo_drawing TYPE REF TO zcl_excel_drawing. lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
lo_row_dim TYPE REF TO ZCL_EXCEL_WORKSHEET_ROWDIMENSI,
DATA: lo_style_month TYPE REF TO zcl_excel_style, lo_drawing TYPE REF TO zcl_excel_drawing.
lv_style_month_guid TYPE zexcel_cell_style.
DATA: lo_style_border TYPE REF TO zcl_excel_style, DATA: lo_style_month TYPE REF TO zcl_excel_style,
lo_border_dark TYPE REF TO zcl_excel_style_border, lv_style_month_guid TYPE zexcel_cell_style.
lv_style_border_guid TYPE zexcel_cell_style. DATA: lo_style_border TYPE REF TO zcl_excel_style,
DATA: lo_style_center TYPE REF TO zcl_excel_style, lo_border_dark TYPE REF TO zcl_excel_style_border,
lv_style_center_guid TYPE zexcel_cell_style. lv_style_border_guid TYPE zexcel_cell_style.
DATA: lo_style_center TYPE REF TO zcl_excel_style,
DATA: lv_file TYPE xstring, lv_style_center_guid TYPE zexcel_cell_style.
lv_bytecount TYPE i,
lt_file_tab TYPE solix_tab. DATA: lv_file TYPE xstring,
lv_bytecount TYPE i,
DATA: lv_full_path TYPE string, lt_file_tab TYPE solix_tab.
image_descr_path TYPE string,
lv_file_separator TYPE c. DATA: lv_full_path TYPE string,
DATA: lv_content TYPE xstring, image_descr_path TYPE string,
width TYPE i. lv_file_separator TYPE c.
DATA: lv_content TYPE xstring,
DATA: month TYPE i, width TYPE i.
month_nr TYPE fcmnr,
count TYPE i VALUE 1, DATA: month TYPE i,
title TYPE zexcel_sheet_title, month_nr TYPE fcmnr,
value TYPE string, count TYPE i VALUE 1,
image_path TYPE string, title TYPE zexcel_sheet_title,
date_from TYPE datum, value TYPE string,
date_to TYPE datum, image_path TYPE string,
row TYPE zexcel_cell_row, date_from TYPE datum,
to_col TYPE zexcel_cell_column_alpha, date_to TYPE datum,
to_col_int TYPE i. row TYPE zexcel_cell_row,
to_col TYPE zexcel_cell_column_alpha,
DATA: month_names TYPE TABLE OF t247. to_col_int TYPE i.
FIELD-SYMBOLS: &lt;month_name&gt; LIKE LINE OF month_names.
DATA: month_names TYPE TABLE OF t247.
TYPES: BEGIN OF tt_datatab, FIELD-SYMBOLS: &lt;month_name&gt; LIKE LINE OF month_names.
month_nr TYPE fcmnr,
filename TYPE string, TYPES: BEGIN OF tt_datatab,
descr TYPE string, month_nr TYPE fcmnr,
END OF tt_datatab. filename TYPE string,
descr TYPE string,
DATA: image_descriptions TYPE TABLE OF tt_datatab. END OF tt_datatab.
FIELD-SYMBOLS: &lt;img_descr&gt; LIKE LINE OF image_descriptions.
DATA: image_descriptions TYPE TABLE OF tt_datatab.
CONSTANTS: lv_default_file_name TYPE string VALUE &apos;Calendar&apos;, &quot;#EC NOTEXT FIELD-SYMBOLS: &lt;img_descr&gt; LIKE LINE OF image_descriptions.
from_row TYPE zexcel_cell_row VALUE 28,
from_col TYPE zexcel_cell_column_alpha VALUE &apos;C&apos;, CONSTANTS: lv_default_file_name TYPE string VALUE &apos;Calendar&apos;, &quot;#EC NOTEXT
c_height TYPE i VALUE 450, &quot; Image Height from_row TYPE zexcel_cell_row VALUE 28,
c_factor TYPE f VALUE &apos;1.5&apos;. &quot; Image Ratio, default 3:2 from_col TYPE zexcel_cell_column_alpha VALUE &apos;C&apos;,
c_height TYPE i VALUE 450, &quot; Image Height
IF p_path IS INITIAL. c_factor TYPE f VALUE &apos;1.5&apos;. &quot; Image Ratio, default 3:2
p_path = lv_workdir.
ENDIF. IF p_path IS INITIAL.
cl_gui_frontend_services=&gt;get_file_separator( CHANGING file_separator = lv_file_separator ). p_path = lv_workdir.
CONCATENATE p_path lv_file_separator lv_default_file_name &apos;.xlsx&apos; INTO lv_full_path. &quot;#EC NOTEXT ENDIF.
cl_gui_frontend_services=&gt;get_file_separator( CHANGING file_separator = lv_file_separator ).
&quot; Read Image Names for Month and Description CONCATENATE p_path lv_file_separator lv_default_file_name &apos;.xlsx&apos; INTO lv_full_path. &quot;#EC NOTEXT
CONCATENATE p_path lv_file_separator lv_default_file_name &apos;.txt&apos; INTO image_descr_path. &quot;#EC NOTEXT
cl_gui_frontend_services=&gt;gui_upload( &quot; Read Image Names for Month and Description
EXPORTING CONCATENATE p_path lv_file_separator lv_default_file_name &apos;.txt&apos; INTO image_descr_path. &quot;#EC NOTEXT
filename = image_descr_path &quot; Name of file cl_gui_frontend_services=&gt;gui_upload(
filetype = &apos;ASC&apos; &quot; File Type (ASCII, Binary) EXPORTING
has_field_separator = &apos;X&apos; filename = image_descr_path &quot; Name of file
read_by_line = &apos;X&apos; &quot; File Written Line-By-Line to the Internal Table filetype = &apos;ASC&apos; &quot; File Type (ASCII, Binary)
CHANGING has_field_separator = &apos;X&apos;
data_tab = image_descriptions &quot; Transfer table for file contents read_by_line = &apos;X&apos; &quot; File Written Line-By-Line to the Internal Table
EXCEPTIONS CHANGING
file_open_error = 1 data_tab = image_descriptions &quot; Transfer table for file contents
file_read_error = 2 EXCEPTIONS
no_batch = 3 file_open_error = 1
gui_refuse_filetransfer = 4 file_read_error = 2
invalid_type = 5 no_batch = 3
no_authority = 6 gui_refuse_filetransfer = 4
unknown_error = 7 invalid_type = 5
bad_data_format = 8 no_authority = 6
header_not_allowed = 9 unknown_error = 7
separator_not_allowed = 10 bad_data_format = 8
header_too_long = 11 header_not_allowed = 9
unknown_dp_error = 12 separator_not_allowed = 10
access_denied = 13 header_too_long = 11
dp_out_of_memory = 14 unknown_dp_error = 12
disk_full = 15 access_denied = 13
dp_timeout = 16 dp_out_of_memory = 14
not_supported_by_gui = 17 disk_full = 15
error_no_gui = 18 dp_timeout = 16
OTHERS = 19 not_supported_by_gui = 17
). error_no_gui = 18
IF sy-subrc &lt;&gt; 0. OTHERS = 19
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno ).
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. IF sy-subrc &lt;&gt; 0.
ENDIF. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
&quot; Creates active sheet ENDIF.
CREATE OBJECT lo_excel.
&quot; Creates active sheet
&quot; Create Styles CREATE OBJECT lo_excel.
&quot; Create an underline double style
lo_style_month = lo_excel-&gt;add_new_style( ). &quot; Create Styles
&quot; lo_style_month-&gt;font-&gt;underline = abap_true. &quot; Create an underline double style
&quot; lo_style_month-&gt;font-&gt;underline_mode = zcl_excel_style_font=&gt;c_underline_single. lo_style_month = lo_excel-&gt;add_new_style( ).
lo_style_month-&gt;font-&gt;name = zcl_excel_style_font=&gt;c_name_roman. &quot; lo_style_month-&gt;font-&gt;underline = abap_true.
lo_style_month-&gt;font-&gt;scheme = zcl_excel_style_font=&gt;c_scheme_none. &quot; lo_style_month-&gt;font-&gt;underline_mode = zcl_excel_style_font=&gt;c_underline_single.
lo_style_month-&gt;font-&gt;family = zcl_excel_style_font=&gt;c_family_roman. lo_style_month-&gt;font-&gt;name = zcl_excel_style_font=&gt;c_name_roman.
lo_style_month-&gt;font-&gt;bold = abap_true. lo_style_month-&gt;font-&gt;scheme = zcl_excel_style_font=&gt;c_scheme_none.
lo_style_month-&gt;font-&gt;size = 36. lo_style_month-&gt;font-&gt;family = zcl_excel_style_font=&gt;c_family_roman.
lv_style_month_guid = lo_style_month-&gt;get_guid( ). lo_style_month-&gt;font-&gt;bold = abap_true.
&quot; Create border object lo_style_month-&gt;font-&gt;size = 36.
CREATE OBJECT lo_border_dark. lv_style_month_guid = lo_style_month-&gt;get_guid( ).
lo_border_dark-&gt;border_color-rgb = zcl_excel_style_color=&gt;c_black. &quot; Create border object
lo_border_dark-&gt;border_style = zcl_excel_style_border=&gt;c_border_thin. CREATE OBJECT lo_border_dark.
&quot;Create style with border lo_border_dark-&gt;border_color-rgb = zcl_excel_style_color=&gt;c_black.
lo_style_border = lo_excel-&gt;add_new_style( ). lo_border_dark-&gt;border_style = zcl_excel_style_border=&gt;c_border_thin.
lo_style_border-&gt;borders-&gt;allborders = lo_border_dark. &quot;Create style with border
lo_style_border-&gt;alignment-&gt;horizontal = zcl_excel_style_alignment=&gt;c_horizontal_right. lo_style_border = lo_excel-&gt;add_new_style( ).
lo_style_border-&gt;alignment-&gt;vertical = zcl_excel_style_alignment=&gt;c_vertical_top. lo_style_border-&gt;borders-&gt;allborders = lo_border_dark.
lv_style_border_guid = lo_style_border-&gt;get_guid( ). lo_style_border-&gt;alignment-&gt;horizontal = zcl_excel_style_alignment=&gt;c_horizontal_right.
&quot;Create style alignment center lo_style_border-&gt;alignment-&gt;vertical = zcl_excel_style_alignment=&gt;c_vertical_top.
lo_style_center = lo_excel-&gt;add_new_style( ). lv_style_border_guid = lo_style_border-&gt;get_guid( ).
lo_style_center-&gt;alignment-&gt;horizontal = zcl_excel_style_alignment=&gt;c_horizontal_center. &quot;Create style alignment center
lo_style_center-&gt;alignment-&gt;vertical = zcl_excel_style_alignment=&gt;c_vertical_top. lo_style_center = lo_excel-&gt;add_new_style( ).
lv_style_center_guid = lo_style_center-&gt;get_guid( ). lo_style_center-&gt;alignment-&gt;horizontal = zcl_excel_style_alignment=&gt;c_horizontal_center.
lo_style_center-&gt;alignment-&gt;vertical = zcl_excel_style_alignment=&gt;c_vertical_top.
lv_style_center_guid = lo_style_center-&gt;get_guid( ).
&quot; Get Month Names
CALL FUNCTION &apos;MONTH_NAMES_GET&apos;
TABLES &quot; Get Month Names
month_names = month_names. CALL FUNCTION &apos;MONTH_NAMES_GET&apos;
TABLES
zcl_date_calculation=&gt;months_between_two_dates( month_names = month_names.
EXPORTING
i_date_from = p_from zcl_date_calculation=&gt;months_between_two_dates(
i_date_to = p_to EXPORTING
i_incl_to = abap_true i_date_from = p_from
IMPORTING i_date_to = p_to
e_month = month i_incl_to = abap_true
). IMPORTING
e_month = month
date_from = p_from. ).
WHILE count &lt;= month. date_from = p_from.
IF count = 1.
&quot; Get active sheet WHILE count &lt;= month.
lo_worksheet = lo_excel-&gt;get_active_worksheet( ). IF count = 1.
ELSE. &quot; Get active sheet
lo_worksheet = lo_excel-&gt;add_new_worksheet( ). lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
ENDIF. ELSE.
lo_worksheet = lo_excel-&gt;add_new_worksheet( ).
lo_worksheet-&gt;zif_excel_sheet_properties~selected = zif_excel_sheet_properties=&gt;c_selected. ENDIF.
title = count. lo_worksheet-&gt;zif_excel_sheet_properties~selected = zif_excel_sheet_properties=&gt;c_selected.
value = count.
CONDENSE title. title = count.
CONDENSE value. value = count.
lo_worksheet-&gt;set_title( title ). CONDENSE title.
lo_worksheet-&gt;set_print_gridlines( abap_false ). CONDENSE value.
lo_worksheet-&gt;sheet_setup-&gt;paper_size = zcl_excel_sheet_setup=&gt;c_papersize_a4. lo_worksheet-&gt;set_title( title ).
lo_worksheet-&gt;sheet_setup-&gt;margin_top = &apos;0.80&apos;. lo_worksheet-&gt;set_print_gridlines( abap_false ).
lo_worksheet-&gt;sheet_setup-&gt;margin_left = &apos;0.55&apos;. lo_worksheet-&gt;sheet_setup-&gt;paper_size = zcl_excel_sheet_setup=&gt;c_papersize_a4.
lo_worksheet-&gt;sheet_setup-&gt;margin_right = &apos;0.05&apos;. lo_worksheet-&gt;sheet_setup-&gt;margin_top = &apos;0.80&apos;.
lo_worksheet-&gt;sheet_setup-&gt;margin_bottom = &apos;0.30&apos;. lo_worksheet-&gt;sheet_setup-&gt;margin_left = &apos;0.55&apos;.
lo_worksheet-&gt;get_column_dimension( &apos;A&apos; )-&gt;set_width( &apos;1.0&apos; ). lo_worksheet-&gt;sheet_setup-&gt;margin_right = &apos;0.05&apos;.
lo_worksheet-&gt;get_column_dimension( &apos;B&apos; )-&gt;set_width( &apos;2.0&apos; ). lo_worksheet-&gt;sheet_setup-&gt;margin_bottom = &apos;0.30&apos;.
lo_worksheet-&gt;get_column_dimension( &apos;K&apos; )-&gt;set_width( &apos;3.0&apos; ). lo_col_dim = lo_worksheet-&gt;get_column_dimension( &apos;A&apos; ).
lo_worksheet-&gt;sheet_setup-&gt;horizontal_centered = abap_true. lo_col_dim-&gt;set_width( &apos;1.0&apos; ).
lo_col_dim = lo_worksheet-&gt;get_column_dimension( &apos;B&apos; ).
&quot; Add Month Name lo_col_dim-&gt;set_width( &apos;2.0&apos; ).
month_nr = date_from+4(2). lo_col_dim = lo_worksheet-&gt;get_column_dimension( &apos;K&apos; ).
READ TABLE month_names WITH KEY mnr = month_nr ASSIGNING &lt;month_name&gt;. lo_col_dim-&gt;set_width( &apos;3.0&apos; ).
CONCATENATE &lt;month_name&gt;-ltx ` ` date_from(4) INTO value. lo_worksheet-&gt;sheet_setup-&gt;horizontal_centered = abap_true.
row = from_row - 2.
lo_worksheet-&gt;set_cell( &quot; Add Month Name
EXPORTING month_nr = date_from+4(2).
ip_column = from_col &quot; Cell Column READ TABLE month_names WITH KEY mnr = month_nr ASSIGNING &lt;month_name&gt;.
ip_row = row &quot; Cell Row CONCATENATE &lt;month_name&gt;-ltx ` ` date_from(4) INTO value.
ip_value = value &quot; Cell Value row = from_row - 2.
ip_style = lv_style_month_guid lo_worksheet-&gt;set_cell(
). EXPORTING
ip_column = from_col &quot; Cell Column
to_col_int = zcl_excel_common=&gt;convert_column2int( from_col ). ip_row = row &quot; Cell Row
to_col = zcl_excel_common=&gt;convert_column2alpha( to_col_int + 7 ). ip_value = value &quot; Cell Value
ip_style = lv_style_month_guid
lo_worksheet-&gt;set_merge( ).
EXPORTING
ip_column_start = from_col &quot; Cell Column Start to_col_int = zcl_excel_common=&gt;convert_column2int( from_col ) + 7.
ip_column_end = to_col &quot; Cell Column End to_col = zcl_excel_common=&gt;convert_column2alpha( to_col_int ).
ip_row = row &quot; Cell Row
ip_row_to = row &quot; Cell Row lo_worksheet-&gt;set_merge(
). EXPORTING
ip_column_start = from_col &quot; Cell Column Start
&quot; Add drawing from a XSTRING read from a file ip_column_end = to_col &quot; Cell Column End
UNASSIGN &lt;img_descr&gt;. ip_row = row &quot; Cell Row
READ TABLE image_descriptions WITH KEY month_nr = month_nr ASSIGNING &lt;img_descr&gt;. ip_row_to = row &quot; Cell Row
IF &lt;img_descr&gt; IS ASSIGNED. ).
value = &lt;img_descr&gt;-descr.
row = from_row - 4. &quot; Add drawing from a XSTRING read from a file
lo_worksheet-&gt;set_cell( UNASSIGN &lt;img_descr&gt;.
EXPORTING READ TABLE image_descriptions WITH KEY month_nr = month_nr ASSIGNING &lt;img_descr&gt;.
ip_column = from_col &quot; Cell Column IF &lt;img_descr&gt; IS ASSIGNED.
ip_row = row &quot; Cell Row value = &lt;img_descr&gt;-descr.
ip_value = value &quot; Cell Value row = from_row - 3.
). lo_worksheet-&gt;set_cell(
lo_worksheet-&gt;get_row_dimension( row )-&gt;set_row_height( &apos;18.0&apos; ). EXPORTING
ip_column = from_col &quot; Cell Column
CONCATENATE p_path lv_file_separator &lt;img_descr&gt;-filename INTO image_path. ip_row = row &quot; Cell Row
lo_drawing = lo_excel-&gt;add_new_drawing( ). ip_value = value &quot; Cell Value
lo_drawing-&gt;set_position( ip_from_row = 1 ).
ip_from_col = &apos;B&apos; ). lo_row_dim = lo_worksheet-&gt;get_row_dimension( row ).
lo_row_dim-&gt;set_row_height( &apos;22.0&apos; ).
lv_content = zcl_helper=&gt;load_image( image_path ).
width = c_height * c_factor. CONCATENATE p_path lv_file_separator &lt;img_descr&gt;-filename INTO image_path.
lo_drawing-&gt;set_media( ip_media = lv_content lo_drawing = lo_excel-&gt;add_new_drawing( ).
ip_media_type = &apos;jpg&apos; lo_drawing-&gt;set_position( ip_from_row = 1
ip_width = width ip_from_col = &apos;B&apos; ).
ip_height = c_height ).
lo_worksheet-&gt;add_drawing( lo_drawing ). lv_content = zcl_helper=&gt;load_image( image_path ).
ENDIF. width = c_height * c_factor.
lo_drawing-&gt;set_media( ip_media = lv_content
&quot; Add Calendar ip_media_type = &apos;jpg&apos;
CALL FUNCTION &apos;SLS_MISC_GET_LAST_DAY_OF_MONTH&apos; ip_width = width
EXPORTING ip_height = c_height ).
day_in = date_from lo_worksheet-&gt;add_drawing( lo_drawing ).
IMPORTING ENDIF.
last_day_of_month = date_to.
&quot; Add Calendar
zcl_helper=&gt;add_calendar( CALL FUNCTION &apos;SLS_MISC_GET_LAST_DAY_OF_MONTH&apos;
EXPORTING EXPORTING
i_date_from = date_from day_in = date_from
i_date_to = date_to IMPORTING
i_from_row = from_row last_day_of_month = date_to.
i_from_col = from_col
i_day_style = lv_style_border_guid zcl_helper=&gt;add_calendar(
i_cw_style = lv_style_center_guid EXPORTING
CHANGING i_date_from = date_from
c_worksheet = lo_worksheet i_date_to = date_to
). i_from_row = from_row
i_from_col = from_col
count = count + 1. i_day_style = lv_style_border_guid
date_from = date_to + 1. i_cw_style = lv_style_center_guid
ENDWHILE. CHANGING
c_worksheet = lo_worksheet
lo_excel-&gt;set_active_sheet_index_by_name( &apos;1&apos; ). ).
CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. count = count + 1.
lv_file = lo_excel_writer-&gt;write_file( lo_excel ). date_from = date_to + 1.
ENDWHILE.
&quot; Convert to binary
CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos; lo_excel-&gt;set_active_sheet_index_by_name( &apos;1&apos; ).
EXPORTING
buffer = lv_file CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
IMPORTING lv_file = lo_excel_writer-&gt;write_file( lo_excel ).
output_length = lv_bytecount
TABLES &quot; Convert to binary
binary_tab = lt_file_tab. CALL FUNCTION &apos;SCMS_XSTRING_TO_BINARY&apos;
* &quot; This method is only available on AS ABAP &gt; 6.40 EXPORTING
* lt_file_tab = cl_bcs_convert=&gt;xstring_to_solix( iv_xstring = lv_file ). buffer = lv_file
* lv_bytecount = xstrlen( lv_file ). IMPORTING
output_length = lv_bytecount
&quot; Save the file TABLES
cl_gui_frontend_services=&gt;gui_download( binary_tab = lt_file_tab.
EXPORTING bin_filesize = lv_bytecount * &quot; This method is only available on AS ABAP &gt; 6.40
filename = lv_full_path * lt_file_tab = cl_bcs_convert=&gt;xstring_to_solix( iv_xstring = lv_file ).
filetype = &apos;BIN&apos; * lv_bytecount = xstrlen( lv_file ).
CHANGING data_tab = lt_file_tab
EXCEPTIONS &quot; Save the file
file_write_error = 1 cl_gui_frontend_services=&gt;gui_download(
no_batch = 2 EXPORTING bin_filesize = lv_bytecount
gui_refuse_filetransfer = 3 filename = lv_full_path
invalid_type = 4 filetype = &apos;BIN&apos;
no_authority = 5 CHANGING data_tab = lt_file_tab
unknown_error = 6 EXCEPTIONS
header_not_allowed = 7 file_write_error = 1
separator_not_allowed = 8 no_batch = 2
filesize_not_allowed = 9 gui_refuse_filetransfer = 3
header_too_long = 10 invalid_type = 4
dp_error_create = 11 no_authority = 5
dp_error_send = 12 unknown_error = 6
dp_error_write = 13 header_not_allowed = 7
unknown_dp_error = 14 separator_not_allowed = 8
access_denied = 15 filesize_not_allowed = 9
dp_out_of_memory = 16 header_too_long = 10
disk_full = 17 dp_error_create = 11
dp_timeout = 18 dp_error_send = 12
file_not_found = 19 dp_error_write = 13
dataprovider_exception = 20 unknown_dp_error = 14
control_flush_error = 21 access_denied = 15
not_supported_by_gui = 22 dp_out_of_memory = 16
error_no_gui = 23 disk_full = 17
OTHERS = 24 dp_timeout = 18
). file_not_found = 19
IF sy-subrc &lt;&gt; 0. dataprovider_exception = 20
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno control_flush_error = 21
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. not_supported_by_gui = 22
ENDIF.</source> error_no_gui = 23
</PROG> OTHERS = 24
).
IF sy-subrc &lt;&gt; 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.</source>
</PROG>

View File

@ -1,348 +1,358 @@
<?xml version="1.0" encoding="utf-16"?> <?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_CALENDAR_CLASSES" VARCL="X" SUBC="I" CNAM="DEVELOPER" CDAT="20111229" UNAM="DEVELOPER" UDAT="20111230" VERN="000057" RMAND="001" RLOAD="E" SDATE="20111230" STIME="102417" IDATE="20111230" ITIME="102417" UCCHECK="X"> <PROG NAME="ZDEMO_CALENDAR_CLASSES" VARCL="X" SUBC="I" CNAM="DEVELOPER" CDAT="20111229" UNAM="DEVELOPER" UDAT="20120619" VERN="000062" RMAND="001" RLOAD="E" SDATE="20120619" STIME="060152" IDATE="20120619" ITIME="060152" UCCHECK="X">
<textPool> <textPool>
<language SPRAS="E"> <language SPRAS="E">
<textElement ID="R" ENTRY="Include ZDEMO_CALENDAR_CLASSES" LENGTH="30 "/> <textElement ID="R" ENTRY="Include ZDEMO_CALENDAR_CLASSES" LENGTH="30 "/>
</language> </language>
</textPool> </textPool>
<source>*&amp;---------------------------------------------------------------------* <source>*&amp;---------------------------------------------------------------------*
*&amp; Include ZDEMO_CALENDAR_CLASSES *&amp; Include ZDEMO_CALENDAR_CLASSES
*&amp;---------------------------------------------------------------------* *&amp;---------------------------------------------------------------------*
*&amp;---------------------------------------------------------------------* *&amp;---------------------------------------------------------------------*
*&amp; Class ZCL_DATE_CALCULATION *&amp; Class ZCL_DATE_CALCULATION
*&amp;---------------------------------------------------------------------* *&amp;---------------------------------------------------------------------*
* Text * Text
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
CLASS zcl_date_calculation DEFINITION. CLASS zcl_date_calculation DEFINITION.
PUBLIC SECTION. PUBLIC SECTION.
CLASS-METHODS: months_between_two_dates CLASS-METHODS: months_between_two_dates
IMPORTING IMPORTING
i_date_from TYPE datum i_date_from TYPE datum
i_date_to TYPE datum i_date_to TYPE datum
i_incl_to TYPE flag i_incl_to TYPE flag
EXPORTING EXPORTING
e_month TYPE i. e_month TYPE i.
ENDCLASS. &quot;ZCL_DATE_CALCULATION ENDCLASS. &quot;ZCL_DATE_CALCULATION
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* CLASS ZCL_DATE_CALCULATION IMPLEMENTATION * CLASS ZCL_DATE_CALCULATION IMPLEMENTATION
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* *
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
CLASS zcl_date_calculation IMPLEMENTATION. CLASS zcl_date_calculation IMPLEMENTATION.
METHOD months_between_two_dates. METHOD months_between_two_dates.
DATA: date_to TYPE datum. DATA: date_to TYPE datum.
DATA: BEGIN OF datum_von, DATA: BEGIN OF datum_von,
jjjj(4) TYPE n, jjjj(4) TYPE n,
mm(2) TYPE n, mm(2) TYPE n,
tt(2) TYPE n, tt(2) TYPE n,
END OF datum_von. END OF datum_von.
DATA: BEGIN OF datum_bis, DATA: BEGIN OF datum_bis,
jjjj(4) TYPE n, jjjj(4) TYPE n,
mm(2) TYPE n, mm(2) TYPE n,
tt(2) TYPE n, tt(2) TYPE n,
END OF datum_bis. END OF datum_bis.
e_month = 0. e_month = 0.
CHECK NOT ( i_date_from IS INITIAL ) CHECK NOT ( i_date_from IS INITIAL )
AND NOT ( i_date_to IS INITIAL ). AND NOT ( i_date_to IS INITIAL ).
date_to = i_date_to. date_to = i_date_to.
IF i_incl_to = abap_true. IF i_incl_to = abap_true.
date_to = date_to + 1. date_to = date_to + 1.
ENDIF. ENDIF.
datum_von = i_date_from. datum_von = i_date_from.
datum_bis = date_to. datum_bis = date_to.
e_month = ( datum_bis-jjjj - datum_von-jjjj ) * 12 e_month = ( datum_bis-jjjj - datum_von-jjjj ) * 12
+ ( datum_bis-mm - datum_von-mm ). + ( datum_bis-mm - datum_von-mm ).
ENDMETHOD. &quot;MONTHS_BETWEEN_TWO_DATES ENDMETHOD. &quot;MONTHS_BETWEEN_TWO_DATES
ENDCLASS. &quot;ZCL_DATE_CALCULATION IMPLEMENTATION ENDCLASS. &quot;ZCL_DATE_CALCULATION IMPLEMENTATION
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* CLASS zcl_date_calculation_test DEFINITION * CLASS zcl_date_calculation_test DEFINITION
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* *
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
CLASS zcl_date_calculation_test DEFINITION FOR TESTING CLASS zcl_date_calculation_test DEFINITION FOR TESTING
RISK LEVEL HARMLESS &quot; DURATION SHORT
DURATION SHORT. &quot; RISK LEVEL HARMLESS
PUBLIC SECTION. &quot;#AU Duration Medium
METHODS: &quot;#AU Risk_Level Harmless
months_between_two_dates FOR TESTING. .
ENDCLASS. &quot;zcl_date_calculation_test DEFINITION PUBLIC SECTION.
*----------------------------------------------------------------------* METHODS:
* CLASS zcl_date_calculation_test IMPLEMENTATION months_between_two_dates FOR TESTING.
*----------------------------------------------------------------------* ENDCLASS. &quot;zcl_date_calculation_test DEFINITION
* *----------------------------------------------------------------------*
*----------------------------------------------------------------------* * CLASS zcl_date_calculation_test IMPLEMENTATION
CLASS zcl_date_calculation_test IMPLEMENTATION. *----------------------------------------------------------------------*
METHOD months_between_two_dates. *
*----------------------------------------------------------------------*
DATA: date_from TYPE datum VALUE &apos;20120101&apos;, CLASS zcl_date_calculation_test IMPLEMENTATION.
date_to TYPE datum VALUE &apos;20121231&apos;. METHOD months_between_two_dates.
DATA: month TYPE i.
DATA: date_from TYPE datum VALUE &apos;20120101&apos;,
zcl_date_calculation=&gt;months_between_two_dates( date_to TYPE datum VALUE &apos;20121231&apos;.
EXPORTING DATA: month TYPE i.
i_date_from = date_from
i_date_to = date_to zcl_date_calculation=&gt;months_between_two_dates(
i_incl_to = abap_true EXPORTING
IMPORTING i_date_from = date_from
e_month = month i_date_to = date_to
). i_incl_to = abap_true
IMPORTING
cl_aunit_assert=&gt;assert_equals( e_month = month
exp = 12 &quot; Data Object with Expected Type ).
act = month &quot; Data Object with Current Value
msg = &apos;Calculated date is wrong&apos; &quot; Message in Case of Error cl_aunit_assert=&gt;assert_equals(
). exp = 12 &quot; Data Object with Expected Type
act = month &quot; Data Object with Current Value
ENDMETHOD. &quot;months_between_two_dates msg = &apos;Calculated date is wrong&apos; &quot; Message in Case of Error
ENDCLASS. &quot;zcl_date_calculation_test IMPLEMENTATION ).
*----------------------------------------------------------------------*
* CLASS zcl_helper DEFINITION ENDMETHOD. &quot;months_between_two_dates
*----------------------------------------------------------------------* ENDCLASS. &quot;zcl_date_calculation_test IMPLEMENTATION
* *----------------------------------------------------------------------*
*----------------------------------------------------------------------* * CLASS zcl_helper DEFINITION
CLASS zcl_helper DEFINITION. *----------------------------------------------------------------------*
PUBLIC SECTION. *
CLASS-METHODS: *----------------------------------------------------------------------*
load_image CLASS zcl_helper DEFINITION.
IMPORTING PUBLIC SECTION.
filename TYPE string CLASS-METHODS:
RETURNING value(r_image) TYPE xstring, load_image
add_calendar IMPORTING
IMPORTING filename TYPE string
i_date_from TYPE datum RETURNING value(r_image) TYPE xstring,
i_date_to TYPE datum add_calendar
i_from_row TYPE zexcel_cell_row IMPORTING
i_from_col TYPE zexcel_cell_column_alpha i_date_from TYPE datum
i_day_style TYPE zexcel_cell_style i_date_to TYPE datum
i_cw_style TYPE zexcel_cell_style i_from_row TYPE zexcel_cell_row
CHANGING i_from_col TYPE zexcel_cell_column_alpha
c_worksheet TYPE REF TO zcl_excel_worksheet, i_day_style TYPE zexcel_cell_style
add_calender_week i_cw_style TYPE zexcel_cell_style
IMPORTING CHANGING
i_date TYPE datum c_worksheet TYPE REF TO zcl_excel_worksheet,
i_row TYPE zexcel_cell_row add_calender_week
i_col TYPE zexcel_cell_column_alpha IMPORTING
i_style TYPE zexcel_cell_style i_date TYPE datum
CHANGING i_row TYPE zexcel_cell_row
c_worksheet TYPE REF TO zcl_excel_worksheet. i_col TYPE zexcel_cell_column_alpha
ENDCLASS. &quot;zcl_helper DEFINITION i_style TYPE zexcel_cell_style
CHANGING
*----------------------------------------------------------------------* c_worksheet TYPE REF TO zcl_excel_worksheet.
* CLASS zcl_helper IMPLEMENTATION ENDCLASS. &quot;zcl_helper DEFINITION
*----------------------------------------------------------------------*
* *----------------------------------------------------------------------*
*----------------------------------------------------------------------* * CLASS zcl_helper IMPLEMENTATION
CLASS zcl_helper IMPLEMENTATION. *----------------------------------------------------------------------*
METHOD load_image. *
&quot;Load samle image *----------------------------------------------------------------------*
DATA: lt_bin TYPE solix_tab, CLASS zcl_helper IMPLEMENTATION.
lv_len TYPE i. METHOD load_image.
&quot;Load samle image
CALL METHOD cl_gui_frontend_services=&gt;gui_upload DATA: lt_bin TYPE solix_tab,
EXPORTING lv_len TYPE i.
filename = filename
filetype = &apos;BIN&apos; CALL METHOD cl_gui_frontend_services=&gt;gui_upload
IMPORTING EXPORTING
filelength = lv_len filename = filename
CHANGING filetype = &apos;BIN&apos;
data_tab = lt_bin IMPORTING
EXCEPTIONS filelength = lv_len
file_open_error = 1 CHANGING
file_read_error = 2 data_tab = lt_bin
no_batch = 3 EXCEPTIONS
gui_refuse_filetransfer = 4 file_open_error = 1
invalid_type = 5 file_read_error = 2
no_authority = 6 no_batch = 3
unknown_error = 7 gui_refuse_filetransfer = 4
bad_data_format = 8 invalid_type = 5
header_not_allowed = 9 no_authority = 6
separator_not_allowed = 10 unknown_error = 7
header_too_long = 11 bad_data_format = 8
unknown_dp_error = 12 header_not_allowed = 9
access_denied = 13 separator_not_allowed = 10
dp_out_of_memory = 14 header_too_long = 11
disk_full = 15 unknown_dp_error = 12
dp_timeout = 16 access_denied = 13
not_supported_by_gui = 17 dp_out_of_memory = 14
error_no_gui = 18 disk_full = 15
OTHERS = 19. dp_timeout = 16
IF sy-subrc &lt;&gt; 0. not_supported_by_gui = 17
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno error_no_gui = 18
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. OTHERS = 19.
ENDIF. IF sy-subrc &lt;&gt; 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
CALL FUNCTION &apos;SCMS_BINARY_TO_XSTRING&apos; WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXPORTING ENDIF.
input_length = lv_len
IMPORTING CALL FUNCTION &apos;SCMS_BINARY_TO_XSTRING&apos;
buffer = r_image EXPORTING
TABLES input_length = lv_len
binary_tab = lt_bin IMPORTING
EXCEPTIONS buffer = r_image
failed = 1 TABLES
OTHERS = 2. binary_tab = lt_bin
IF sy-subrc &lt;&gt; 0. EXCEPTIONS
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno failed = 1
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. OTHERS = 2.
ENDIF. IF sy-subrc &lt;&gt; 0.
ENDMETHOD. &quot;load_image MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
METHOD add_calendar. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
DATA: row TYPE zexcel_cell_row, ENDIF.
col_int TYPE zexcel_cell_column, ENDMETHOD. &quot;load_image
from_col_int TYPE zexcel_cell_column, METHOD add_calendar.
col TYPE zexcel_cell_column_alpha. DATA: row TYPE zexcel_cell_row,
DATA: lv_date TYPE datum, row_max TYPE i,
value TYPE string, col_int TYPE zexcel_cell_column,
weekday TYPE wotnr, col_max TYPE i,
weekrow TYPE wotnr VALUE 1, from_col_int TYPE zexcel_cell_column,
day TYPE i, col TYPE zexcel_cell_column_alpha,
width TYPE f, lr_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
height TYPE f. lr_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi.
DATA: hyperlink TYPE REF TO zcl_excel_hyperlink. DATA: lv_date TYPE datum,
value TYPE string,
DATA: day_names TYPE TABLE OF t246. weekday TYPE wotnr,
FIELD-SYMBOLS: &lt;day_name&gt; LIKE LINE OF day_names. weekrow TYPE wotnr VALUE 1,
day TYPE i,
lv_date = i_date_from. width TYPE f,
from_col_int = zcl_excel_common=&gt;convert_column2int( i_from_col ). height TYPE f.
&quot; Add description for Calendar Week DATA: hyperlink TYPE REF TO zcl_excel_hyperlink.
c_worksheet-&gt;set_cell(
EXPORTING DATA: day_names TYPE TABLE OF t246.
ip_column = i_from_col &quot; Cell Column FIELD-SYMBOLS: &lt;day_name&gt; LIKE LINE OF day_names.
ip_row = i_from_row &quot; Cell Row
ip_value = &apos;CW&apos;(001) &quot; Cell Value lv_date = i_date_from.
ip_style = i_cw_style from_col_int = zcl_excel_common=&gt;convert_column2int( i_from_col ).
). &quot; Add description for Calendar Week
c_worksheet-&gt;set_cell(
&quot; Add Days EXPORTING
CALL FUNCTION &apos;DAY_NAMES_GET&apos; ip_column = i_from_col &quot; Cell Column
TABLES ip_row = i_from_row &quot; Cell Row
day_names = day_names. ip_value = &apos;CW&apos;(001) &quot; Cell Value
ip_style = i_cw_style
LOOP AT day_names ASSIGNING &lt;day_name&gt;. ).
row = i_from_row.
col_int = from_col_int + &lt;day_name&gt;-wotnr. &quot; Add Days
col = zcl_excel_common=&gt;convert_column2alpha( col_int ). CALL FUNCTION &apos;DAY_NAMES_GET&apos;
value = &lt;day_name&gt;-langt. TABLES
c_worksheet-&gt;set_cell( day_names = day_names.
EXPORTING
ip_column = col &quot; Cell Column LOOP AT day_names ASSIGNING &lt;day_name&gt;.
ip_row = row &quot; Cell Row row = i_from_row.
ip_value = value &quot; Cell Value col_int = from_col_int + &lt;day_name&gt;-wotnr.
ip_style = i_cw_style col = zcl_excel_common=&gt;convert_column2alpha( col_int ).
). value = &lt;day_name&gt;-langt.
ENDLOOP. c_worksheet-&gt;set_cell(
EXPORTING
WHILE lv_date &lt;= i_date_to. ip_column = col &quot; Cell Column
day = lv_date+6(2). ip_row = row &quot; Cell Row
CALL FUNCTION &apos;FIMA_X_DAY_IN_MONTH_COMPUTE&apos; ip_value = value &quot; Cell Value
EXPORTING ip_style = i_cw_style
i_datum = lv_date ).
IMPORTING ENDLOOP.
e_wochentag_nr = weekday.
WHILE lv_date &lt;= i_date_to.
row = i_from_row + weekrow. day = lv_date+6(2).
col_int = from_col_int + weekday. CALL FUNCTION &apos;FIMA_X_DAY_IN_MONTH_COMPUTE&apos;
col = zcl_excel_common=&gt;convert_column2alpha( col_int ). EXPORTING
i_datum = lv_date
value = day. IMPORTING
CONDENSE value. e_wochentag_nr = weekday.
c_worksheet-&gt;set_cell( row = i_from_row + weekrow.
EXPORTING col_int = from_col_int + weekday.
ip_column = col &quot; Cell Column col = zcl_excel_common=&gt;convert_column2alpha( col_int ).
ip_row = row &quot; Cell Row
ip_value = value &quot; Cell Value value = day.
ip_style = i_day_style &quot; Single-Character Indicator CONDENSE value.
).
c_worksheet-&gt;set_cell(
IF weekday = 7. EXPORTING
&quot; Add Calender Week ip_column = col &quot; Cell Column
zcl_helper=&gt;add_calender_week( ip_row = row &quot; Cell Row
EXPORTING ip_value = value &quot; Cell Value
i_date = lv_date ip_style = i_day_style &quot; Single-Character Indicator
i_row = row ).
i_col = i_from_col
i_style = i_cw_style IF weekday = 7.
CHANGING &quot; Add Calender Week
c_worksheet = c_worksheet zcl_helper=&gt;add_calender_week(
). EXPORTING
weekrow = weekrow + 1. i_date = lv_date
ENDIF. i_row = row
lv_date = lv_date + 1. i_col = i_from_col
ENDWHILE. i_style = i_cw_style
&quot; Add Calender Week CHANGING
zcl_helper=&gt;add_calender_week( c_worksheet = c_worksheet
EXPORTING ).
i_date = lv_date weekrow = weekrow + 1.
i_row = row ENDIF.
i_col = i_from_col lv_date = lv_date + 1.
i_style = i_cw_style ENDWHILE.
CHANGING &quot; Add Calender Week
c_worksheet = c_worksheet zcl_helper=&gt;add_calender_week(
). EXPORTING
&quot; Add Created with abap2xlsx i_date = lv_date
row = row + 2. i_row = row
value = &apos;Created with abap2xlsx. Find more information at http://abap2xlsx.org.&apos;(002). i_col = i_from_col
hyperlink = zcl_excel_hyperlink=&gt;create_external_link( &apos;http://abap2xlsx.org&apos; ). &quot;#EC NOTEXT i_style = i_cw_style
c_worksheet-&gt;set_cell( CHANGING
EXPORTING c_worksheet = c_worksheet
ip_column = i_from_col &quot; Cell Column ).
ip_row = row &quot; Cell Row &quot; Add Created with abap2xlsx
ip_value = value &quot; Cell Value row = row + 2.
ip_hyperlink = hyperlink value = &apos;Created with abap2xlsx. Find more information at http://abap2xlsx.org.&apos;(002).
). hyperlink = zcl_excel_hyperlink=&gt;create_external_link( &apos;http://abap2xlsx.org&apos; ). &quot;#EC NOTEXT
col_int = from_col_int. c_worksheet-&gt;set_cell(
WHILE col_int &lt;= from_col_int + 7. EXPORTING
col = zcl_excel_common=&gt;convert_column2alpha( col_int ). ip_column = i_from_col &quot; Cell Column
IF sy-index = 1. ip_row = row &quot; Cell Row
width = &apos;5.0&apos;. ip_value = value &quot; Cell Value
ELSE. ip_hyperlink = hyperlink
width = &apos;11.4&apos;. ).
ENDIF. col_int = from_col_int.
col_max = from_col_int + 7.
c_worksheet-&gt;get_column_dimension( col )-&gt;set_width( width ). WHILE col_int &lt;= col_max.
col_int = col_int + 1. col = zcl_excel_common=&gt;convert_column2alpha( col_int ).
ENDWHILE. IF sy-index = 1.
row = i_from_row + 1. width = &apos;5.0&apos;.
WHILE row &lt;= i_from_row + 6. ELSE.
height = 50. width = &apos;11.4&apos;.
c_worksheet-&gt;get_row_dimension( row )-&gt;set_row_height( height ). ENDIF.
row = row + 1. lr_col_dim = c_worksheet-&gt;get_column_dimension( col ).
ENDWHILE. lr_col_dim-&gt;set_width( width ).
ENDMETHOD. &quot;add_calendar col_int = col_int + 1.
ENDWHILE.
METHOD add_calender_week. row = i_from_row + 1.
DATA: week TYPE kweek, row_max = i_from_row + 6.
week_int TYPE i, WHILE row &lt;= row_max.
value TYPE string. height = 50.
&quot; Add Calender Week lr_row_dim = c_worksheet-&gt;get_row_dimension( row ).
CALL FUNCTION &apos;DATE_GET_WEEK&apos; lr_row_dim-&gt;set_row_height( height ).
EXPORTING row = row + 1.
date = i_date &quot; Date for which the week should be calculated ENDWHILE.
IMPORTING ENDMETHOD. &quot;add_calendar
week = week. &quot; Week for date (format:YYYYWW)
value = week+4(2). METHOD add_calender_week.
week_int = value. DATA: week TYPE kweek,
value = week_int. week_int TYPE i,
CONDENSE value. value TYPE string.
c_worksheet-&gt;set_cell( &quot; Add Calender Week
EXPORTING CALL FUNCTION &apos;DATE_GET_WEEK&apos;
ip_column = i_col &quot; Cell Column EXPORTING
ip_row = i_row &quot; Cell Row date = i_date &quot; Date for which the week should be calculated
ip_value = value &quot; Cell Value IMPORTING
ip_style = i_style week = week. &quot; Week for date (format:YYYYWW)
). value = week+4(2).
ENDMETHOD. &quot;add_calender_week week_int = value.
ENDCLASS. &quot;zcl_helper IMPLEMENTATION</source> value = week_int.
</PROG> CONDENSE value.
c_worksheet-&gt;set_cell(
EXPORTING
ip_column = i_col &quot; Cell Column
ip_row = i_row &quot; Cell Row
ip_value = value &quot; Cell Value
ip_style = i_style
).
ENDMETHOD. &quot;add_calender_week
ENDCLASS. &quot;zcl_helper IMPLEMENTATION</source>
</PROG>