-
Notifications
You must be signed in to change notification settings - Fork 63
/
excel.datavalidationrule.yml
177 lines (152 loc) · 6.08 KB
/
excel.datavalidationrule.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
### YamlMime:TSType
name: Excel.DataValidationRule
uid: 'excel!Excel.DataValidationRule:interface'
package: excel!
fullName: Excel.DataValidationRule
summary: >-
A data validation rule contains different types of data validation. You can only use one of them at a time according
the `Excel.DataValidationType`<!-- -->.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: interface
properties:
- name: custom
uid: 'excel!Excel.DataValidationRule#custom:member'
package: excel!
fullName: custom
summary: Custom data validation criteria.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'custom?: Excel.CustomDataValidation;'
return:
type: '<xref uid="excel!Excel.CustomDataValidation:interface" />'
- name: date
uid: 'excel!Excel.DataValidationRule#date:member'
package: excel!
fullName: date
summary: Date data validation criteria.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'date?: Excel.DateTimeDataValidation;'
return:
type: '<xref uid="excel!Excel.DateTimeDataValidation:interface" />'
- name: decimal
uid: 'excel!Excel.DataValidationRule#decimal:member'
package: excel!
fullName: decimal
summary: Decimal data validation criteria.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'decimal?: Excel.BasicDataValidation;'
return:
type: '<xref uid="excel!Excel.BasicDataValidation:interface" />'
- name: list
uid: 'excel!Excel.DataValidationRule#list:member'
package: excel!
fullName: list
summary: List data validation criteria.
remarks: >-
\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Decision");
const nameRange =
sheet.tables.getItem("NameOptionsTable").columns.getItem("Baby Name").getDataBodyRange();
// When you are developing, it is a good practice to
// clear the dataValidation object with each run of your code.
nameRange.dataValidation.clear();
const nameSourceRange = context.workbook.worksheets.getItem("Names").getRange("A1:A3");
let approvedListRule = {
list: {
inCellDropDown: true,
source: nameSourceRange
}
};
nameRange.dataValidation.rule = approvedListRule;
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'list?: Excel.ListDataValidation;'
return:
type: '<xref uid="excel!Excel.ListDataValidation:interface" />'
- name: textLength
uid: 'excel!Excel.DataValidationRule#textLength:member'
package: excel!
fullName: textLength
summary: Text length data validation criteria.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'textLength?: Excel.BasicDataValidation;'
return:
type: '<xref uid="excel!Excel.BasicDataValidation:interface" />'
- name: time
uid: 'excel!Excel.DataValidationRule#time:member'
package: excel!
fullName: time
summary: Time data validation criteria.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'time?: Excel.DateTimeDataValidation;'
return:
type: '<xref uid="excel!Excel.DateTimeDataValidation:interface" />'
- name: wholeNumber
uid: 'excel!Excel.DataValidationRule#wholeNumber:member'
package: excel!
fullName: wholeNumber
summary: Whole number data validation criteria.
remarks: >-
\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/22-data-validation/data-validation.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Decision");
const rankingRange = sheet.tables.getItem("NameOptionsTable").columns.getItem("Ranking").getDataBodyRange();
// When you are developing, it is a good practice to
// clear the dataValidation object with each run of your code.
rankingRange.dataValidation.clear();
let greaterThanZeroRule = {
wholeNumber: {
formula1: 0,
operator: Excel.DataValidationOperator.greaterThan
}
};
rankingRange.dataValidation.rule = greaterThanZeroRule;
rankingRange.dataValidation.prompt = {
message: "Please enter a positive number.",
showPrompt: true,
title: "Positive numbers only."
};
rankingRange.dataValidation.errorAlert = {
message: "Sorry, only positive numbers are allowed",
showAlert: true,
style: "Stop",
title: "Negative Number Entered"
};
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'wholeNumber?: Excel.BasicDataValidation;'
return:
type: '<xref uid="excel!Excel.BasicDataValidation:interface" />'