Create Xlsx Files With Cell Data Validation Settings

Take advantage of one of the powerful feature of an xlsx file, the ‘Data Validation’. This will grant the ability to define an input filter on the data that a user can insert in a particular cell. The filter can be a value that must be between a certain start data and specific end data, for example, a value between 100 and 200 will only be allowed to be entered on a selected cell. Greater than a given value, or lower than a set value can also be set as a filter.
But before moving further in coding a data validation in PhpSpreadsheet, it would be better to read and familiarize oneself with the available options such as the ‘Constants’, ‘Properties’, and ‘Methods’, to be able to have a wider-look of the coding possibilities in creating an xlsx file with data validation using PhpSpreadsheet.
Below are the available cell data validation options of PhpSpreadsheet.
Note:
For the complete documentation, head over to the PhpSpreadsheet Cell Data Validation page.
Constants
- TYPE_NONE
- TYPE_CUSTOM
- TYPE_DATE
- TYPE_DECIMAL
- TYPE_LIST
- TYPE_TEXTLENGTH
- TYPE_TIME
- TYPE_WHOLE
- STYLE_STOP
- STYLE_WARNING
- STYLE_INFORMATION
- OPERATOR_BETWEEN
- OPERATOR_EQUAL
- OPERATOR_GREATERTHAN
- OPERATOR_GREATERTHANOREQUAL
- OPERATOR_LESSTHAN
- OPERATOR_LESSTHANOREQUAL
- OPERATOR_NOTBETWEEN
- OPERATOR_NOTEQUAL
Properties
- $formula1
- $formula2
- $type
- $errorStyle
- $operator
- $allowBlank
- $showDropDown
- $showInputMessage
- $showErrorMessage
- $errorTitle
- $error
- $promptTitle
- $prompt
Methods
- __construct()
- getFormula1()
- setFormula1()
- getFormula2()
- setFormula2()
- getType()
- setType()
- getErrorStyle()
- setErrorStyle()
- getOperator()
- setOperator()
- getAllowBlank()
- setAllowBlank()
- getShowDropDown()
- setShowDropDown()
- getShowInputMessage()
- setShowInputMessage()
- getShowErrorMessage()
- setShowErrorMessage()
- getErrorTitle()
- setErrorTitle()
- getError()
- setError()
- getPromptTitle()
- setPromptTitle()
- getPrompt()
- setPrompt()
- getHashCode()
- __clone()
References:
- How to install PhpSpreadsheet
- PhpSpreadsheet Cell Data Validation
- Creating a spreadsheet
- Reading and writing to file
- PhpSpreadsheet Recipes