DataObject::ExecuteFormula

Description

Trigger the execution of Column/MatrixObject formula For Origin version 8 or later.

Syntax

BOOL ExecuteFormula( int nBegin = -1, int nEnd = -1, BOOL bUndo = TRUE, int nC1 = -1, int nC2 = -1, DWORD dwCtrl = 0, UINT nColRepeatCount = 0, UINT nRefColUID = 0 )

Parameters

nBegin
[input] begining row index (0 based), <0 indicate the first row; default is -1.
nEnd
[input] end row index (0 based), <0 indicate the last row; default is -1.
bUndo
[input] if this parameter is TRUE (by default) method can be undone.
nC1
[input] start col index (0 based), <0 indicate the first col; default is -1.
nC2
[output] end col index (0 based), <0 indicate the last col; default is -1.
dwCtrl
[input] control options enumerated as EXEC_FORMULA_*
nColRepeatCount
[input] internal use
nRefColUID
[input] internal use

Return

TRUE on success and FALSE on failure.

Examples

EX1

// Create a worksheet with column formulas in place and execute
void    DataObject_ExecuteFormula_Ex1()
{
    Worksheet wks;
    wks.Create("origin", CREATE_VISIBLE);
    Column col;
    col.Attach(wks, 0);
    col.SetFormula("5*(i-1)");
    BOOL bRet = col.ExecuteFormula();
}

EX2

 
void     DataObject_ExecuteFormula_Ex2()
{
        MatrixPage mp;
    mp.Create("origin");
    MatrixLayer ml = Project.ActiveLayer();
    MatrixObject moMy(ml, 0);
    if(moMy)
    {
        moMy.SetFormula("i*i");
        moMy.ExecuteFormula(0,-1, TRUE, 2,4);
    }
}

Remark

Must call SetFormula the set the formula before ExecuteFormula.

See Also

DataObject::GetFormula, DataObject::SetFormula

header to Include

origin.h