SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface IDataValidation

    A data validation: a rule that a cell's value must satisfy, over one or more ranges of a sheet, with the prompt shown when the cell is selected and the alert for a value that fails.

    Validations may overlap, and every one covering a cell applies: the cell is valid only when each of them accepts its value. Where a single answer is needed, the rule with the lowest getIndex wins: the prompt is the first covering rule's that has one, the alert the first failing rule's, and the dropdown offers the items every covering list rule accepts. Excel keeps one validation per cell, and when it opens a file whose validations overlap it honors only the first; see ICell.getDataValidation.

    The rule judges the value a cell holds, whatever wrote it. A value set through the API, pasted or filled is never refused; it is simply invalid, and getAlertAt says so.

    interface IDataValidation {
        isIAnchored: true;
        isIDataValidation: true;
        addListeners(
            listeners: IDataValidation.IListeners,
            options?: IListener.Options,
        ): Remove;
        apply(): void;
        close(): void;
        delete(): void;
        getAlertAt(rowIndex: number, columnIndex: number): boolean;
        getAlertCount(): number;
        getAlertEntries(
            options?: ICellRange.IteratorOptions<ICellRange.Address>,
        ): EntryIterator<boolean>;
        getAlertMessage(): string;
        getAlertStyle(): IDataValidation.AlertStyle;
        getAlertTitle(): string;
        getAnchorType?(): IAnchored.Type;
        getCondition(): ICondition<any> | null;
        getIndex(): number;
        getListItemsAt(
            rowIndex: number,
            columnIndex: number,
        ): Promise<readonly ListItem[]>;
        getName?(): string | null;
        getPromptMessage(): string;
        getPromptTitle(): string;
        getRanges(options?: ICellRange.GetRangeOptions): ICellRanges;
        getRenderHints(): readonly string[];
        getSnapshot(options?: CopyOptions): IDataValidation.ISnapshot;
        isClosed(): boolean;
        isDeleted(): boolean;
        isHideDropdown(): boolean;
        isIncludeBlanks(): boolean;
        isProtected(): boolean;
        isShowAlertMessage(): boolean;
        isShowPromptMessage(): boolean;
        setAlertMessage(
            message: string,
            options?: ITransaction.OperationOptions,
        ): this;
        setAlertStyle(
            alertStyle: IDataValidation.AlertStyle,
            options?: ITransaction.OperationOptions,
        ): this;
        setAlertTitle(title: string, options?: ITransaction.OperationOptions): this;
        setCondition(
            condition: Input<any> | null,
            options?: ITransaction.OperationOptions,
        ): this;
        setHideDropdown(
            hide: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setIncludeBlanks(
            include: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setIndex(index: number): this;
        setPromptMessage(
            message: string,
            options?: ITransaction.OperationOptions,
        ): this;
        setPromptTitle(
            title: string,
            options?: ITransaction.OperationOptions,
        ): this;
        setRanges(
            address: ICellRanges.Address,
            options?: ITransaction.OperationOptions,
        ): this;
        setShowAlertMessage(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setShowPromptMessage(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        toJSON(): IDataValidation.JSON | null;
        update(
            update: IDataValidation | Partial<IDataValidation.Properties>,
            options?: ITransaction.OperationOptions,
        ): this;
    }

    Hierarchy (View Summary)

    Index
    isIAnchored: true

    For runtime type checking.

    isIDataValidation: true

    For runtime type checking.

    • Applies the condition.

      Returns void

    • Similar to delete but cleans resources and can't be undone.

      Returns void

    • Deletes the anchored item.

      Returns void

    • Whether the cell at the specified coordinates fails this validation.

      Parameters

      • rowIndex: number

        The sheet row.

      • columnIndex: number

        The sheet column.

      Returns boolean

      This validation's answer alone. Where validations overlap, a cell is invalid when any of the ones covering it fails (ICellRange.getDataValidations).

      An empty cell fails when Ignore blank is off (isIncludeBlanks is false) and the rule rejects a blank there, as Excel's Circle Invalid Data circles it. With Ignore blank on, an empty cell never fails. A cell holding "" (a formula's empty text) is a value, and is judged.

    • The number of cells that fail this validation, empty cells included.

      Returns number

      A rule that judges every empty cell alike (no formula) counts them without visiting any. A rule with a formula, a custom formula or a range list source, reads each empty cell's answer, so the first call over a large range can be slow. The answer is kept until the values change.

    • The cells that fail this validation, each as a [coords, true] entry, empty cells included.

      Parameters

      Returns EntryIterator<boolean>

      Lazy: the cost is what the caller reads. Stop early to pay for the first few entries only. When empty cells pass (Ignore blank on), they are skipped without being visited. When they fail, a whole-column rule yields every one of its empty cells, so take what you need.

    • Returns the index of this data validation within its container: its priority, 0 first.

      Returns number

      Where validations overlap, the lowest index supplies the prompt and the alert style; see IDataValidation. The writer saves the rules in this order.

    • The items a list validation offers at a cell: what its in-cell dropdown lists.

      Parameters

      • rowIndex: number

        The cell's row.

      • columnIndex: number

        The cell's column. A relative source ($F1:$G1, INDIRECT($E1)) gives each cell its own list, as it does in Excel.

      Returns Promise<readonly ListItem[]>

      The set's members: its items, then what its source lists in source order, duplicates kept, then its typed additions, with any subtractions left out. Empty when this is not a list validation or the set lists nothing. Blank source cells are not listed.

      Evaluated when asked, for one cell — the check itself does not need the items, so nothing is resolved until a dropdown or a preview asks. text is what a source cell shows (a date list reads as dates), the item itself for a typed one.

    • The name of the anchor or null if it has none.

      Returns string | null

    • Returns the ranges this object is anchored to, in authored order.

      Parameters

      Returns ICellRanges

      • Never null. An item whose last range was removed by a row/column delete returns an invalid ranges — ask ICellRanges.isInvalid, the same contract as ITable.getDataRange.
      • This is the general accessor. Most anchored types hold exactly one range and declare their own getRange() for it, but data validations, conditional formats and protected ranges are authored as several, and any single range can become several when a delete splits it.
    • How a cell the rule covers asks to be drawn and edited, as keywords a client may honor.

      Returns readonly string[]

      A rule that tests membership of a set (inSet, under any selector) answers list, which is what an in-cell dropdown is shown for. Any other rule answers its selector's hints. Empty when the rule has no condition or nothing to ask for.

    • Returns if the model has been closed

      Returns boolean

    • Returns if the model has been deleted

      Returns boolean

    • If the anchor is unable to be modified.

      Returns boolean

    • Sets the style of the alert raised when a user enters a value that fails the rule.

      Parameters

      Returns this

      Stop refuses the entry, Warning asks before accepting it, and Information accepts it with a message. Where validations overlap, the first failing rule's style is the one used.

      The alert answers what a user types or picks, as in Excel. A value written through the API, pasted or filled raises no alert and is never refused.

      The style applies only while setShowAlertMessage is on. With it off, an invalid entry is accepted without a word whatever the style, as in Excel, so a rule meant to refuse entry needs both.

      Stop

    • Set whether to suppress the in-cell dropdown arrow for a list validation.

      Parameters

      Returns this

      A rendering flag only — it never affects whether input is validated. Meaningful only for list validations, matching Excel's In-cell dropdown checkbox (inverted: the checkbox ON means false here).

    • Sets whether blanks are included in validation.

      Parameters

      Returns this

      Reads and writes through to the condition — blanks-pass-or-fail is a property of the predicate, and this is Excel's Ignore blank checkbox. A validation with no condition has nothing to set.

    • Sets the index of this data validation within its container.

      Parameters

      • index: number

        The new index to set. See getIndex.

      Returns this

    • The message shown while a cell the rule covers is selected (Excel's Input Message).

      Parameters

      Returns this

      Shown only while isShowPromptMessage is on. Where validations overlap, the first covering rule with a prompt shows its own.

    • Re-anchors this rule to address, REPLACING every range it currently covers.

      Parameters

      • address: ICellRanges.Address

        The range or ranges to cover — anything ISheet.getRanges accepts ('A1:C20', 'A1:A5, C1:C5', coords). Resolved against this rule's own sheet.

      • Optionaloptions: ITransaction.OperationOptions

        Transaction options; description names the entry in undo history.

      Returns this

      A REPLACE, not an add: the ranges named become the whole anchor. An address that names nothing throws rather than leaving the rule unanchored — clearing is IAnchored.delete.

      Undoable, and refused on a protected sheet. A rule spans several ranges as readily as one; Excel writes them as one sqref, and so do we.

    • Sets whether a value that fails the rule raises the alert when a user enters it.

      Parameters

      Returns this

      With the alert off, a failing entry is accepted silently, whatever the getAlertStyle. It is still invalid: getAlertAt reports it either way.

    • Sets whether to show the prompt when a cell the rule covers is selected.

      Parameters

      Returns this

      Separate from the prompt's text, as in Excel: turning the prompt off keeps its title and message, and turning it back on shows them again.