Compartilhar via


DataValidation Class

Defines the DataValidation Class.This class is only available in Office2010.When the object is serialized out as xml, its qualified name is x14:dataValidation.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlCompositeElement
      DocumentFormat.OpenXml.Office2010.Excel.DataValidation

Namespace:  DocumentFormat.OpenXml.Office2010.Excel
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
<ChildElementInfoAttribute(GetType(DataValidationForumla1), FileFormatVersions.Office2010)> _
<ChildElementInfoAttribute(GetType(DataValidationForumla2), FileFormatVersions.Office2010)> _
<ChildElementInfoAttribute(GetType(ReferenceSequence))> _
<OfficeAvailabilityAttribute(FileFormatVersions.Office2010)> _
Public Class DataValidation _
    Inherits OpenXmlCompositeElement
'Usage
Dim instance As DataValidation
[ChildElementInfoAttribute(typeof(DataValidationForumla1), FileFormatVersions.Office2010)]
[ChildElementInfoAttribute(typeof(DataValidationForumla2), FileFormatVersions.Office2010)]
[ChildElementInfoAttribute(typeof(ReferenceSequence))]
[OfficeAvailabilityAttribute(FileFormatVersions.Office2010)]
public class DataValidation : OpenXmlCompositeElement

Remarks

The following table lists the possible child types:

  • DataValidationForumla1 <x14:formula1>

  • DataValidationForumla2 <x14:formula2>

  • DocumentFormat.OpenXml.Office.Excel.ReferenceSequence <xne:sqref>

2.6.5 CT_DataValidation

Target namespace: https://schemas.microsoft.com/office/spreadsheetml/2010/main

Referenced by: CT_DataValidations

A complex type that specifies data validation for a range on this sheet.

Child Elements:

formula1 : A CT_DataValidationFormula element that specifies the first formula for the data validation.

If operator is "between" or "notBetween" and type is not "custom", "list", or "none" then this formula is used as the lesser of two bounding values and MUST exist.

If operator is not "between" or "notBetween" or type is "custom", or "list" then this formula is the only formula and MUST exist.

If the type is "none" then this formula MUST NOT exist.

formula2 : A CT_DataValidationFormula element that specifies the second formula for the data validation.

If operator is "between" or "notBetween" and type is not "custom", "list", or "none" then this formula is used as the greater of two bounding values and MUST exist.

If operator is not "between" or "notBetween" or type is "custom", "list", or "none" then this formula MUST NOT exist.

xm:sqref : An sqref element that specifies ranges to which data validation is applied.

Attributes:

type : An ST_DataValidationType ([ISO/IEC-29500-1] section 18.18.21) attribute that specifies the type of data validation.

errorStyle : An ST_DataValidationErrorStyle ([ISO/IEC-29500-1] section 18.18.18) attribute that specifies the style of error alert used for this data validation.

imeMode : An ST_DataValidationImeMode ([ISO/IEC-29500-1] section 18.18.19) attribute that specifies the Input Method Editor (IME) mode enforced by this data validation.

operator : An ST_DataValidationOperator ([ISO/IEC-29500-1] section 18.18.20) attribute that specifies the relational operator used with this data validation. If type is “custom”, “list” or “none”, the value of the operator attribute is undefined and MUST be ignored.

allowBlank : A boolean ([XMLSCHEMA2] section 3.2.2) attribute that specifies whether the data validation treats empty or blank entries as valid.

showDropDown : A boolean ([XMLSCHEMA2] section 3.2.2) attribute that specifies whether to display the dropdown combo box for a list type data validation.

Value of showDropDown

Value of type

Meaning

TRUE

list

Displays the dropdown combo box

FALSE

list

Suppresses the dropdown combo box

showInputMessage : A boolean ([XMLSCHEMA2] section 3.2.2) attribute that specifies whether to display the input prompt message.

showErrorMessage : A boolean ([XMLSCHEMA2] section 3.2.2) attribute that specifies whether to display the error alert message.

errorTitle : An ST_Xstring ([ISO/IEC-29500-1] section 22.9.2.19) attribute that specifies the text of the title bar of the error alert. The length of this string MUST be less than or equal to 32 characters.

error : An ST_Xstring ([ISO/IEC-29500-1] section 22.9.2.19) attribute that specifies the message text of the error alert. The length of this string MUST be less than or equal to 225 characters.

promptTitle : An ST_Xstring ([ISO/IEC-29500-1] section 22.9.2.19) attribute that specifies the text of the title bar of the input prompt. The length of this string MUST be less than or equal to 32 characters.

prompt : An ST_Xstring ([ISO/IEC-29500-1] section 22.9.2.19) attribute that specifies the message text of the input prompt. This string MUST be less than or equal to 255 characters.

The following W3C XML Schema ([XMLSCHEMA1] section 2.1) fragment specifies the contents of this complex type.

<xsd:complexType name="CT_DataValidation">

<xsd:sequence>

<xsd:element name="formula1" type="CT_DataValidationFormula" minOccurs="0" maxOccurs="1"/>

<xsd:element name="formula2" type="CT_DataValidationFormula" minOccurs="0" maxOccurs="1"/>

<xsd:element ref="xm:sqref" minOccurs="1" maxOccurs="1"/>

</xsd:sequence>

<xsd:attribute name="type" type="x:ST_DataValidationType" use="optional" default="none"/>

<xsd:attribute name="errorStyle" type="x:ST_DataValidationErrorStyle" use="optional" default="stop"/>

<xsd:attribute name="imeMode" type="x:ST_DataValidationImeMode" use="optional" default="noControl"/>

<xsd:attribute name="operator" type="x:ST_DataValidationOperator" use="optional" default="between"/>

<xsd:attribute name="allowBlank" type="xsd:boolean" use="optional" default="false"/>

<xsd:attribute name="showDropDown" type="xsd:boolean" use="optional" default="false"/>

<xsd:attribute name="showInputMessage" type="xsd:boolean" use="optional" default="false"/>

<xsd:attribute name="showErrorMessage" type="xsd:boolean" use="optional" default="false"/>

<xsd:attribute name="errorTitle" type="x:ST_Xstring" use="optional"/>

<xsd:attribute name="error" type="x:ST_Xstring" use="optional"/>

<xsd:attribute name="promptTitle" type="x:ST_Xstring" use="optional"/>

<xsd:attribute name="prompt" type="x:ST_Xstring" use="optional"/>

</xsd:complexType>

See section 5.3 for the full W3C XML Schema ([XMLSCHEMA1] section 2.1).

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

DataValidation Members

DocumentFormat.OpenXml.Office2010.Excel Namespace