A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/spreadsheet/boolean-condition below:

Class BooleanCondition | Apps Script

Class BooleanCondition

Stay organized with collections Save and categorize content based on your preferences.

BooleanCondition

Access boolean conditions in ConditionalFormatRules. Each conditional format rule may contain a single boolean condition. The boolean condition itself contains a boolean criteria (with values) and formatting settings. The criteria is evaluated against the content of a cell resulting in either a true or false value. If the criteria evaluates to true, the condition's formatting settings are applied to the cell.

Methods Method Return type Brief description getBackgroundObject() Color Gets the background color for this boolean condition. getBold() Boolean Returns true if this boolean condition bolds the text and returns false if this boolean condition removes bolding from the text. getCriteriaType() BooleanCriteria Gets the rule's criteria type as defined in the BooleanCriteria enum. getCriteriaValues() Object[] Gets an array of arguments for the rule's criteria. getFontColorObject() Color Gets the font color for this boolean condition. getItalic() Boolean Returns true if this boolean condition italicises the text and returns false if this boolean condition removes italics from the text. getStrikethrough() Boolean Returns true if this boolean condition strikes through the text and returns false if this boolean condition removes strikethrough from the text. getUnderline() Boolean Returns true if this boolean condition underlines the text and returns false if this boolean condition removes underlining from the text. Deprecated methods Method Return type Brief description getBackground() String Gets the background color string for this boolean condition. getFontColor() String Gets the font color string for this boolean condition. Detailed documentation getBackgroundObject()

Gets the background color for this boolean condition. Returns null if not set.

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

Color — The background color, or null if not set for this condition.

getBold()

Returns true if this boolean condition bolds the text and returns false if this boolean condition removes bolding from the text. Returns null if bolding is unaffected.

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

Boolean — whether or not the boolean condition bolds the text, or null if bolding is unaffected

getCriteriaType()

Gets the rule's criteria type as defined in the BooleanCriteria enum. To get the arguments for the criteria, use getCriteriaValues(). To use these values to create or modify a conditional formatting rule, see 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}`);
  }
});
Return

BooleanCriteria — The type of conditional formatting criteria.

getCriteriaValues()

Gets an array of arguments for the rule's criteria. To get the criteria type, use getCriteriaType(). To use these values to create or modify a conditional formatting rule, see 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}`);
  }
});
Return

Object[] — An array of arguments appropriate to the rule's criteria type; the number of arguments and their type match the corresponding when...() method of the ConditionalFormatRuleBuilder class.

getFontColorObject()

Gets the font color for this boolean condition. Returns null if not set.

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

Color — The font color, or null if not set for this condition.

getItalic()

Returns true if this boolean condition italicises the text and returns false if this boolean condition removes italics from the text. Returns null if italics are unaffected.

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

Boolean — whether or not the boolean condition italicises the text, or null if italicising is unaffected

getStrikethrough()

Returns true if this boolean condition strikes through the text and returns false if this boolean condition removes strikethrough from the text. Returns null if strikethrough is unaffected.

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

Boolean — whether or not the boolean condition strikes through the text, or null if strikethrough is unaffected

getUnderline()

Returns true if this boolean condition underlines the text and returns false if this boolean condition removes underlining from the text. Returns null if underlining is unaffected.

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

Boolean — whether or not the boolean condition underlines the text, or null if underlining is unaffected

Deprecated methods getBackground()

Deprecated. Replaced by getBackgroundObject()

Gets the background color string for this boolean condition. Returns null if not set.

// 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().getBackground();
  Logger.log(`Background color: ${color}`);
}
Return

String — The background color string, or null if not set for this condition.

getFontColor()

Deprecated. Replaced by getFontColorObject()

Gets the font color string for this boolean condition. Returns null if not set.

// 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) {
  Logger.log(`Font color: ${rule.getBooleanCondition().getFontColor()}`);
}
Return

String — The font color string, or null if not set for this condition.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-12-02 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["Boolean conditions within conditional format rules determine cell formatting based on criteria evaluation."],["If a boolean condition's criteria evaluates to `true`, specified formatting is applied to the cell."],["`BooleanCondition` methods allow you to retrieve and modify various formatting settings, such as background color, font styles, and criteria details."],["`getCriteriaType()` and `getCriteriaValues()` enable you to access the type and arguments of a boolean condition's criteria."],["Deprecated methods like `getBackground()` and `getFontColor()` have been replaced with object-based alternatives like `getBackgroundObject()` and `getFontColorObject()`."]]],["Boolean conditions within `ConditionalFormatRules` evaluate cell content against a defined criteria, resulting in a `true` or `false` outcome. If `true`, formatting is applied. Key actions include: retrieving the criteria type and values (`getCriteriaType`, `getCriteriaValues`), managing text formatting like bolding, italics, strikethrough, underlining (`getBold`, `getItalic`, `getStrikethrough`, `getUnderline`), and obtaining background and font colors (`getBackgroundObject`, `getFontColorObject`). The deprecated methods are `getBackground` and `getFontColor`.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4