ExcelRow AllocatedCells Property GemBox.Spreadsheet Help
Gets only currently allocated cells for this row.

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 37.3.30.1035
Syntax

public ExcelCellCollection AllocatedCells { get; }
Remarks

Use this collection if you are reading entire Excel file (you don't know exact position of cells with data). If writing values, using Cells property is recommended.

This collection contains only allocated cells so it is faster as you avoid checking every single cell in a row. You still need to check if a specific cell contains any value (it can be empty).

Examples

Following code reads entire XLSX file and displays all cells containing any data. Data types are also displayed.

ExcelFile ef = ExcelFile.Load("Book1.xlsx");

foreach (ExcelWorksheet sheet in ef.Worksheets)
{
    Console.WriteLine("--------- {0} ---------", sheet.Name);

    foreach (ExcelRow row in sheet.Rows)
    {
        foreach (ExcelCell cell in row.AllocatedCells)
        {
            if (cell.Value != null)
                Console.Write("{0}({1})", cell.Value, cell.Value.GetType().Name);

            Console.Write("\t");
        }

        Console.WriteLine();
    }
}
See Also