Worksheet::SetAsLabel

Description

Sets a row of the worksheet to a label of the given type.

Syntax

BOOL SetAsLabel( UINT nType, int index, BOOL bUndo = FALSE, BOOL bLabel = FALSE, BOOL bAppend = FALSE )

Parameters

nType
[input] Label type. From enumerated types RCLT_INVALID etc.
plus an optional offset for RCLT_PARAM, like RCLT_PARAM + 1, RCLT_PARAM + 2, etc.
index
[input] Row index to use as the source. If negative, the function will act on the selected full rows (in which case the existing selected data rows will be removed at the end).
Otherwise, it is 0-based index of the row. If bLabel is TRUE, it is the index of a label row (the type will be changed accordingly if needed), otherwise it is a data row.
bUndo
[input] Whether to support undo of change (TRUE) or not (FALSE);default value is FALSE.
bLabel
[input] It determines whether the row index is interpreted as the index of a label row (if TRUE) or a data row (if FALSE). Not used if index < 0;default is FALSE
bAppend
[input] Whether to append to the contents (TRUE) of an existing label (if any) or just replace its contents (FALSE);default is FALSE
bDeleteRow
[input] Whether to delete the source row if index >= 0;default is FALSE

Return

TRUE on success, FALSE on failure

Examples

EX1

// Create a worksheet, fill some rows with values then use data to fill Label header
void Worksheet_SetAsLabel_Ex1()
{
    Worksheet wks;
    wks.Create("origin.otw",CREATE_VISIBLE);
    
    if ( wks )
    {
        vector<string> v1(5), v2(5);
        // Put some data into worksheet just to show how this works
        for(int ii = 0; ii < 5; ii++)
        {
            string strText;
            strText.Format("ROW %d:COL 1",ii);
            v1[ii] = strText;
            strText.Format("ROW %d:COL 2",ii);
            v2[ii] = strText;
        }
        
        DataRange drOut;
        drOut.Add("X", wks, 0, 0, -1, 0);
        drOut.Add("Y", wks, 0, 1, -1, 1);
        drOut.SetData(&v2, &v1);
        
        UINT nType;
        int nRet;
        nType = RCLT_LONG_NAME;
        nRet = wks.SetAsLabel(nType, 0, FALSE); // Replace LONG NAME label from text in Row 1
        nType = RCLT_UNIT;
        nRet = wks.SetAsLabel(nType, 1, FALSE); // Replace UNIT label from text in Row 2
        nType = RCLT_COMMENT;
        nRet = wks.SetAsLabel(nType, 2, FALSE); // Replace COMMENT label from text in Row 3
        nType = RCLT_PARAM;
        nRet = wks.SetAsLabel(nType, 3, FALSE); // Replace PARAMETER label from text in Row 4
        nType = RCLT_PARAM + 1;
        nRet = wks.SetAsLabel(nType, 4, FALSE); // Replace PARAMETER label from text in Row 5
    }
    else
        out_str("No active worksheet");
    return;
}

EX2

// Worksheet should be active - pass 0..3, 0..MaxRow-1
int Worksheet_SetAsLabel_Ex2(UINT nType, int index, BOOL bUndo = FALSE, BOOL bLabel = FALSE, BOOL bAppend = FALSE, BOOL bDeleteRow = FALSE)
{
    Worksheet wks = Project.ActiveLayer();
    if(wks)
        return (int) wks.SetAsLabel(nType, index, bUndo, bLabel, bAppend, bDeleteRow);
}

Remark

See Also

Header to Include

origin.h