次の方法で共有


Excel.DataValidationErrorAlert interface

データ検証のエラー 警告プロパティを表します。

注釈

[ API セット: ExcelApi 1.8 ]

// 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();
});

プロパティ

message

エラー アラート メッセージを表します。

showAlert

ユーザーが無効なデータを入力したときにエラー アラート ダイアログを表示するかどうかを指定します。 既定値は true です。

style

データ検証アラートの種類については、「 Excel.DataValidationAlertStyle 」を参照してください。

title

エラー アラート ダイアログのタイトルを表します。

プロパティの詳細

message

エラー アラート メッセージを表します。

message: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.8 ]

showAlert

ユーザーが無効なデータを入力したときにエラー アラート ダイアログを表示するかどうかを指定します。 既定値は true です。

showAlert: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.8 ]

style

データ検証アラートの種類については、「 Excel.DataValidationAlertStyle 」を参照してください。

style: Excel.DataValidationAlertStyle | "Stop" | "Warning" | "Information";

プロパティ値

Excel.DataValidationAlertStyle | "Stop" | "Warning" | "Information"

注釈

[ API セット: ExcelApi 1.8 ]

title

エラー アラート ダイアログのタイトルを表します。

title: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.8 ]