DataRange::SetName

Description

Update the Name property of the datarange.

Syntax

BOOL SetName( LPCSTR lpcszName, BOOL bCheckUnique = TRUE )

Parameters

lpcszName
[input]Pointer to string holding the new Name of the DataRange
bCheckUnique
[input]if TRUE, checking whether range name is unique in project.

Return

Returns true if lpcszNewName is successfully used to rename the DataRange

Examples

EX1

//This example will show how to set the name of the Datarange
void DataRange_SetName_Ex1(int nCol1 = 0, int nCol2 = 1)
{
    Worksheet wks ;
    wks.Create();
    if( wks )
    {
        while(wks.Columns(0))
            wks.DeleteCol(0);
 
        wks.AddCol("A");
        wks.AddCol("B");
        double rr;
        for(int j=0;j<2;j++)
        {
            for (int i=0;i<10;i++)
            {
                   rr=rnd();
                   wks.SetCell(i,j,rr*100);
            }
        }
        
        DataRange dr;
        dr.Add("X", wks, 0, nCol1, -1, nCol1);
        dr.Add("Y", wks, 0, nCol2, -1, nCol2);
        //set the name of the datarange
        dr.SetName("This is a Long Name for the Range");
        string strName = dr.GetName();
        out_str(strName);
        string strDescription = dr.GetDescription();
    }
}

Remark

See Also

header to Include

origin.h