| 2.2.4.46.45 Worksheet::GetSelectionGetSelection
 DescriptionRetrieves the current selection from the worksheet.
 Syntaxint GetSelection( int & c1, int & c2, int & r1, int & r2, string * pstrAddress = NULL ) Parameters c1[output] Receives the index of the first column in the selection, if any c2[output] Receives the index of the last column in the selection, if any r1[output] Receives the index of the first row in the selection, if any r2[output] Receives the index of the last row in the selection, if any pstrAddress[output] if not NULL, pointer to receives the address of the Excel selection range as string (assuming it is an Excel worksheet).Its default value is NULL.
 ReturnInteger indicating the type of selection. It can be a bitwise combination of one or more of the following:
 WKS_SEL_NONE  					// no selection
 WKS_SEL_EDIT					// one cell being edited
 WKS_SEL_COLUMN					// one or more entire columns selected
 WKS_SEL_ROW						// one or more entire rows selected
 WKS_SEL_RANGE					// more than one cell selected
 WKS_SEL_ONE_COL					// exactly one column selected
 WKS_SEL_DISCONTIGUOUS			// discontiguous columns selected
 WKS_SEL_ALL						// entire worksheet
 ExamplesEX1
 int Worksheet_GetSelection_Ex1()
{
    WorksheetPage wp = Project.WorksheetPages(0);
    if(!wp)
        return -1;
    
    Worksheet wks(wp.GetName());
    int r1, c1,r2, c2;
    string strAddress;
    int seltype = wks.GetSelection(c1, c2, r1, r2, &strAddress);
    printf("sel = %d\tr1 = %d\tc1 = %d\tr2 = %d\tc2 = %d\n", seltype, r1, c1, r2, c2);
    out_str(strAddress);
    return seltype;
}RemarkPlease note that the argument order is c1,c2,r1,r2 which is not the same as many other function of this type. You may use GetSelectedRange which follows a more consistent argument list of R1C1:R2C2. So this function is provided for backward compatible reason only
 See AlsoGetSelectedRange, SetSelectedRange
 Header to Includeorigin.h
 |