Validation

Validation class

Represents data validation.settings.

class Validation;

Example

const { Workbook, ValidationType, CellArea } = require("aspose.cells.node");

var workbook = new Workbook();
var validations = workbook.getWorksheets().get(0).getValidations();
var area = CellArea.createCellArea(0, 0, 1, 1);
var validation = validations.get(validations.add(area));
validation.setType(ValidationType.List);
validation.setFormula1("a,b,c,d");

Methods

MethodDescription
getOperator()Represents the operator for the data validation.
setOperator(OperatorType)Represents the operator for the data validation.
getAlertStyle()Represents the validation alert style.
setAlertStyle(ValidationAlertType)Represents the validation alert style.
getType()Represents the data validation type.
setType(ValidationType)Represents the data validation type.
getInputMessage()Represents the data validation input message.
setInputMessage(string)Represents the data validation input message.
getInputTitle()Represents the title of the data-validation input dialog box.
setInputTitle(string)Represents the title of the data-validation input dialog box.
getErrorMessage()Represents the data validation error message.
setErrorMessage(string)Represents the data validation error message.
getErrorTitle()Represents the title of the data-validation error dialog box.
setErrorTitle(string)Represents the title of the data-validation error dialog box.
getShowInput()Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.
setShowInput(boolean)Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.
getShowError()Indicates whether the data validation error message will be displayed whenever the user enters invalid data.
setShowError(boolean)Indicates whether the data validation error message will be displayed whenever the user enters invalid data.
getIgnoreBlank()Indicates whether blank values are permitted by the range data validation.
setIgnoreBlank(boolean)Indicates whether blank values are permitted by the range data validation.
getFormula1()Represents the value or expression associated with the data validation.
setFormula1(string)Represents the value or expression associated with the data validation.
getFormula2()Represents the value or expression associated with the data validation.
setFormula2(string)Represents the value or expression associated with the data validation.
getValue1()Represents the first value associated with the data validation.
setValue1(object)Represents the first value associated with the data validation.
getValue2()Represents the second value associated with the data validation.
setValue2(object)Represents the second value associated with the data validation.
getInCellDropDown()Indicates whether data validation displays a drop-down list that contains acceptable values.
setInCellDropDown(boolean)Indicates whether data validation displays a drop-down list that contains acceptable values.
getAreas()Gets all CellArea which contain the data validation settings.
getFormula1(boolean, boolean)Gets the value or expression associated with this validation.
getFormula1(boolean, boolean, number, number)Gets the value or expression associated with this validation for specific cell.
getFormula2(boolean, boolean)Gets the value or expression associated with this validation.
getFormula2(boolean, boolean, number, number)Gets the value or expression associated with this validation for specific cell.
setFormula1(string, boolean, boolean)Sets the value or expression associated with this validation.
setFormula2(string, boolean, boolean)Sets the value or expression associated with this validation.
getListValue(number, number)Get the value for list of the validation for the specified cell.
getValue(number, number, boolean)Get the value of validation on the specific cell.
addArea(CellArea)Applies the validation to the area.
addArea(CellArea, boolean, boolean)Applies the validation to the area.
addAreas(CellArea[], boolean, boolean)Applies the validation to given areas.
removeArea(CellArea)Remove the validation settings in the range.
removeAreas(CellArea[])Removes this validation from given areas.
removeACell(number, number)Remove the validation settings in the cell.
copy(Validation, CopyOptions)Copy validation.
isNull()Checks whether the implementation object is null.

getOperator()

Represents the operator for the data validation.

getOperator() : OperatorType;

Returns

OperatorType

setOperator(OperatorType)

Represents the operator for the data validation.

setOperator(value: OperatorType) : void;

Parameters:

ParameterTypeDescription
valueOperatorTypeThe value to set.

getAlertStyle()

Represents the validation alert style.

getAlertStyle() : ValidationAlertType;

Returns

ValidationAlertType

setAlertStyle(ValidationAlertType)

Represents the validation alert style.

setAlertStyle(value: ValidationAlertType) : void;

Parameters:

ParameterTypeDescription
valueValidationAlertTypeThe value to set.

getType()

Represents the data validation type.

getType() : ValidationType;

Returns

ValidationType

setType(ValidationType)

Represents the data validation type.

setType(value: ValidationType) : void;

Parameters:

ParameterTypeDescription
valueValidationTypeThe value to set.

getInputMessage()

Represents the data validation input message.

getInputMessage() : string;

setInputMessage(string)

Represents the data validation input message.

setInputMessage(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getInputTitle()

Represents the title of the data-validation input dialog box.

getInputTitle() : string;

setInputTitle(string)

Represents the title of the data-validation input dialog box.

setInputTitle(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getErrorMessage()

Represents the data validation error message.

getErrorMessage() : string;

setErrorMessage(string)

Represents the data validation error message.

setErrorMessage(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getErrorTitle()

Represents the title of the data-validation error dialog box.

getErrorTitle() : string;

setErrorTitle(string)

Represents the title of the data-validation error dialog box.

setErrorTitle(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getShowInput()

Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.

getShowInput() : boolean;

setShowInput(boolean)

Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.

setShowInput(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getShowError()

Indicates whether the data validation error message will be displayed whenever the user enters invalid data.

getShowError() : boolean;

setShowError(boolean)

Indicates whether the data validation error message will be displayed whenever the user enters invalid data.

setShowError(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getIgnoreBlank()

Indicates whether blank values are permitted by the range data validation.

getIgnoreBlank() : boolean;

setIgnoreBlank(boolean)

Indicates whether blank values are permitted by the range data validation.

setIgnoreBlank(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getFormula1()

Represents the value or expression associated with the data validation.

getFormula1() : string;

setFormula1(string)

Represents the value or expression associated with the data validation.

setFormula1(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getFormula2()

Represents the value or expression associated with the data validation.

getFormula2() : string;

setFormula2(string)

Represents the value or expression associated with the data validation.

setFormula2(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getValue1()

Represents the first value associated with the data validation.

getValue1() : object;

setValue1(object)

Represents the first value associated with the data validation.

setValue1(value: object) : void;

Parameters:

ParameterTypeDescription
valueobjectThe value to set.

getValue2()

Represents the second value associated with the data validation.

getValue2() : object;

setValue2(object)

Represents the second value associated with the data validation.

setValue2(value: object) : void;

Parameters:

ParameterTypeDescription
valueobjectThe value to set.

getInCellDropDown()

Indicates whether data validation displays a drop-down list that contains acceptable values.

getInCellDropDown() : boolean;

setInCellDropDown(boolean)

Indicates whether data validation displays a drop-down list that contains acceptable values.

setInCellDropDown(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getAreas()

Gets all CellArea which contain the data validation settings.

getAreas() : CellArea[];

Returns

CellArea[]

getFormula1(boolean, boolean)

Gets the value or expression associated with this validation.

getFormula1(isR1C1: boolean, isLocal: boolean) : string;

Parameters:

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.

Returns

The value or expression associated with this validation.

getFormula1(boolean, boolean, number, number)

Gets the value or expression associated with this validation for specific cell.

getFormula1(isR1C1: boolean, isLocal: boolean, row: number, column: number) : string;

Parameters:

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.
rownumberThe row index.
columnnumberThe column index.

Returns

The value or expression associated with this validation.

getFormula2(boolean, boolean)

Gets the value or expression associated with this validation.

getFormula2(isR1C1: boolean, isLocal: boolean) : string;

Parameters:

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.

Returns

The value or expression associated with this validation.

getFormula2(boolean, boolean, number, number)

Gets the value or expression associated with this validation for specific cell.

getFormula2(isR1C1: boolean, isLocal: boolean, row: number, column: number) : string;

Parameters:

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.
rownumberThe row index.
columnnumberThe column index.

Returns

The value or expression associated with this validation.

setFormula1(string, boolean, boolean)

Sets the value or expression associated with this validation.

setFormula1(formula: string, isR1C1: boolean, isLocal: boolean) : void;

Parameters:

ParameterTypeDescription
formulastringThe value or expression associated with this format condition.
isR1C1booleanWhether the formula is R1C1 formula.
isLocalbooleanWhether the formula is locale formatted.

setFormula2(string, boolean, boolean)

Sets the value or expression associated with this validation.

setFormula2(formula: string, isR1C1: boolean, isLocal: boolean) : void;

Parameters:

ParameterTypeDescription
formulastringThe value or expression associated with this format condition.
isR1C1booleanWhether the formula is R1C1 formula.
isLocalbooleanWhether the formula is locale formatted.

getListValue(number, number)

Get the value for list of the validation for the specified cell.

getListValue(row: number, column: number) : object;

Parameters:

ParameterTypeDescription
rownumberThe row index.
columnnumberThe column index.

Returns

The value to produce the list of this validation for the specified cell. If the list references to a range, then the returned value will be a ReferredArea object; Otherwise the returned value may be null, object[], or simple object.

Remarks

Only for validation whose type is List and has been applied to given cell, otherwise null will be returned.

getValue(number, number, boolean)

Get the value of validation on the specific cell.

getValue(row: number, column: number, isValue1: boolean) : object;

Parameters:

ParameterTypeDescription
rownumberThe row index.
columnnumberThe column index.
isValue1booleanIndicates whether getting the first value.

addArea(CellArea)

Applies the validation to the area.

addArea(cellArea: CellArea) : void;

Parameters:

ParameterTypeDescription
cellAreaCellAreaThe area.

Remarks

It is equivalent to use AddArea(Aspose.Cells.CellArea,bool,bool) with checking intersection and edge.

addArea(CellArea, boolean, boolean)

Applies the validation to the area.

addArea(cellArea: CellArea, checkIntersection: boolean, checkEdge: boolean) : void;

Parameters:

ParameterTypeDescription
cellAreaCellAreaThe area.
checkIntersectionbooleanWhether check the intersection of given area with existing validations’ areas. /// If one validation has been applied in given area(or part of it), /// then the existing validation should be removed at first from given area. /// Otherwise corruption may be caused for the generated Validations. /// If user is sure that the added area does not intersect with any existing area, /// this parameter can be set as false for performance consideration.
checkEdgebooleanWhether check the edge of this validation’s applied areas. /// Validation’s internal settings depend on the top-left one of its applied ranges, /// so if given area will become the new top-left one of the applied ranges, /// the internal settings should be changed and rebuilt, otherwise unexpected result may be caused. /// If user is sure that the added area is not the top-left one, /// this parameter can be set as false for performance consideration.

Remarks

In this method, we will remove all old validations in given area. For the top-left one of Validation’s applied ranges, firstly its StartRow is smallest, secondly its StartColumn is the smallest one of those areas who have the same smallest StartRow.

addAreas(CellArea[], boolean, boolean)

Applies the validation to given areas.

addAreas(areas: CellArea[], checkIntersection: boolean, checkEdge: boolean) : void;

Parameters:

ParameterTypeDescription
areasCellArea[]The areas.
checkIntersectionbooleanWhether check the intersection of given area with existing validations’ areas. /// If one validation has been applied in given area(or part of it), /// then the existing validation should be removed at first from given area. /// Otherwise corruption may be caused for the generated Validations. /// If user is sure that all the added areas do not intersect with any existing area, /// this parameter can be set as false for performance consideration.
checkEdgebooleanWhether check the edge of this validation’s applied areas. /// Validation’s internal settings depend on the top-left one of its applied ranges, /// so if one of given areas will become the new top-left one of the applied ranges, /// the internal settings should be changed and rebuilt, otherwise unexpected result may be caused. /// If user is sure that no one of those added areas is the top-left, /// this parameter can be set as false for performance consideration.

Remarks

In this method, we will remove all old validations in given area. For the top-left one of Validation’s applied ranges, firstly its StartRow is smallest, secondly its StartColumn is the smallest one of those areas who have the same smallest StartRow.

removeArea(CellArea)

Remove the validation settings in the range.

removeArea(cellArea: CellArea) : void;

Parameters:

ParameterTypeDescription
cellAreaCellAreathe areas where this validation settings should be removed.

removeAreas(CellArea[])

Removes this validation from given areas.

removeAreas(areas: CellArea[]) : void;

Parameters:

ParameterTypeDescription
areasCellArea[]the areas where this validation settings should be removed.

removeACell(number, number)

Remove the validation settings in the cell.

removeACell(row: number, column: number) : void;

Parameters:

ParameterTypeDescription
rownumberThe row index.
columnnumberThe column index.

copy(Validation, CopyOptions)

Copy validation.

copy(source: Validation, copyOption: CopyOptions) : void;

Parameters:

ParameterTypeDescription
sourceValidationThe source validation.
copyOptionCopyOptionsThe copy option.

isNull()

Checks whether the implementation object is null.

isNull() : boolean;