Accede a 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 una configuración de formato. Los criterios se evalúan según el contenido de una celda, lo que da como resultado un valor true
o false
. Si los criterios se evalúan como true
, la configuración de formato de la condición se aplica a la celda.
Métodos
Método | Tipo de datos que se muestra | Descripción breve |
---|---|---|
getBackgroundObject() | Color | Obtiene el color de fondo para esta condición booleana. |
getBold() | Boolean | Muestra true si esta condición booleana escribe en negrita el texto y muestra false si esta condición booleana quita la negrita del texto. |
getCriteriaType() | BooleanCriteria | Obtiene el tipo de criterios de la regla como se define en la enumeración BooleanCriteria . |
getCriteriaValues() | Object[] | Obtiene un arreglo de argumentos para los criterios de la regla. |
getFontColorObject() | Color | Obtiene el color de fuente para esta condición booleana. |
getItalic() | Boolean | Muestra true si esta condición booleana escribe en cursiva el texto y muestra false si esta condición booleana quita la cursiva del texto. |
getStrikethrough() | Boolean | Muestra true si esta condición booleana tacha el texto y muestra false si esta condición booleana quita el tachado del texto. |
getUnderline() | Boolean | Muestra true si esta condición booleana subraya el texto y muestra false si esta condición booleana quita el subrayado del texto. |
Documentación detallada
getBackgroundObject()
Obtiene el color de fondo para esta condición booleana. Muestra null
si no está configurado.
// Logs the boolean condition background color for each conditional format rule on a sheet. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); for (int i = 0; i < rules.length; i++) { var color = rules[i].getBooleanCondition().getBackgroundObject(); Logger.log("The background color for rule %s is %s", i, color.asRgbColor().asHexString()); }
Volver
Color
: Es el color de fondo o null
si no se establece para esta condición.
getBold()
Muestra true
si esta condición booleana escribe en negrita el texto y muestra false
si esta condición booleana quita la negrita del texto. Muestra null
si la negrita no se ve afectada.
// Logs the boolean condition font weight for each conditional format rule on a sheet. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); for (int i = 0; i < rules.length; i++) { var bold = rules[i].getBooleanCondition().getBold(); Logger.log("The font bold setting for rule %s is %b", i, weight); }
Volver
Boolean
: Indica si la condición booleana negrita al texto o null
si la negrita no se ve afectada
getCriteriaType()
Obtiene el tipo de criterios de la regla como se define en la enumeración BooleanCriteria
. A fin de obtener los argumentos de los criterios, usa getCriteriaValues()
. Si deseas 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. var sheet = SpreadsheetApp.getActiveSheet; var formats = sheet.getConditionalFormats(); sheet.getConditionalFormats().forEach(function(format) { var booleanCondition = format.getBooleanCondition(); if (booleanCondition) { var criteria = booleanCondition.getCriteriaType(); var args = booleanCondition.getCriteriaValues(); Logger.log('The conditional format rule is %s %s', criteria, args); } });
Volver
BooleanCriteria
: Es el tipo de criterios de formato condicional.
getCriteriaValues()
Obtiene un arreglo de argumentos para los criterios de la regla. Para obtener el tipo de criterios, usa getCriteriaType()
. Si deseas 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. var sheet = SpreadsheetApp.getActiveSheet; var formats = sheet.getConditionalFormats(); sheet.getConditionalFormats().forEach(function(format) { var booleanCondition = format.getBooleanCondition(); if (booleanCondition) { var criteria = booleanCondition.getCriteriaType(); var args = booleanCondition.getCriteriaValues(); Logger.log('The conditional format rule is %s %s', criteria, args); } });
Volver
Object[]
: Es un arreglo de argumentos apropiados para el tipo de criterios 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. Muestra null
si no está configurado.
// Logs the boolean condition font color for each conditional format rule on a sheet. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); for (int i = 0; i < rules.length; i++) { var color = rules[i].getBooleanCondition().getFontColorObject(); Logger.log("The font color for rule %s is %s", i, color.asRgbColor().asHexString()); }
Volver
Color
: El color de la fuente o null
si no se establece para esta condición.
getItalic()
Muestra true
si esta condición booleana escribe en cursiva el texto y muestra false
si esta condición booleana quita la cursiva del texto. Muestra null
si las cursivas no se ven afectadas.
// Logs the boolean condition font style for each conditional format rule on a sheet. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); for (int i = 0; i < rules.length; i++) { var italic = rules[i].getBooleanCondition().getItalic(); Logger.log("The font italic setting for rule %s is %b", i, italic); }
Volver
Boolean
: indica si la condición booleana está en cursiva o no, o null
si no se modifica.
getStrikethrough()
Muestra true
si esta condición booleana tacha el texto y muestra false
si esta condición booleana quita el tachado del texto. Muestra null
si la tachado no se ve afectada.
// Logs the boolean condition strikethrough setting for each conditional format rule on a // sheet. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); for (int i = 0; i < rules.length; i++) { var strikethrough = rules[i].getBooleanCondition().getStrikethrough(); Logger.log("The font strikethrough setting for rule %s is %b", i, strikethrough); }
Volver
Boolean
: Indica si la condición booleana tacha o no el texto, o null
si tachado no se ve afectado.
getUnderline()
Muestra true
si esta condición booleana subraya el texto y muestra false
si esta condición booleana quita el subrayado del texto. Muestra null
si el subrayado no se ve afectado.
// Logs the boolean condition underline setting for each conditional format rule on a sheet. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); for (int i = 0; i < rules.length; i++) { var underline = rules[i].getBooleanCondition().getUnderline(); Logger.log("The font underline setting for rule %s is %b", i, underline); }
Volver
Boolean
: Indica si la condición booleana subraya el texto o null
si no se ve subrayado.