DataValidation Class

Data validation for single cell or a range More...

Header: #include <DataValidation>

Public Types

enum ErrorStyle { Stop, Warning, Information }
enum ValidationOperator { Between, NotBetween, Equal, NotEqual, ..., GreaterThanOrEqual }
enum ValidationType { None, Whole, Decimal, List, ..., Custom }

Public Functions

DataValidation()
DataValidation(ValidationType type, ValidationOperator op = Between, const QString & formula1 = QString(), const QString & formula2 = QString(), bool allowBlank = false)
DataValidation(const DataValidation & other)
~DataValidation()
void addCell(const CellReference & cell)
void addCell(int row, int col)
void addRange(const CellRange & range)
void addRange(int firstRow, int firstCol, int lastRow, int lastCol)
bool allowBlank() const
QString errorMessage() const
QString errorMessageTitle() const
ErrorStyle errorStyle() const
QString formula1() const
QString formula2() const
bool isErrorMessageVisible() const
bool isPromptMessageVisible() const
QString promptMessage() const
QString promptMessageTitle() const
QList<CellRange> ranges() const
void setAllowBlank(bool enable)
void setErrorMessage(const QString & error, const QString & title = QString())
void setErrorMessageVisible(bool visible)
void setErrorStyle(ErrorStyle es)
void setFormula1(const QString & formula)
void setFormula2(const QString & formula)
void setPromptMessage(const QString & prompt, const QString & title = QString())
void setPromptMessageVisible(bool visible)
void setValidationOperator(ValidationOperator op)
void setValidationType(ValidationType type)
ValidationOperator validationOperator() const
ValidationType validationType() const
DataValidation & operator=(const DataValidation & other)

Detailed Description

Data validation for single cell or a range

The data validation can be applied to a single cell or a range of cells.

Member Type Documentation

enum DataValidation::ErrorStyle

The enum type defines the type of error dialog that is displayed.

ConstantValue
DataValidation::Stop0
DataValidation::Warning1
DataValidation::Information2

enum DataValidation::ValidationOperator

The enum type defines the criteria by which the data in the cell is validated

ConstantValue
DataValidation::Between0
DataValidation::NotBetween1
DataValidation::Equal2
DataValidation::NotEqual3
DataValidation::LessThan4
DataValidation::LessThanOrEqual5
DataValidation::GreaterThan6
DataValidation::GreaterThanOrEqual7

enum DataValidation::ValidationType

The enum type defines the type of data that you wish to validate.

ConstantValueDescription
DataValidation::None0the type of data is unrestricted. This is the same as not applying a data validation.
DataValidation::Whole1restricts the cell to integer values. Means "Whole number"?
DataValidation::Decimal2restricts the cell to decimal values.
DataValidation::List3restricts the cell to a set of user specified values.
DataValidation::Date4restricts the cell to date values.
DataValidation::Time5restricts the cell to time values.
DataValidation::TextLength6restricts the cell data based on an integer string length.
DataValidation::Custom7restricts the cell based on an external Excel formula that returns a true/false value.

Member Function Documentation

DataValidation::DataValidation()

Construct a data validation object

DataValidation::DataValidation(ValidationType type, ValidationOperator op = Between, const QString & formula1 = QString(), const QString & formula2 = QString(), bool allowBlank = false)

Construct a data validation object with the given type, op, formula1 formula2, and allowBlank.

DataValidation::DataValidation(const DataValidation & other)

Constructs a copy of other.

DataValidation::~DataValidation()

Destroy the object.

void DataValidation::addCell(const CellReference & cell)

Add the cell on which the DataValidation will apply to.

void DataValidation::addCell(int row, int col)

This is an overloaded function.

Add the cell(row, col) on which the DataValidation will apply to.

void DataValidation::addRange(const CellRange & range)

Add the range on which the DataValidation will apply to.

void DataValidation::addRange(int firstRow, int firstCol, int lastRow, int lastCol)

This is an overloaded function.

Add the range(firstRow, firstCol, lastRow, lastCol) on which the DataValidation will apply to.

bool DataValidation::allowBlank() const

Returns whether blank is allowed.

See also setAllowBlank().

QString DataValidation::errorMessage() const

Returns the error message.

See also setErrorMessage().

QString DataValidation::errorMessageTitle() const

Returns the error message title.

ErrorStyle DataValidation::errorStyle() const

Returns the validation error style.

See also setErrorStyle().

QString DataValidation::formula1() const

Returns the formula1.

See also setFormula1().

QString DataValidation::formula2() const

Returns the formula2.

See also setFormula2().

bool DataValidation::isErrorMessageVisible() const

Returns the whether error message is shown.

bool DataValidation::isPromptMessageVisible() const

Returns the whether prompt message is shown.

QString DataValidation::promptMessage() const

Returns the prompt message.

See also setPromptMessage().

QString DataValidation::promptMessageTitle() const

Returns the prompt message title.

QList<CellRange> DataValidation::ranges() const

Returns the ranges on which the validation will be applied.

void DataValidation::setAllowBlank(bool enable)

Enable/disabe blank allow based on enable.

See also allowBlank().

void DataValidation::setErrorMessage(const QString & error, const QString & title = QString())

Sets the error message to error with title title.

See also errorMessage().

void DataValidation::setErrorMessageVisible(bool visible)

Enable/disabe error message visible based on visible.

See also isErrorMessageVisible().

void DataValidation::setErrorStyle(ErrorStyle es)

Sets the error style to es.

See also errorStyle().

void DataValidation::setFormula1(const QString & formula)

Sets the formula1 to formula.

See also formula1().

void DataValidation::setFormula2(const QString & formula)

Sets the formulas to formula.

See also formula2().

void DataValidation::setPromptMessage(const QString & prompt, const QString & title = QString())

Sets the prompt message to prompt with title title.

See also promptMessage().

void DataValidation::setPromptMessageVisible(bool visible)

Enable/disabe prompt message visible based on visible.

See also isPromptMessageVisible().

void DataValidation::setValidationOperator(ValidationOperator op)

Sets the validation operator to op.

See also validationOperator().

void DataValidation::setValidationType(ValidationType type)

Sets the validation type to type.

See also validationType().

ValidationOperator DataValidation::validationOperator() const

Returns the validation operator.

See also setValidationOperator().

ValidationType DataValidation::validationType() const

Returns the validation type.

See also setValidationType().

DataValidation & DataValidation::operator=(const DataValidation & other)

Assigns other to this validation and returns a reference to this validation.