Datasheet::FindFirstEmpty

Description

Find first column of last empty range in a worksheet or the first empty MatrixObject in a MatrixLayer

Syntax

int FindFirstEmpty( int nC1 = 0, BOOL bContiguous = true )

Parameters

nC1
[input] starting column or matrixobject index, 0 offset
bContiguous
[input] true if all remaining columns or matrixobjects are also empty, false if allow later columns or matrixobjects not empty.

Return

Column or MatrixObject index in the layer or -1 if no empty range or matrixobject found

Examples

EX1

//Find first empty range in a worksheet or the first empty MatrixObject in a MatrixLayer

void Datasheet_FindFirstEmpty_Ex1()
{
    Page pg = Project.Pages();
    
    foreach(Layer ly in pg.Layers)
    {
        Datasheet dats = ly;
        if(!dats)
        {
            out_str("Active Window is not a Workbook or Matrix Book");
            return;
        }
        
        int nn = dats.FindFirstEmpty();
        if(nn == 0)
            printf("Sheet %s is empty.\n", dats.GetName());
        else if(nn < 0)
            printf("Sheet %s is Not empty, there is no contigueous col/mat from the end.\n", dats.GetName());
        else
            printf("Col/Mat %d(0-offset) begins a contigueous empty block in sheet %s.\n", nn, dats.GetName());
    }
}

Remark

See Also

header to Include

origin.h