Spread Windows Forms 13.0 Product Documentation
FarPoint.Win.Spread Assembly / FarPoint.Win.Spread Namespace / SheetView Class / GetLastNonEmptyColumn Method
Whether to look for data or formatting (NonEmptyItemFlag setting)
Example


In This Topic
    GetLastNonEmptyColumn Method
    In This Topic
    Gets the index of the last column that contains data or formatting on this sheet.
    Syntax
    'Declaration
     
    Public Function GetLastNonEmptyColumn( _
       ByVal dataFlag As NonEmptyItemFlag _
    ) As Integer
    'Usage
     
    Dim instance As SheetView
    Dim dataFlag As NonEmptyItemFlag
    Dim value As Integer
     
    value = instance.GetLastNonEmptyColumn(dataFlag)
    public int GetLastNonEmptyColumn( 
       NonEmptyItemFlag dataFlag
    )

    Parameters

    dataFlag
    Whether to look for data or formatting (NonEmptyItemFlag setting)

    Return Value

    Integer column index of the last column that contains data
    Example
    This example illustrates the use of this member by returning the last column and row that contains data.
    int i, j;
    fpSpread1.Columns[2].CellType = new FarPoint.Win.Spread.CellType.DateTimeCellType();
    for( i = 0; i < 10; i++ )
        fpSpread1.ActiveSheet.SetValue(i, 0, i + 1);
    j = 0;
    for( i = 106;  i > 96; i-- )
    {
        fpSpread1.ActiveSheet.SetValue(j, 1, Convert.ToChar(i));
        j += 1;
    }
    System.DateTime mydate = System.DateTime.Now;
    for( i = 0; i < 10; i++ )
        fpSpread1.ActiveSheet.SetValue(i, 2, mydate.AddDays(i));
    label1.Text = "The last non-empty column and row is: Column( " + fpSpread1.ActiveSheet.GetLastNonEmptyColumn(FarPoint.Win.Spread.NonEmptyItemFlag.Data).ToString()
    + ") - Row(" + fpSpread1.ActiveSheet.GetLastNonEmptyRow(FarPoint.Win.Spread.NonEmptyItemFlag.Data).ToString() + ")";
    Dim i As Integer, j As Integer
    FpSpread1.ActiveSheet.Columns(2).CellType = New FarPoint.Win.Spread.CellType.DateTimeCellType()
    For i = 0 To 9
        FpSpread1.ActiveSheet.SetValue(i, 0, i + 1)
    Next
    j = 0
    For i = 106 To 97 Step -1
        FpSpread1.ActiveSheet.SetValue(j, 1, Convert.ToChar(i))
        j += 1
    Next
    Dim mydate As DateTime = Now
    For i = 0 To 9
        FpSpread1.ActiveSheet.SetValue(i, 2, mydate.AddDays(i))
    Next
    Label1.Text = "The last non-empty column and row is: Column( " & FpSpread1.ActiveSheet.GetLastNonEmptyColumn(FarPoint.Win.Spread.NonEmptyItemFlag.Data).ToString()
    & ") - Row(" & FpSpread1.ActiveSheet.GetLastNonEmptyRow(FarPoint.Win.Spread.NonEmptyItemFlag.Data).ToString() & ")"
    See Also