Skip to Content
0
Former Member
Mar 20, 2009 at 01:47 PM

OLE using SUMIF

269 Views

Hi experts,

I m making an Excel workbook with OLE object.

I would like to use the SUMIF function of excel but it doesn't work

I dont understand why because it works with the simple SUM function :/

sample :

(you can copy/paste it)

INCLUDE ole2incl.

DATA application TYPE ole2_object.
DATA excel TYPE ole2_object.
DATA workbook TYPE ole2_object.
DATA cell1 TYPE ole2_object.
DATA cells TYPE ole2_object.

CREATE OBJECT excel 'EXCEL.APPLICATION'.
SET PROPERTY OF excel 'Visible' = 1.
GET PROPERTY OF excel 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
GET PROPERTY OF workbook 'Application' = application.
SET PROPERTY OF application 'SheetsInNewWorkbook' = 1. " nbsheets.

CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 5
  #2 = 3.
SET PROPERTY OF cell1 'Value' = 'ok'.

CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 6
  #2 = 3.
SET PROPERTY OF cell1 'Value' = 2.

CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 7
  #2 = 3.
SET PROPERTY OF cell1 'Value' = 2.

CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 5
  #2 = 6.
SET PROPERTY OF cell1 'Value' = 1.


CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 6
  #2 = 6.
SET PROPERTY OF cell1 'Value' = 2.

CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 7
  #2 = 6.
SET PROPERTY OF cell1 'Value' = 4.



CALL METHOD OF excel 'Cells' = cell1
  EXPORTING
  #1 = 8
  #2 = 6.
SET PROPERTY OF cell1 'Value' = '=SUMIF(C5:C7;"ok";F5:F7)'.

The function works when I use it in the excel after generation that's why I dont understand why it doesn't work during the genration !

For the information my excel is in French but it works with the SUM -> SOMME function.

Any idea ? 😊

Thx