spreadSheetAddDataValidationRule

説明

データ検証を使用すると、特定のスプレッドシートセルに入力するデータのタイプに制限を適用できます。ルールを使用すると、スプレッドシートに入力するデータが正確で、一貫性があり、ルールに準拠していることを確認できます。

検証が役に立つ仕組み

スプレッドシートにデータ検証ルールを追加すると、次のことが可能になります。

  • エラーを防止:入力できるデータを制限することで、データ入力時のエラーを最小限に抑えます。 

  • データの整合性を維持:データが一貫性のある形式であることを確認します。 

  • データ品質を向上:正確なレポート作成に不可欠な有効なデータのみを入力できます。

ColdFusion でのデータ検証のタイプ:

  • 整数:整数のみを許可します。 例:アパートの築年数やサイズ。 

  • 浮動小数点数:小数のみを許可します。例:商品価格や 2 つの場所間の距離。 

  • リスト:エントリを定義済みの値のリストに制限します。例:部門名や製品カテゴリからの選択。 

  • 日付:指定された日付の条件に応じてエントリが有効であることを確認します。例:プロジェクトの期限の設定や、生年月日が一定範囲内であることの確認。  

  • テキストの長さ:セル内の文字数を制限します。例:郵便番号、電話番号、従業員 ID。  

戻り値

なし

履歴

  • ColdFusion(2025 リリース):関数が追加されました。

シンタックス 

spreadSheetAddDataValidationRule(spreadSheetObject, validationRule)
spreadSheetAddDataValidationRule(spreadSheetObject, validationRule)
spreadSheetAddDataValidationRule(spreadSheetObject, validationRule)

パラメーター

名前

必須

説明

spreadSheetObject

はい

ExcelInfo

データ検証を追加する Excel スプレッドシートオブジェクトです。

validationRule

はい

構造体

次のルールを含む構造体:

  • validationType:次のいずれかを選択します。
    • Date
    • Double
    • 整数
    • リスト
    • Text_Length
  • 領域:検証の対象となるデータを入力する、スプレッドシート内の領域を定義します。これは、データ入力領域の開始行と終了行、および開始列と終了列を定義する構造体の配列です。
    • 領域が単一の列にある場合は、領域を {startRow:2, startColumn:1, endRow: 1, endColumn: 1} として指定します
    • 領域が複数の列にまたがる場合は、領域を[ { startRow : 1, startColumn : 1, endRow : 1, endColumn : 1 }, { startRow : 2, startColumn : 1, endRow : 2, endColumn : 4}] として指定します
  • value:範囲内に入力されたデータの検証対象となる値。
  • operator:次のいずれかを選択します。
    • greater_than
    • less_than
    • greater_or_equal
    • less_or_equal
    • equal
    • not_equal
    • between
    • not_between
  • minValue:検証範囲の最小値を定義します。演算子が between または not_between の場合に使用します。キーは、リスト検証タイプには適用されません。
  • maxValue:検証範囲の最大値を定義します。 演算子が between または not_between の場合に使用します。キーは、リスト検証タイプには適用されません。
  • alertTitle:エラーメッセージボックスのタイトルです。
  • alertText:検証が失敗したときに表示されるエラーメッセージです。
  • cellSelectTitle:セルを選択したときのメッセージボックスのタイトルです。
  • cellSelectText:セルを選択したときにボックス内に表示されるテキストです。

例 - 整数の検証

例 1 - greater_than の使用 

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-gt.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
value : 94,
operator : &quot;greater_than&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer greater than 94.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-gt.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], value : 94, operator : &quot;greater_than&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer greater than 94.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-gt.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        value : 94, 
        operator : &quot;greater_than&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer greater than 94.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 2 - less_than の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-lt.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
value : 94,
operator : &quot;less_than&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer less than 94.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-lt.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], value : 94, operator : &quot;less_than&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer less than 94.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-lt.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        value : 94, 
        operator : &quot;less_than&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer less than 94.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 3 - greater_or_equal の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-gte.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
value : 94,
operator : &quot;greater_or_equal&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer greater or equal to 94.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-gte.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], value : 94, operator : &quot;greater_or_equal&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer greater or equal to 94.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-gte.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        value : 94, 
        operator : &quot;greater_or_equal&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer greater or equal to 94.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 4 - less_or_equal の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-lte.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
value : 94,
operator : &quot;less_or_equal&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer less than or equal to 94.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-lte.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], value : 94, operator : &quot;less_or_equal&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer less than or equal to 94.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-lte.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        value : 94, 
        operator : &quot;less_or_equal&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer less than or equal to 94.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 5 - equal の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-equal.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
value : 94,
operator : &quot;equal&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer equal to 94.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-equal.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], value : 94, operator : &quot;equal&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer equal to 94.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-equal.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        value : 94, 
        operator : &quot;equal&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer equal to 94.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 6 - not_equal の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-not-equal.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
value : 94,
operator : &quot;not_equal&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer not equal to 94.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-not-equal.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], value : 94, operator : &quot;not_equal&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer not equal to 94.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-not-equal.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        value : 94, 
        operator : &quot;not_equal&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer not equal to 94.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 7 - between の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-between.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
minValue : 50,
maxValue: 100,
operator : &quot;between&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer between 50-100.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-between.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], minValue : 50, maxValue: 100, operator : &quot;between&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer between 50-100.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-between.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        minValue : 50, 
        maxValue: 100, 
        operator : &quot;between&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer between 50-100.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

例 8 - not_between の使用

<cfscript>
theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-not-between.xls&quot;;
// スプレッドシートオブジェクトを作成します
theSheet=spreadsheetNew(&quot;SampleData&quot;)
// 列を追加します
spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1)
//ヘッダーを書式設定します
spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1)
// 整数の検証を追加します
// 検証の構造体を追加します
validationStruct={
validationType : &quot;integer&quot;,
regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }],
minValue : 50,
maxValue: 100,
operator : &quot;not_between&quot;,
alertTitle:&quot;Data validation failed&quot;,
alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;,
cellSelectTitle:&quot;Enter a number&quot;,
cellSelectText:&quot;Make sure you enter an integer not between 50-100.&quot;
}
try{
SpreadsheetAddDataValidationRule(theSheet,validationStruct)
writeOutput(&quot;Data validation rule applied successfully&quot;)
}
catch(any e){
writeOutput(e.message)
}
// スプレッドシートに書き込みます
spreadsheetWrite(theSheet,theFile,&quot;yes&quot;)
</cfscript>
<cfscript> theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-not-between.xls&quot;; // スプレッドシートオブジェクトを作成します theSheet=spreadsheetNew(&quot;SampleData&quot;) // 列を追加します spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) //ヘッダーを書式設定します spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) // 整数の検証を追加します // 検証の構造体を追加します validationStruct={ validationType : &quot;integer&quot;, regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], minValue : 50, maxValue: 100, operator : &quot;not_between&quot;, alertTitle:&quot;Data validation failed&quot;, alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, cellSelectTitle:&quot;Enter a number&quot;, cellSelectText:&quot;Make sure you enter an integer not between 50-100.&quot; } try{ SpreadsheetAddDataValidationRule(theSheet,validationStruct) writeOutput(&quot;Data validation rule applied successfully&quot;) } catch(any e){ writeOutput(e.message) } // スプレッドシートに書き込みます spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) </cfscript>
<cfscript> 
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & &quot;sheet-validate-integer-not-between.xls&quot;; 
    // スプレッドシートオブジェクトを作成します 
    theSheet=spreadsheetNew(&quot;SampleData&quot;)  
    // 列を追加します 
    spreadsheetAddRow(theSheet,&quot;Integer&quot;,1,1) 
    //ヘッダーを書式設定します 
    spreadsheetformatRow(theSheet,{bold=true,alignment='center'},1) 
    // 整数の検証を追加します 
    // 検証の構造体を追加します 
    validationStruct={ 
        validationType : &quot;integer&quot;, 
        regions : [ { startRow : 2, startColumn : 1, endRow : 11, endColumn : 1 }], 
        minValue : 50, 
        maxValue: 100, 
        operator : &quot;not_between&quot;, 
        alertTitle:&quot;Data validation failed&quot;, 
        alertText:&quot;The number you've entered is invalid. Check the number and re-try.&quot;, 
        cellSelectTitle:&quot;Enter a number&quot;, 
        cellSelectText:&quot;Make sure you enter an integer not between 50-100.&quot; 
    } 

    try{ 
        SpreadsheetAddDataValidationRule(theSheet,validationStruct) 
        writeOutput(&quot;Data validation rule applied successfully&quot;) 
    } 

    catch(any e){ 
        writeOutput(e.message) 
    } 

    // スプレッドシートに書き込みます 
    spreadsheetWrite(theSheet,theFile,&quot;yes&quot;) 
</cfscript>

ヘルプをすばやく簡単に入手

新規ユーザーの場合

Acrobat 購入相談

Acrobat 購入相談

Acrobat 購入相談

Acrobat 購入相談