Retrieves the current selection from the worksheet.
int GetSelection( int & c1, int & c2, int & r1, int & r2, string * pstrAddress = NULL )
Integer 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
EX1
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; }
Please 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
GetSelectedRange, SetSelectedRange
origin.h