[ABAP] ExcelOle – Range (Bereich) definieren

DATA: o_excel TYPE ole2_object.
DATA: o_range TYPE ole2_object.
DATA: o_font TYPE ole2_object.
DATA: o_interior TYPE ole2_object.

...

* Range (Bereich) definieren
CALL METHOD OF o_excel 'Range' = o_range
  EXPORTING
	#1 = 'A2'
	#2 = 'B2'.

* Range Schrift setzen
GET PROPERTY OF o_range 'Font' = o_font.
SET PROPERTY OF o_font 'Bold' = 1.
SET PROPERTY OF o_font 'ColorIndex' = 4.
SET PROPERTY OF o_font 'Size' = 12.

CALL METHOD OF o_range 'Select' .
CALL METHOD OF o_range 'BorderAround'
  EXPORTING
	#1 = 1  " Stil
	#2 = 2. " Dicke (1..4)

* Zellhintergrund setzen
CALL METHOD OF o_range 'Interior' = o_interior.
SET PROPERTY OF o_interior 'ColorIndex' = 6. " gelb
SET PROPERTY OF o_interior 'Pattern' = 1.

* Objekte wieder freigeben
FREE OBJECT: o_interior.
FREE OBJECT: o_font.
FREE OBJECT: o_range.