Conditional でブール値の条件にアクセスします。各条件付き書式ルールには、1 つのブール条件を含めることができます。ブール条件自体には、ブール条件(値付き)と書式設定が含まれています。条件はセルの内容に対して評価され、true または false のいずれかの値が返されます。条件が true と評価された場合、条件の書式設定がセルに適用されます。
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
get | Color|null | このブール条件の背景色を取得します。 |
get | Boolean|null | このブール条件でテキストが太字になる場合は true を返し、このブール条件でテキストの太字が削除される場合は false を返します。 |
get | Boolean | Boolean 列挙型で定義されているルールの条件タイプを取得します。 |
get | Object[] | ルールの条件の引数の配列を取得します。 |
get | Color|null | このブール条件のフォントの色を取得します。 |
get | Boolean|null | このブール条件でテキストが斜体になる場合は true を返し、このブール条件でテキストから斜体が削除される場合は false を返します。 |
get | Boolean|null | このブール条件がテキストに打ち消し線を引く場合は true を返し、このブール条件がテキストから打ち消し線を削除する場合は false を返します。 |
get | Boolean|null | このブール条件がテキストに下線を引く場合は true を返し、このブール条件がテキストから下線を削除する場合は false を返します。 |
詳細なドキュメント
get Background Object()
このブール条件の背景色を取得します。設定されていない場合は null を返します。
// Logs the boolean condition background color for each conditional format rule // on a sheet. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); for (const rule of rules) { const color = rule.getBooleanCondition().getBackgroundObject(); Logger.log(`Background color: ${color.asRgbColor().asHexString()}`); }
戻る
Color|null - 背景色。この条件に設定されていない場合は null。
get Bold()
このブール条件でテキストが太字になる場合は true を返し、このブール条件でテキストの太字が削除される場合は false を返します。太字が変更されない場合は null を返します。
// Logs the boolean condition font weight for each conditional format rule on a // sheet. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); for (const rule of rules) { const bold = rule.getBooleanCondition().getBold(); Logger.log(`Bold: ${bold}`); }
戻る
Boolean|null - ブール条件でテキストが太字になるかどうか。太字にならない場合は null
get Criteria Type()
Boolean 列挙型で定義されているルールの条件タイプを取得します。条件の引数を取得するには、get を使用します。これらの値を使用して条件付き書式ルールを作成または変更するには、Conditional をご覧ください。
// Log information about the conditional formats on the active sheet that use // boolean conditions. const formats = SpreadsheetApp.getActiveSheet.getConditionalFormats(); SpreadsheetApp.getActiveSheet.getConditionalFormats().forEach((format) => { const booleanCondition = format.getBooleanCondition(); if (booleanCondition) { const criteria = booleanCondition.getCriteriaType(); const args = booleanCondition.getCriteriaValues(); Logger.log(`The conditional format rule is ${criteria} ${args}`); } });
戻る
Boolean - 条件付き書式の条件のタイプ。
get Criteria Values()
ルールの条件の引数の配列を取得します。条件タイプを取得するには、get を使用します。これらの値を使用して条件付き書式ルールを作成または変更するには、Conditional をご覧ください。
// Log information about the conditional formats on the active sheet that use // boolean conditions. const formats = SpreadsheetApp.getActiveSheet.getConditionalFormats(); SpreadsheetApp.getActiveSheet.getConditionalFormats().forEach((format) => { const booleanCondition = format.getBooleanCondition(); if (booleanCondition) { const criteria = booleanCondition.getCriteriaType(); const args = booleanCondition.getCriteriaValues(); Logger.log(`The conditional format rule is ${criteria} ${args}`); } });
戻る
Object[] - ルールの条件タイプに適した引数の配列。引数の数とその型は、Conditional クラスの対応する when...() メソッドと一致します。
get Font Color Object()
このブール条件のフォントの色を取得します。設定されていない場合は null を返します。
// Logs the boolean condition font color for each conditional format rule on a // sheet. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); for (const rule of rules) { const color = rule.getBooleanCondition().getFontColorObject(); Logger.log(`Font color: ${color.asRgbColor().asHexString()}`); }
戻る
Color|null - フォントの色。この条件に設定されていない場合は null。
get Italic()
このブール条件でテキストが斜体になる場合は true を返し、このブール条件でテキストから斜体が削除される場合は false を返します。斜体が影響を受けない場合は null を返します。
// Logs the boolean condition font style for each conditional format rule on a // sheet. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); for (const rule of rules) { const italic = rule.getBooleanCondition().getItalic(); Logger.log(`Italic: ${italic}`); }
戻る
Boolean|null - ブール条件がテキストを斜体にするかどうか。斜体にするかどうかに関係がない場合は null
get Strikethrough()
このブール条件がテキストに打ち消し線を引く場合は true を返し、このブール条件がテキストから打ち消し線を削除する場合は false を返します。取り消し線が影響を受けない場合は null を返します。
// Logs the boolean condition strikethrough setting for each conditional format // rule on a sheet. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); for (const rule of rules) { const strikethrough = rule.getBooleanCondition().getStrikethrough(); Logger.log(`Strikethrough: ${strikethrough}`); }
戻る
Boolean|null - ブール条件がテキストに打ち消し線を引くかどうか。打ち消し線が影響を受けない場合は null
get Underline()
このブール条件がテキストに下線を引く場合は true を返し、このブール条件がテキストから下線を削除する場合は false を返します。下線が変更されない場合は null を返します。
// Logs the boolean condition underline setting for each conditional format rule // on a sheet. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); for (const rule of rules) { const underline = rule.getBooleanCondition().getUnderline(); Logger.log(`Underline: ${underline}`); }
戻る
Boolean|null - ブール条件がテキストに下線を引くかどうか。下線が引かれない場合は null