Excel.DataValidationErrorAlert interface
Represents the error alert properties for the data validation.
Remarks
Examples
// 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();
});
Properties
message | Represents the error alert message. |
show |
Specifies whether to show an error alert dialog when a user enters invalid data. The default is |
style | The data validation alert type, please see |
title | Represents the error alert dialog title. |
Property Details
message
Represents the error alert message.
message: string;
Property Value
string
Remarks
showAlert
Specifies whether to show an error alert dialog when a user enters invalid data. The default is true
.
showAlert: boolean;
Property Value
boolean
Remarks
style
The data validation alert type, please see Excel.DataValidationAlertStyle
for details.
style: Excel.DataValidationAlertStyle | "Stop" | "Warning" | "Information";
Property Value
Excel.DataValidationAlertStyle | "Stop" | "Warning" | "Information"
Remarks
title
Represents the error alert dialog title.
title: string;
Property Value
string