Class BooleanCondition

BooleanCondition

Accede a las condiciones booleanas en ConditionalFormatRules. Cada regla de formato condicional puede contener una sola condición booleana. La condición booleana en sí contiene un criterio booleano (con valores) y parámetros de configuración de formato. El criterio se evalúa en función del contenido de una celda, lo que da como resultado un valor true o false. Si el criterio se evalúa como true, se aplican a la celda los parámetros de configuración de formato de la condición.

Métodos

MétodoTipo de datos que se muestraDescripción breve
getBackgroundObject()Color|nullObtiene el color de fondo de esta condición booleana.
getBold()Boolean|nullDevuelve true si esta condición booleana aplica negrita al texto y devuelve false si esta condición booleana quita la negrita del texto.
getCriteriaType()BooleanCriteriaObtiene el tipo de criterio de la regla, tal como se define en la enumeración BooleanCriteria.
getCriteriaValues()Object[]Obtiene un array de argumentos para los criterios de la regla.
getFontColorObject()Color|nullObtiene el color de fuente para esta condición booleana.
getItalic()Boolean|nullDevuelve true si esta condición booleana aplica cursiva al texto y devuelve false si esta condición booleana quita la cursiva del texto.
getStrikethrough()Boolean|nullDevuelve true si esta condición booleana tacha el texto y devuelve false si esta condición booleana quita el tachado del texto.
getUnderline()Boolean|nullDevuelve true si esta condición booleana subraya el texto y devuelve false si esta condición booleana quita el subrayado del texto.

Documentación detallada

getBackgroundObject()

Obtiene el color de fondo de esta condición booleana. Devuelve null si no está configurado.

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

Volver

Color|null: Es el color de fondo o null si no se configuró para esta condición.


getBold()

Devuelve true si esta condición booleana aplica negrita al texto y devuelve false si esta condición booleana quita la negrita del texto. Devuelve null si el negrita no se ve afectado.

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

Volver

Boolean|null: Indica si la condición booleana pone el texto en negrita o null si el formato en negrita no se ve afectado.


getCriteriaType()

Obtiene el tipo de criterio de la regla, tal como se define en la enumeración BooleanCriteria. Para obtener los argumentos de los criterios, usa getCriteriaValues(). Para usar estos valores y crear o modificar una regla de formato condicional, consulta 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}`);
  }
});

Volver

BooleanCriteria: Es el tipo de criterio de formato condicional.


getCriteriaValues()

Obtiene un array de argumentos para los criterios de la regla. Para obtener el tipo de criterio, usa getCriteriaType(). Para usar estos valores para crear o modificar una regla de formato condicional, consulta 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}`);
  }
});

Volver

Object[]: Es un array de argumentos adecuados para el tipo de criterio de la regla. La cantidad de argumentos y su tipo coinciden con el método when...() correspondiente de la clase ConditionalFormatRuleBuilder.


getFontColorObject()

Obtiene el color de fuente para esta condición booleana. Devuelve null si no está configurado.

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

Volver

Color|null: Es el color de la fuente o null si no se configuró para esta condición.


getItalic()

Devuelve true si esta condición booleana aplica cursiva al texto y devuelve false si esta condición booleana quita la cursiva del texto. Devuelve null si la cursiva no se ve afectada.

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

Volver

Boolean|null: Indica si la condición booleana aplica cursiva al texto o null si la aplicación de cursiva no se ve afectada.


getStrikethrough()

Devuelve true si esta condición booleana tacha el texto y devuelve false si esta condición booleana quita el tachado del texto. Devuelve null si el tachado no se ve afectado.

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

Volver

Boolean|null: Indica si la condición booleana tacha el texto o no. null si el tachado no se ve afectado.


getUnderline()

Devuelve true si esta condición booleana subraya el texto y devuelve false si esta condición booleana quita el subrayado del texto. Devuelve null si el subrayado no se ve afectado.

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

Volver

Boolean|null: Indica si la condición booleana subraya el texto o null si el subrayado no se ve afectado.

Métodos obsoletos