Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZDEMA_TEST84
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zdema_test84.
INCLUDE ole2incl.
DATA: excel TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
zelle TYPE ole2_object.
DATA: zeile TYPE i. "Zeile. Wird zur Laufzeit gesetzt
DATA: spalte TYPE i VALUE 1. "immer in Spalte 1
DATA: sy_tabix LIKE sy-tabix.
TYPES: BEGIN OF ty,
value(30) TYPE c,
END OF ty.
DATA:wa TYPE ty.
DATA:itab TYPE TABLE OF ty.
START-OF-SELECTION.
wa-value = '1'.
APPEND wa TO itab.
wa-value = '=wenn(A3="2";"X";"")'.
APPEND wa TO itab.
CREATE OBJECT excel 'excel.application'.
SET PROPERTY OF excel 'visible' = 1.
CALL METHOD OF excel 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
CALL METHOD OF excel 'Worksheets' = sheet
EXPORTING #1 = 1.
CALL METHOD OF sheet 'Activate'.
SET PROPERTY OF sheet 'Name' = 'Test1'.
LOOP AT itab INTO wa.
sy_tabix = sy-tabix. "Call method of sheet setzt sy-tabix neu
zeile = sy-tabix.
CALL METHOD OF sheet 'Cells' = zelle
EXPORTING #1 = zeile
#2 = spalte.
IF sy_tabix = '1'.
SET PROPERTY OF zelle 'Value' = wa-value.
ELSE.
SET PROPERTY OF zelle 'FormulaR1C1' = wa-value.
ENDIF.
ENDLOOP.
Code: Alles auswählen.
wa-value = '=wenn(A1=1;"X";"")'.
Code: Alles auswählen.
SET PROPERTY OF zelle 'FormulaR1C1' = wa-value.
Code: Alles auswählen.
SET PROPERTY OF zelle 'FormulaLocal' = wa-value.