Code: Alles auswählen.
INCLUDE ole2incl.
DATA: EXCEL TYPE OLE2_OBJECT, " Excel.Application
O_MAPL TYPE OLE2_OBJECT, " list of workbooks
WORKAREA TYPE OLE2_OBJECT, " Workbook
O_MAP TYPE OLE2_OBJECT, " Mappe
O_ACTIVE_WINDOW TYPE OLE2_OBJECT, " Active Window
O_ACTIVE_SHEET TYPE OLE2_OBJECT, " Active Sheet
O_CELL TYPE OLE2_OBJECT, " Cell
V_ZAHL TYPE P DECIMALS 2, " Number
V_VALUE(30) TYPE C,
zeile(10) TYPE i,
i(10) TYPE i. " Cell Value
CREATE OBJECT excel 'Excel.Application'.
SET PROPERTY OF excel 'VISIBLE' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workarea.
CALL METHOD OF workarea 'OPEN' EXPORTING #1 = 'C:\temp\kst_test.xls'.
GET PROPERTY OF excel 'ACTIVEWORKBOOK' = workarea.
V_VALUE = 'dummy'.
zeile = 2950.
WHILE V_VALUE <> ''.
zeile = zeile + 1.
*** Wert "Länge" auslesen
PERFORM GET_CELLVALUE USING zeile 1 V_VALUE.
WRITE: 'Benutzernamen: ', V_VALUE.
*** Wert "Breite" auslesen
PERFORM GET_CELLVALUE USING zeile 2 V_VALUE.
WRITE: 'Kostenstelle:', V_VALUE.
*** Wert "Höhe" auslesen
PERFORM GET_CELLVALUE USING zeile 3 V_VALUE.
WRITE: 'Bezeichnung der Organisationseinheit: ', V_VALUE.
ENDWHILE.
STOP.
*---------------------------------------------------------------------*
* FORM GET_CELLVALUE *
*---------------------------------------------------------------------*
FORM GET_CELLVALUE USING I J VAL.
* Zelle, aus der Ergebnis gelesen wird
* CALL METHOD OF EXCEL 'ActiveSheet' = O_ACTIVE_SHEET
* EXPORTING
* #1 = SPACE
* #2 = 1 "Drawing Objects
* #3 = 1 "Contents
* #4 = 1. "Scenarios
CALL METHOD OF EXCEL 'Cells' = O_CELL
EXPORTING
#1 = I "Zeile
#2 = J. "Spalte
* Zellinhalt lesen
* GET PROPERTY OF O_ACTIVE_SHEET 'Value' = V_VALUE.
GET PROPERTY OF O_CELL 'Value' = V_VALUE.
IF V_VALUE CO '0123456789. '.
V_ZAHL = V_VALUE.
VAL = V_ZAHL.
ELSE.
VAL = V_VALUE.
ENDIF.
* Objekt freigeben
* FREE OBJECT O_ACTIVE_SHEET.
FREE OBJECT O_CELL.
ENDFORM.