DataRange::GetBookSheet

Description

Get book and sheet name of the index-th subrange.

Syntax

BOOL GetBookSheet( string & strBook, string & strSheet, int nIndex = 0 )

Parameters

strBook
[Output] book name of the booksheet.
strSheet
[Output] Sheet name of the booksheet.
nIndex
[Input] (offset)indicate the specified booksheet.

Return

Examples

//Get the first and second datarange's book name and sheet name.
void DataRange_GetBookSheet_Ex1()
{
        //assume the active workbook with two sheet and each has least two columns before run this code.
        Worksheet wks = Project.ActiveLayer();
        if ( !wks )
        {
                printf("Can not find any active worksheet!");
                return;
        }
        DataRange dr;
        dr.Create();//init the object
        dr.Add("X", wks, 0, 0, -1, 0);//add the first column as x range
        dr.Add("C", wks, 0, 1, -1, 1);
        
        WorksheetPage wksPage = wks.GetPage();
        Worksheet wks2 = wksPage.Layers(1); //get second layer
        if ( !wks2 )
        {
                printf("Can not get second worksheet layer!");
                return;
        }

        dr.Add("X", wks2, 0, 0, -1, 0); //second x range
        dr.Add("C", wks2, 0, 1, -1, 1); 
        
        string strBook, strSheet;
        dr.GetBookSheet(strBook, strSheet, 0);
        printf("The first xrange's Book and Sheet names are : %s, %s\n", strBook, strSheet);
        
        dr.GetBookSheet(strBook, strSheet, 1); //get second xrange's book and sheet
        printf("The second xrange's Book and Sheet names are : %s, %s\n", strBook, strSheet);
        return;
}

Remark

See Also

header to Include

origin.h