Search Results for

    Show / Hide Table of Contents

    ExcelFile.LoopOverUsedRange Method

    This method loops over a range of cells, and calls an action for every cell that has data.

    Syntax

    Namespace: FlexCel.Core

    public void LoopOverUsedRange(TXlsCellRange aRange, Action<TLoopOverUsedRangeParameters> reader)

    Parameters

    <-> Parameter Type Description
    aRange TXlsCellRange Range where we want to extract the cell values.
    reader Action<TLoopOverUsed​Range​Parameters> Anonymous method that will be called once for each cell with a value inside the range.

    Examples

    To fill an array with all the cells in a range, you could use:

        object[,] GetRangeAsArray(ExcelFile xls, TXlsCellRange range)
        {
            object[,] Result = new object[range.RowCount, range.ColCount];
            xls.LoopOverUsedRange(range, (x) =>
            {
                Result[x.Row - range.Top, x.Col - range.Left] = x.Value;
            });
            return Result;
        }
    

    See also

    • ExcelFile
    • ColCountInRow(Int32)
    • ColFromIndex(Int32, Int32)
    • ColToIndex(Int32, Int32)
    In This Article
    Back to top FlexCel Studio for the .NET Framework v7.24.0.0
    © 2002 - 2025 tmssoftware.com