Find column in worksheet by searching for column long name. Also applies to MatrixObject in a MatrixLayer.
DataObject FindCol( LPCSTR lpcszColLabel, int nColBegin = 0, BOOL bCaseSensitive = false, BOOL bFullMatch = true, int nColEnd = -1, BOOL bAllowShortName = true )
A DataObject object
EX1
void Datasheet_FindCol_Ex1() { Worksheet wks; wks.Create(); wks.AddCol(); wks.Columns(0).SetLabel("AA01"); wks.Columns(1).SetLabel("AA"); wks.Columns(2).SetLabel("aa"); wks.Columns(2).SetName("Test"); wks.ShowLabels(); // search whole worksheet for label is "aa" without case sensitive Column col = wks.FindCol("aa"); // should be 2nd column "AA" if( col ) printf("1. The label of the column is %s.\n", col.GetLabel()); else printf("1. Fail to find column.\n"); // search whole worksheet for label is "aa" with case sensitive col = wks.FindCol("aa", 0, true); // should be 3th column "aa" if( col ) printf("2. The label of the column is %s.\n", col.GetLabel()); else printf("2. Fail to find column.\n"); // search whole worksheet for label is "aa" without full match col = wks.FindCol("aa", 0, false, false); // should be 1st column "AA01" if( col ) printf("3. The label of the column is %s.\n", col.GetLabel()); else printf("3. Fail to find column.\n"); // search whole worksheet for short name is "aa" without case sensitive col = wks.FindCol("Test", 0, false, true, -1, true); // should be 3th column "aa" if( col ) printf("4. The label of the column is %s.\n", col.GetLabel()); else printf("4. Fail to find column.\n"); }
void MatrixObject_FindCol_Ex1() { //before running this code, make sure the active matrixsheet contain multiple matrixobjects and renamed with special names, e.g "rr", "pp" MatrixLayer ml = Project.ActiveLayer(); if ( !ml ) { printf("Can not access active matrixsheet"); return; } string strObjName = "rr"; MatrixObject mo = ml.FindCol(strObjName); if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); strObjName = "Rr"; mo = ml.FindCol(strObjName, 0, true); //case sensitive if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); strObjName = "r"; mo = ml.FindCol(strObjName, 0, true, false); //not full match if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); strObjName = "pp"; mo = ml.FindCol(strObjName, 0, true, true, -1, false); if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); return; }
origin.h