Builder para regras de formatação condicional.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number between 1 and 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Métodos
Método | Tipo de retorno | Breve descrição |
---|---|---|
build() | ConditionalFormatRule | Cria uma regra de formato condicional nas configurações aplicadas ao builder. |
copy() | ConditionalFormatRuleBuilder | Retorna uma predefinição de criador de regras com as configurações desta regra. |
getBooleanCondition() | BooleanCondition | Recupera as informações do BooleanCondition da regra se essa regra usar critérios de condição booleana. |
getGradientCondition() | GradientCondition | Recupera as informações do GradientCondition da regra se essa regra usar critérios de condição de gradiente. |
getRanges() | Range[] | Recupera os intervalos a que esta regra de formatação condicional é aplicada. |
setBackground(color) | ConditionalFormatRuleBuilder | Define a cor do plano de fundo do formato da regra condicional de formato. |
setBackgroundObject(color) | ConditionalFormatRuleBuilder | Define a cor do plano de fundo do formato da regra condicional de formato. |
setBold(bold) | ConditionalFormatRuleBuilder | Define o negrito do texto da regra de formato condicional. |
setFontColor(color) | ConditionalFormatRuleBuilder | Define a cor da fonte para o formato da regra condicional de formato. |
setFontColorObject(color) | ConditionalFormatRuleBuilder | Define a cor da fonte para o formato da regra condicional de formato. |
setGradientMaxpoint(color) | ConditionalFormatRuleBuilder | Limpa o valor máximo do gradiente da regra condicional de formato e usa o valor máximo nos intervalos da regra. |
setGradientMaxpointObject(color) | ConditionalFormatRuleBuilder | Limpa o valor máximo do gradiente da regra condicional de formato e usa o valor máximo nos intervalos da regra. |
setGradientMaxpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | Define os campos de ponto máximo do gradiente da regra condicional do formato condicional. |
setGradientMaxpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | Define os campos de ponto máximo do gradiente da regra condicional do formato condicional. |
setGradientMidpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | Define os campos de ponto médio do gradiente da regra condicional de formato. |
setGradientMidpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | Define os campos de ponto médio do gradiente da regra condicional de formato. |
setGradientMinpoint(color) | ConditionalFormatRuleBuilder | Limpa o valor de minpoint do gradiente condicional da regra e formata o valor mínimo nos intervalos dele. |
setGradientMinpointObject(color) | ConditionalFormatRuleBuilder | Limpa o valor de minpoint do gradiente condicional da regra e formata o valor mínimo nos intervalos dele. |
setGradientMinpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | Define os campos de minpoint do gradiente condicional da regra de formato condicional. |
setGradientMinpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | Define os campos de minpoint do gradiente condicional da regra de formato condicional. |
setItalic(italic) | ConditionalFormatRuleBuilder | Define o itálico do texto da regra de formato condicional. |
setRanges(ranges) | ConditionalFormatRuleBuilder | Define um ou mais intervalos aos quais a regra de formato condicional é aplicada. |
setStrikethrough(strikethrough) | ConditionalFormatRuleBuilder | Define o tachado do texto para o formato da regra condicional de formato. |
setUnderline(underline) | ConditionalFormatRuleBuilder | Define o sublinhado do texto da regra de formato condicional. |
whenCellEmpty() | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando a célula estiver vazia. |
whenCellNotEmpty() | ConditionalFormatRuleBuilder | Define a regra de formatação condicional para ser acionada quando a célula não estiver vazia. |
whenDateAfter(date) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando uma data for posterior ao valor fornecido. |
whenDateAfter(date) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando uma data for posterior à data relativa especificada. |
whenDateBefore(date) | ConditionalFormatRuleBuilder | Define a regra de formatação condicional para ser acionada quando uma data for anterior à data especificada. |
whenDateBefore(date) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando uma data for anterior à data relativa especificada. |
whenDateEqualTo(date) | ConditionalFormatRuleBuilder | Define a regra de formatação condicional para ser acionada quando uma data for igual à data especificada. |
whenDateEqualTo(date) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando uma data for igual à data relativa fornecida. |
whenFormulaSatisfied(formula) | ConditionalFormatRuleBuilder | Define a regra de formato condicional que será acionada quando a fórmula especificada for avaliada como true . |
whenNumberBetween(start, end) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando um número estiver entre ou for um dos dois valores especificados. |
whenNumberEqualTo(number) | ConditionalFormatRuleBuilder | Define a regra de formatação condicional para ser acionada quando um número for igual ao valor informado. |
whenNumberGreaterThan(number) | ConditionalFormatRuleBuilder | Define a regra de formatação condicional para ser acionada quando um número for maior que o valor informado. |
whenNumberGreaterThanOrEqualTo(number) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando um número for maior ou igual ao valor informado. |
whenNumberLessThan(number) | ConditionalFormatRuleBuilder | Define a regra de formatação condicional condicional para ser acionada quando um número menor que o valor fornecido. |
whenNumberLessThanOrEqualTo(number) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando um número menor ou igual ao valor fornecido. |
whenNumberNotBetween(start, end) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando um número não ficar entre e não for dois dos dois valores especificados. |
whenNumberNotEqualTo(number) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando um número não for igual ao valor informado. |
whenTextContains(text) | ConditionalFormatRuleBuilder | Define a regra de formato condicional que será acionada quando a entrada contiver o valor informado. |
whenTextDoesNotContain(text) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para ser acionada quando a entrada não contiver o valor especificado. |
whenTextEndsWith(text) | ConditionalFormatRuleBuilder | Define a regra de formato condicional que será acionada quando a entrada terminar com o valor informado. |
whenTextEqualTo(text) | ConditionalFormatRuleBuilder | Define a regra de formato condicional que será acionada quando a entrada for igual ao valor informado. |
whenTextStartsWith(text) | ConditionalFormatRuleBuilder | Define a regra de formato condicional que será acionada quando a entrada começar com o valor informado. |
withCriteria(criteria, args) | ConditionalFormatRuleBuilder | Define a regra de formato condicional para critérios definidos por valores de BooleanCriteria , normalmente baseados em criteria e arguments de uma regra existente. |
Documentação detalhada
build()
Cria uma regra de formato condicional nas configurações aplicadas ao builder.
Retornar
ConditionalFormatRule
: uma representação da regra de formato condicional
copy()
Retorna uma predefinição de criador de regras com as configurações desta regra.
Retornar
ConditionalFormatRuleBuilder
: um builder baseado nas configurações desta regra
getBooleanCondition()
Recupera as informações do BooleanCondition
da regra se essa regra usar critérios de condição booleana. Caso contrário, retorna null
.
// Log the boolean criteria type of the first conditional format rules of a sheet. var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; var booleanCondition = rule.getBooleanCondition(); if (booleanCondition != null) { Logger.log(booleanCondition.getCriteriaType()); }
Retornar
BooleanCondition
: o objeto da condição booleana, ou null
se a regra não usar uma condição booleana.
getGradientCondition()
Recupera as informações do GradientCondition
da regra se essa regra usar critérios de condição de gradiente. Caso contrário, retorna null
.
// Log the gradient minimum color of the first conditional format rule of a sheet. var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; var gradientCondition = rule.getGradientCondition(); if (gradientCondition != null) { // Assume the color has ColorType.RGB. Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString()); }
Retornar
GradientCondition
: o objeto da condição de gradiente ou null
se a regra não usar uma condição de gradiente.
getRanges()
Recupera os intervalos a que esta regra de formatação condicional é aplicada.
// Log each range of the first conditional format rule of a sheet. var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; var ranges = rule.getRanges(); for (var i = 0; i < ranges.length; i++) { Logger.log(ranges[i].getA1Notation()); }
Retornar
Range[]
: os intervalos aos quais a regra de formatação condicional é aplicada.
setBackground(color)
Define a cor do plano de fundo do formato da regra condicional de formato. Transmitir em null
remove a configuração de formato de cor de fundo da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color to red if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor desejada ou null para limpar. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setBackgroundObject(color)
Define a cor do plano de fundo do formato da regra condicional de formato. Transmitir em null
remove a configuração de formato de cor de fundo da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color to theme background color if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBackground(color) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | O objeto de cor desejado ou null para limpar. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setBold(bold)
Define o negrito do texto da regra de formato condicional. Se bold
for true
,
a regra vai colocar o texto em negrito se a condição for atendida. Se false
, a regra vai remover qualquer negrito
se a condição for atendida. Transmitir null
remove a configuração de formato em negrito da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn their // text bold if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBold(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
bold | Boolean | Indica se o texto precisa estar em negrito se a condição de formato for atendida. null remove essa configuração. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setFontColor(color)
Define a cor da fonte para o formato da regra condicional de formato. Transmitir null
remove a
configuração de formato de cor da fonte da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their font // color to red if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setFontColor("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor desejada ou null para limpar. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setFontColorObject(color)
Define a cor da fonte para o formato da regra condicional de formato. Transmitir null
remove a
configuração de formato de cor da fonte da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their font // color to theme text color if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setFontColor(color) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | O objeto de cor desejado ou null para limpar. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setGradientMaxpoint(color)
Limpa o valor máximo do gradiente da regra condicional de formato e usa o valor máximo nos intervalos da regra. Também define a cor máxima do gradiente para a cor de entrada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere between white and red, based on their values in comparison to // the ranges minimum and maximum values. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint("#FF0000") .setGradientMinpoint("#FFFFFF") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor máxima para definir. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setGradientMaxpointObject(color)
Limpa o valor máximo do gradiente da regra condicional de formato e usa o valor máximo nos intervalos da regra. Também define a cor máxima do gradiente para a cor de entrada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere between theme text and background colors, based on their values // in comparison to the ranges minimum and maximum values. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var textColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); var backgroundColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint(textColor) .setGradientMinpoint(backgroundColor) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | Objeto de cor maxpoint a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setGradientMaxpointObjectWithValue(color, type, value)
Define os campos de ponto máximo do gradiente da regra condicional do formato condicional.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from theme accent 1, accent 2 to accent 3 colors, based on their // values in comparison to the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); var color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); var color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | A cor máxima para definir. |
type | InterpolationType | Tipo de interpolação maxpoint a ser definido. |
value | String | O valor máximo do ponto a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setGradientMaxpointWithValue(color, type, value)
Define os campos de ponto máximo do gradiente da regra condicional do formato condicional.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from red green to blue, based on their values in comparison to // the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor máxima para definir. |
type | InterpolationType | Tipo de interpolação maxpoint a ser definido. |
value | String | O valor máximo do ponto a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setGradientMidpointObjectWithValue(color, type, value)
Define os campos de ponto médio do gradiente da regra condicional de formato. Limpa todos os campos de ponto médio se o tipo de interpolação transmitido for null
.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from theme accent 1 to accent 2 to accent 3 colors, based on // their values in comparison to the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); var color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); var color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | A cor do ponto médio a ser definida. |
type | InterpolationType | O tipo de interpolação do ponto médio a ser definido ou null para limpar. |
value | String | O valor do ponto médio a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setGradientMidpointWithValue(color, type, value)
Define os campos de ponto médio do gradiente da regra condicional de formato. Limpa todos os campos de ponto médio se o tipo de interpolação transmitido for null
.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from red green to blue, based on their values in comparison to // the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor do ponto médio a ser definida. |
type | InterpolationType | O tipo de interpolação do ponto médio a ser definido ou null para limpar. |
value | String | O valor do ponto médio a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setGradientMinpoint(color)
Limpa o valor de minpoint do gradiente condicional da regra e formata o valor mínimo nos intervalos dele. Também define a cor mínima do gradiente do gradiente para a cor de entrada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere between white and red, based on their values in comparison to // the ranges minimum and maximum values. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint("#FF0000") .setGradientMinpoint("#FFFFFF") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor do minpoint a ser definida. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setGradientMinpointObject(color)
Limpa o valor de minpoint do gradiente condicional da regra e formata o valor mínimo nos intervalos dele. Também define a cor mínima do gradiente do gradiente para a cor de entrada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere between theme text and background colors, based on their values // in comparison to the ranges minimum and maximum values. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var textColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); var backgroundColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint(textColor) .setGradientMinpoint(backgroundColor) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | Objeto de cor minpoint a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setGradientMinpointObjectWithValue(color, type, value)
Define os campos de minpoint do gradiente condicional da regra de formato condicional.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from theme accent 1 to accent 2 to accent 3 colors, based on // their values in comparison to the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); var color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); var color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | Color | A cor do minpoint a ser definida. |
type | InterpolationType | Tipo de interpolação de minpoint a ser definido. |
value | String | O valor de minpoint a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento.
setGradientMinpointWithValue(color, type, value)
Define os campos de minpoint do gradiente condicional da regra de formato condicional.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from red to green to blue, based on their values in comparison to // the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
color | String | A cor do minpoint a ser definida. |
type | InterpolationType | Tipo de interpolação de minpoint a ser definido. |
value | String | O valor de minpoint a ser definido. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setItalic(italic)
Define o itálico do texto da regra de formato condicional. Se italic
for true
,
a regra exibirá itálico no texto se a condição for atendida. Se false
, a regra removerá qualquer
itálico existente se a condição for atendida. Transmitir null
remove a configuração de
formato itálico da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn their // text italic if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setItalic(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
italic | Boolean | Indica se o texto precisa ou não estar em itálico se a condição do formato for atendida.
null remove essa configuração. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setRanges(ranges)
Define um ou mais intervalos aos quais a regra de formato condicional é aplicada. Essa operação substitui todos os intervalos atuais. Definir uma matriz vazia limpa todos os intervalos atuais. Uma regra precisa ter pelo menos um intervalo.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 and range D4:F6 // to turn red if they contain a number between 1 and 10. var sheet = SpreadsheetApp.getActiveSheet(); var rangeOne = sheet.getRange("A1:B3"); var rangeTwo = sheet.getRange("D4:F6"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground("#FF0000") .setRanges([rangeOne, rangeTwo]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
ranges | Range[] | Os intervalos aos quais a regra de formato condicional é aplicada. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setStrikethrough(strikethrough)
Define o tachado do texto para o formato da regra condicional de formato. Se strikethrough
for true
, a regra substituirá o texto se a condição for atendida. Se false
, a regra removerá qualquer formatação tachada se a condição for atendida. Transmitir em null
remove a configuração de formato tachado da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to strikethrough // their text if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setStrikethrough(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
strikethrough | Boolean | Indica se o texto precisa ser tachado se a condição de formato for
atendida. null remove essa configuração. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
setUnderline(underline)
Define o sublinhado do texto da regra de formato condicional. Se underline
for true
, a regra sublinha o texto se a condição for atendida. Se false
, a regra removerá qualquer sublinhado atual se a condição for atendida. Transmitir null
remove a configuração de
formato de sublinhado da regra.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to underline // their text if the cell has text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setUnderline(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
underline | Boolean | Indica se o texto precisa ser sublinhado se a condição de formato for atendida.
null remove essa configuração. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenCellEmpty()
Define a regra de formato condicional para ser acionada quando a célula estiver vazia.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they are empty. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenCellEmpty() .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenCellNotEmpty()
Define a regra de formatação condicional para ser acionada quando a célula não estiver vazia.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they are not empty. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenCellNotEmpty() .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenDateAfter(date)
Define a regra de formato condicional para ser acionada quando uma data for posterior ao valor fornecido.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a date after 11/4/1993. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateAfter(new Date("11/4/1993")) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
date | Date | A data mais recente. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenDateAfter(date)
Define a regra de formato condicional para ser acionada quando uma data for posterior à data relativa especificada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a date after today. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
date | RelativeDate | A data mais recente em relação ao tipo de data selecionado. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenDateBefore(date)
Define a regra de formatação condicional para ser acionada quando uma data for anterior à data especificada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a date before 11/4/1993. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateBefore(new Date("11/4/1993")) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
date | Date | A data inaceitável mais antiga. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenDateBefore(date)
Define a regra de formato condicional para ser acionada quando uma data for anterior à data relativa especificada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a date before today. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
date | RelativeDate | A data mais recente em relação ao tipo de data selecionado. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenDateEqualTo(date)
Define a regra de formatação condicional para ser acionada quando uma data for igual à data especificada.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain the date 11/4/1993. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateEqualTo(new Date("11/4/1993")) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
date | Date | A única data aceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenDateEqualTo(date)
Define a regra de formato condicional para ser acionada quando uma data for igual à data relativa fornecida.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain todays date. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateEqualTo(SpreadsheetApp.RelativeDate.TODAY) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
date | RelativeDate | A data mais recente em relação ao tipo de data selecionado. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenFormulaSatisfied(formula)
Define a regra de formato condicional que será acionada quando a fórmula especificada for avaliada como true
.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they satisfy the condition "=EQ(B4, C3)". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenFormulaSatisfied("=EQ(B4, C3)") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
formula | String | Uma fórmula personalizada que avalia como true se a entrada for válida. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberBetween(start, end)
Define a regra de formato condicional para ser acionada quando um número estiver entre ou for um dos dois valores especificados.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number between 1 and 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
start | Number | É o menor valor aceitável. |
end | Number | É o maior valor aceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberEqualTo(number)
Define a regra de formatação condicional para ser acionada quando um número for igual ao valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain the number 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
number | Number | O único valor aceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberGreaterThan(number)
Define a regra de formatação condicional para ser acionada quando um número for maior que o valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red // if they contain a number greater than 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberGreaterThan(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
number | Number | É o valor inaceitável mais alto. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberGreaterThanOrEqualTo(number)
Define a regra de formato condicional para ser acionada quando um número for maior ou igual ao valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number greater than or equal to 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberGreaterThanOrEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
number | Number | É o menor valor aceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberLessThan(number)
Define a regra de formatação condicional condicional para ser acionada quando um número menor que o valor fornecido.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number less than 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberLessThan(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
number | Number | É o menor valor inaceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberLessThanOrEqualTo(number)
Define a regra de formato condicional para ser acionada quando um número menor ou igual ao valor fornecido.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number less than or equal to 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberLessThanOrEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
number | Number | É o maior valor aceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberNotBetween(start, end)
Define a regra de formato condicional para ser acionada quando um número não ficar entre e não for dois dos dois valores especificados.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number not between 1 and 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberNotBetween(1, 10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
start | Number | É o menor valor inaceitável. |
end | Number | É o valor inaceitável mais alto. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenNumberNotEqualTo(number)
Define a regra de formato condicional para ser acionada quando um número não for igual ao valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they don't contain the number 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberNotEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
number | Number | O único valor inaceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenTextContains(text)
Define a regra de formato condicional que será acionada quando a entrada contiver o valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain the text "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextContains("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
text | String | O valor que a entrada precisa conter. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenTextDoesNotContain(text)
Define a regra de formato condicional para ser acionada quando a entrada não contiver o valor especificado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they don't contain the text "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextDoesNotContain("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
text | String | O valor que a entrada não pode conter. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenTextEndsWith(text)
Define a regra de formato condicional que será acionada quando a entrada terminar com o valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they end with the text "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEndsWith("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
text | String | Texto para comparar com o fim da string. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenTextEqualTo(text)
Define a regra de formato condicional que será acionada quando a entrada for igual ao valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they have text equal to "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
text | String | O único valor aceitável. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
whenTextStartsWith(text)
Define a regra de formato condicional que será acionada quando a entrada começar com o valor informado.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they start with the text "hello". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextStartsWith("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
text | String | Texto para comparar com o início da string. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento
withCriteria(criteria, args)
Define a regra de formato condicional para critérios definidos por valores de BooleanCriteria
, normalmente baseados em criteria
e arguments
de uma regra existente.
// Adds a new conditional format rule that is a copy of the first active // conditional format rule, except it instead sets its cells to have a black // background color. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); var booleanCondition = rules[0].getBooleanCondition(); if (booleanCondition != null) { var rule = SpreadsheetApp.newConditionalFormatRule() .withCriteria(booleanCondition.getCriteriaType(), booleanCondition.getCriteriaValues()) .setBackground("#000000") .setRanges(rule.getRanges()) .build(); rules.push(rule); } sheet.setConditionalFormatRules(rules);
Parâmetros
Nome | Tipo | Descrição |
---|---|---|
criteria | BooleanCriteria | É o tipo de critério de formato condicional. |
args | Object[] | Uma matriz de argumentos apropriados para o tipo de critério. O número de argumentos e o tipo deles correspondem ao método when...() correspondente acima. |
Retornar
ConditionalFormatRuleBuilder
: o builder, para encadeamento