ConditionalFormatRules のブール条件にアクセスします。各条件付き書式ルールには、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 を返します。 |
詳細なドキュメント
getBackgroundObject()
このブール条件の背景色を取得します。設定されていない場合は 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。
getBold()
このブール条件でテキストが太字になる場合は 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。
getCriteriaType()
BooleanCriteria 列挙型で定義されているルールの条件タイプを取得します。条件の引数を取得するには、getCriteriaValues()
を使用します。これらの値を使用して条件付き書式ルールを作成または
変更するには、ConditionalFormatRuleBuilder.withCriteria(criteria, args) をご覧ください。
// 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}`); } });
戻る
BooleanCriteria - 条件付き書式の条件のタイプ。
getCriteriaValues()
ルールの条件の引数の配列を取得します。条件タイプを取得するには、getCriteriaType()
を使用します。これらの値を使用して条件付き書式ルールを作成または変更するには、
ConditionalFormatRuleBuilder.withCriteria(criteria, args).
をご覧ください。
// 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[] - ルールの条件タイプに適した引数の配列。引数の数
とその型は、ConditionalFormatRuleBuilder クラスの対応する when...() メソッドと一致します。
getFontColorObject()
このブール条件のフォントの色を取得します。設定されていない場合は 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。
getItalic()
このブール条件でテキストが斜体になる場合は 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。
getStrikethrough()
このブール条件でテキストに取り消し線が引かれる場合は 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。
getUnderline()
このブール条件でテキストに下線が引かれる場合は 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。