.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

DataValidationCollection.GetInvalidCells() Method

Returns cells that do not meet the data validation criteria.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

IEnumerable<Cell> GetInvalidCells()
Function GetInvalidCells As IEnumerable(Of Cell)
IEnumerable<Cell> GetInvalidCells()
Function GetInvalidCells As IEnumerable(Of Cell)
IEnumerable<Cell> GetInvalidCells()
Function GetInvalidCells As IEnumerable(Of Cell)

Returns

Type Description
IEnumerable<Cell>

A IEnumerable<T><Cell,> collection of cells containing invalid data.

Returns

Type Description
IEnumerable<Cell>

A IEnumerable<T><Cell,> collection of cells containing invalid data.

Returns

Type Description
IEnumerable<Cell>

A IEnumerable<T><Cell,> collection of cells containing invalid data.

Remarks

Note that the GetInvalidCells property returns only first 255 invalid cells, other invalid entries are ignored. If there are no data validation errors in a worksheet, the GetInvalidCells property returns an empty collection.

The code sample below shows how to use the GetInvalidCells method to check whether loaded document contains invalid cells:

static void Main(string[] args)
{
    Workbook workbook = new Workbook();
    workbook.LoadDocument("DataValidation_template.xlsx");
    IsDocumentValid(workbook);
}

private static void IsDocumentValid(Workbook workbook)
{
    foreach (Worksheet workSheet in workbook.Worksheets)
    {
        var invalidCells = workSheet.DataValidations.GetInvalidCells().Count();

        if (invalidCells == 0)
        {
            Console.WriteLine(string.Format("The {0} worksheet does not contain invalid cells", workSheet.Name));
            Console.ReadLine();
        }
        else
        {
            Console.WriteLine(string.Format("The {0} worksheet contains {1} invalid cells",workSheet.Name, invalidCells));
            Console.ReadLine();
        }
    }
}
See Also