Kreator reguł formatowania warunkowego.
// 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);
Metody
Metoda | Zwracany typ | Krótki opis |
---|---|---|
build() | ConditionalFormatRule | Konstruuje regułę formatowania warunkowego na podstawie ustawień zastosowanych do kreatora. |
copy() | ConditionalFormatRuleBuilder | Zwraca gotowe ustawienia konstruktora reguł z ustawieniami tej reguły. |
getBooleanCondition() | BooleanCondition | Pobiera informacje o BooleanCondition reguły, jeśli ta reguła używa logicznych kryteriów warunku. |
getGradientCondition() | GradientCondition | Pobiera informacje o GradientCondition reguły, jeśli ta reguła używa kryteriów warunku gradientu. |
getRanges() | Range[] | Pobiera zakresy, do których zastosowano tę regułę formatowania warunkowego. |
setBackground(color) | ConditionalFormatRuleBuilder | Ustawia kolor tła dla formatu reguły formatowania warunkowego. |
setBackgroundObject(color) | ConditionalFormatRuleBuilder | Ustawia kolor tła dla formatu reguły formatowania warunkowego. |
setBold(bold) | ConditionalFormatRuleBuilder | Ustawia pogrubienie tekstu na potrzeby formatu reguły formatowania warunkowego. |
setFontColor(color) | ConditionalFormatRuleBuilder | Ustawia kolor czcionki formatu reguły formatowania warunkowego. |
setFontColorObject(color) | ConditionalFormatRuleBuilder | Ustawia kolor czcionki formatu reguły formatowania warunkowego. |
setGradientMaxpoint(color) | ConditionalFormatRuleBuilder | Usuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły. |
setGradientMaxpointObject(color) | ConditionalFormatRuleBuilder | Usuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły. |
setGradientMaxpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | Ustawia pola maks. punktu gradientu w regule formatowania warunkowego. |
setGradientMaxpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | Ustawia pola maks. punktu gradientu w regule formatowania warunkowego. |
setGradientMidpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | Ustawia pola punktu środkowego gradientu w regule formatowania warunkowego. |
setGradientMidpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | Ustawia pola punktu środkowego gradientu w regule formatowania warunkowego. |
setGradientMinpoint(color) | ConditionalFormatRuleBuilder | Czyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły. |
setGradientMinpointObject(color) | ConditionalFormatRuleBuilder | Czyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły. |
setGradientMinpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | Ustawia pola punktów minimalnych gradientu w regule formatowania warunkowego. |
setGradientMinpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | Ustawia pola punktów minimalnych gradientu w regule formatowania warunkowego. |
setItalic(italic) | ConditionalFormatRuleBuilder | Ustawia kursywę tekstu dla formatu reguły formatowania warunkowego. |
setRanges(ranges) | ConditionalFormatRuleBuilder | Ustawia co najmniej jeden zakres, do którego stosowana jest ta reguła formatowania warunkowego. |
setStrikethrough(strikethrough) | ConditionalFormatRuleBuilder | Ustawia przekreślenie tekstu dla formatu reguły formatowania warunkowego. |
setUnderline(underline) | ConditionalFormatRuleBuilder | Ustawia podkreślenie tekstu dla formatu reguły formatowania warunkowego. |
whenCellEmpty() | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka jest pusta. |
whenCellNotEmpty() | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka nie jest pusta. |
whenDateAfter(date) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po podanej wartości. |
whenDateAfter(date) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po określonej dacie względnej. |
whenDateBefore(date) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed tą datą. |
whenDateBefore(date) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed określoną datą względną. |
whenDateEqualTo(date) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data jest równa tej dacie. |
whenDateEqualTo(date) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest uruchamiana, gdy data jest równa podanej dacie względnej. |
whenFormulaSatisfied(formula) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dana formuła zwróci wartość true . |
whenNumberBetween(start, end) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba mieści się między 2 określonymi wartościami lub jest jedną z tych wartości. |
whenNumberEqualTo(number) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest równa podanej wartości. |
whenNumberGreaterThan(number) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa od podanej wartości. |
whenNumberGreaterThanOrEqualTo(number) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa lub równa danej wartości. |
whenNumberLessThan(number) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która uruchamia się, gdy liczba jest mniejsza od podanej wartości. |
whenNumberLessThanOrEqualTo(number) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest mniejsza lub równa podanej wartości. |
whenNumberNotBetween(start, end) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba nie znajduje się między 2 określonymi wartościami i nie jest żadnej z nich. |
whenNumberNotEqualTo(number) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która uruchamia się, gdy liczba nie jest równa podanej wartości. |
whenTextContains(text) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe zawierają określoną wartość. |
whenTextDoesNotContain(text) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe nie zawierają określonej wartości. |
whenTextEndsWith(text) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe będą się kończyć określoną wartością. |
whenTextEqualTo(text) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe będą równe podanej wartości. |
whenTextStartsWith(text) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe zaczynają się od określonej wartości. |
withCriteria(criteria, args) | ConditionalFormatRuleBuilder | Ustawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości BooleanCriteria , zwykle pobierane z criteria i arguments istniejącej reguły. |
Szczegółowa dokumentacja
build()
Konstruuje regułę formatowania warunkowego na podstawie ustawień zastosowanych do kreatora.
Powroty
ConditionalFormatRule
– reprezentacja reguły formatowania warunkowego,
copy()
Zwraca gotowe ustawienia konstruktora reguł z ustawieniami tej reguły.
Powroty
ConditionalFormatRuleBuilder
– kreator oparty na ustawieniach tej reguły,
getBooleanCondition()
Pobiera informacje o BooleanCondition
reguły, jeśli ta reguła używa logicznych kryteriów warunku. W przeciwnym razie zwraca wartość 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()); }
Powroty
BooleanCondition
– obiekt warunku logicznego, lub null
, jeśli reguła nie używa warunku logicznego.
getGradientCondition()
Pobiera informacje o GradientCondition
reguły, jeśli ta reguła używa kryteriów warunku gradientu. W przeciwnym razie zwraca wartość 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()); }
Powroty
GradientCondition
– obiekt warunku gradientu lub null
, jeśli reguła nie używa warunku gradientu.
getRanges()
Pobiera zakresy, do których zastosowano tę regułę formatowania warunkowego.
// 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()); }
Powroty
Range[]
– zakresy, do których stosowana jest reguła formatowania warunkowego;
setBackground(color)
Ustawia kolor tła dla formatu reguły formatowania warunkowego. Przekazywanie wartości null
usuwa z reguły ustawienie formatu koloru tła.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Wybrany kolor lub null do wyczyszczenia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setBackgroundObject(color)
Ustawia kolor tła dla formatu reguły formatowania warunkowego. Przekazywanie wartości null
usuwa z reguły ustawienie formatu koloru tła.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Obiekt koloru lub element null do usunięcia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setBold(bold)
Ustawia pogrubienie tekstu na potrzeby formatu reguły formatowania warunkowego. Jeśli bold
ma wartość true
, reguła pogrubi tekst, jeśli warunek zostanie spełniony, a jeśli zostanie spełniony warunek false
, reguła usunie wszelkie dotychczasowe pogrubienie, jeśli zostanie spełniony. Przekazywanie wartości null
powoduje usunięcie z reguły ustawienia pogrubionego formatu.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
bold | Boolean | Określa, czy tekst ma być pogrubiony w przypadku spełnienia warunku formatu. null usuwa to ustawienie. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setFontColor(color)
Ustawia kolor czcionki formatu reguły formatowania warunkowego. Przekazanie parametru null
usuwa z reguły ustawienie formatu koloru czcionki.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Wybrany kolor lub null do wyczyszczenia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setFontColorObject(color)
Ustawia kolor czcionki formatu reguły formatowania warunkowego. Przekazanie parametru null
usuwa z reguły ustawienie formatu koloru czcionki.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Obiekt koloru lub element null do usunięcia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setGradientMaxpoint(color)
Usuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły. Ustawia też maksymalny kolor gradientu na kolor wejściowy.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Kolor wartości maksymalnej do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setGradientMaxpointObject(color)
Usuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły. Ustawia też maksymalny kolor gradientu na kolor wejściowy.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Obiekt koloru maxpoint do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setGradientMaxpointObjectWithValue(color, type, value)
Ustawia pola maks. punktu gradientu w regule formatowania warunkowego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Kolor wartości maksymalnej do ustawienia. |
type | InterpolationType | Ustawiona wartość interpolacji maksymalnej. |
value | String | Maksymalna wartość do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setGradientMaxpointWithValue(color, type, value)
Ustawia pola maks. punktu gradientu w regule formatowania warunkowego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Kolor wartości maksymalnej do ustawienia. |
type | InterpolationType | Ustawiona wartość interpolacji maksymalnej. |
value | String | Maksymalna wartość do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setGradientMidpointObjectWithValue(color, type, value)
Ustawia pola punktu środkowego gradientu w regule formatowania warunkowego. Jeśli przekazano w ramach interpolacji null
, czyści wszystkie pola punktu środkowego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Kolor punktu środkowego do ustawienia. |
type | InterpolationType | Typ interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia. |
value | String | Połowa do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setGradientMidpointWithValue(color, type, value)
Ustawia pola punktu środkowego gradientu w regule formatowania warunkowego. Jeśli przekazano w ramach interpolacji null
, czyści wszystkie pola punktu środkowego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Kolor punktu środkowego do ustawienia. |
type | InterpolationType | Typ interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia. |
value | String | Połowa do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setGradientMinpoint(color)
Czyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły. Ustawia też kolor punktu minimalnego gradientu na kolor wejściowy.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Kolor punktu minimalnego do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setGradientMinpointObject(color)
Czyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły. Ustawia też kolor punktu minimalnego gradientu na kolor wejściowy.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Obiekt koloru punktu minimalnego do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setGradientMinpointObjectWithValue(color, type, value)
Ustawia pola punktów minimalnych gradientu w regule formatowania warunkowego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | Color | Kolor punktu minimalnego do ustawienia. |
type | InterpolationType | Typ interpolacji punktu minimalnego, który ma zostać ustawiony. |
value | String | Minimalna wartość do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator służący do tworzenia łańcuchów.
setGradientMinpointWithValue(color, type, value)
Ustawia pola punktów minimalnych gradientu w regule formatowania warunkowego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
color | String | Kolor punktu minimalnego do ustawienia. |
type | InterpolationType | Typ interpolacji punktu minimalnego, który ma zostać ustawiony. |
value | String | Minimalna wartość do ustawienia. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setItalic(italic)
Ustawia kursywę tekstu dla formatu reguły formatowania warunkowego. Jeśli italic
ma wartość true
, w przypadku spełnienia warunku reguła wyróżni tekst kursywą. Jeśli warunek zostanie spełniony, reguła spowoduje usunięcie kursywy, jeśli zostanie spełniony warunek false
. Przekazanie wartości null
powoduje usunięcie z reguły ustawienia formatu kursywy.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
italic | Boolean | Określa, czy tekst ma być pisany kursywą w przypadku spełnienia warunku formatu.
null usuwa to ustawienie. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setRanges(ranges)
Ustawia co najmniej jeden zakres, do którego stosowana jest ta reguła formatowania warunkowego. Ta operacja zastępuje wszystkie istniejące zakresy. Ustawienie pustej tablicy powoduje wyczyszczenie wszystkich istniejących zakresów. Reguła musi mieć co najmniej jeden zakres.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
ranges | Range[] | Zakresy, do których stosowana jest ta reguła formatowania warunkowego. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setStrikethrough(strikethrough)
Ustawia przekreślenie tekstu dla formatu reguły formatowania warunkowego. Jeśli strikethrough
ma wartość true
, reguła przekreśla tekst, jeśli zostanie spełniony warunek. Jeśli zostanie spełniony warunek false
, reguła usunie istniejące przekreślenie, jeśli zostanie spełniony warunek. Przekazywanie wartości null
powoduje usunięcie z reguły ustawienia formatu przekreślonego.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
strikethrough | Boolean | Określa, czy tekst ma być przekreślony w przypadku spełnienia warunku formatu. null usuwa to ustawienie. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
setUnderline(underline)
Ustawia podkreślenie tekstu dla formatu reguły formatowania warunkowego. Jeśli underline
ma wartość true
, w przypadku spełnienia warunku reguła podkreśla tekst, a jeśli false
jest spełniony, reguła usuwa wszelkie istniejące podkreślenia, o ile jest spełniony. Przekazanie parametru null
usuwa z reguły ustawienie formatu podkreślenia.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
underline | Boolean | Określa, czy tekst ma być podkreślony w przypadku spełnienia warunku formatu. null usuwa to ustawienie. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenCellEmpty()
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka jest pusta.
// 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);
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenCellNotEmpty()
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka nie jest pusta.
// 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);
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenDateAfter(date)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
date | Date | Najnowsza data. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenDateAfter(date)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po określonej dacie względnej.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
date | RelativeDate | Najnowsza data w odniesieniu do wybranego typu daty. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenDateBefore(date)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed tą datą.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
date | Date | Najwcześniejsza niedopuszczalna data. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenDateBefore(date)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed określoną datą względną.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
date | RelativeDate | Najnowsza data w odniesieniu do wybranego typu daty. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenDateEqualTo(date)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data jest równa tej dacie.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
date | Date | Jedyna akceptowalna data. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenDateEqualTo(date)
Ustawia regułę formatowania warunkowego, która jest uruchamiana, gdy data jest równa podanej dacie względnej.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
date | RelativeDate | Najnowsza data w odniesieniu do wybranego typu daty. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenFormulaSatisfied(formula)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dana formuła zwróci wartość 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
formula | String | Formuła niestandardowa, która zwraca wartość true , jeśli dane wejściowe są prawidłowe. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberBetween(start, end)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba mieści się między 2 określonymi wartościami lub jest jedną z tych wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
start | Number | Najniższa akceptowalna wartość. |
end | Number | Najwyższa akceptowana wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberEqualTo(number)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest równa podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
number | Number | Jedyna akceptowalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberGreaterThan(number)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa od podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
number | Number | Najwyższa nieakceptowalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberGreaterThanOrEqualTo(number)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa lub równa danej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
number | Number | Najniższa akceptowalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberLessThan(number)
Ustawia regułę formatowania warunkowego, która uruchamia się, gdy liczba jest mniejsza od podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
number | Number | Najniższa niedopuszczalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberLessThanOrEqualTo(number)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest mniejsza lub równa podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
number | Number | Najwyższa akceptowana wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberNotBetween(start, end)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba nie znajduje się między 2 określonymi wartościami i nie jest żadnej z nich.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
start | Number | Najniższa niedopuszczalna wartość. |
end | Number | Najwyższa nieakceptowalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenNumberNotEqualTo(number)
Ustawia regułę formatowania warunkowego, która uruchamia się, gdy liczba nie jest równa podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
number | Number | Jedyna niedopuszczalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenTextContains(text)
Ustawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe zawierają określoną wartość.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
text | String | Wartość, którą muszą zawierać dane wejściowe. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenTextDoesNotContain(text)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe nie zawierają określonej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
text | String | Wartość, której nie mogą zawierać dane wejściowe. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenTextEndsWith(text)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe będą się kończyć określoną wartością.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
text | String | Tekst do porównania z końcem ciągu. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenTextEqualTo(text)
Ustawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe będą równe podanej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
text | String | Jedyna akceptowalna wartość. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
whenTextStartsWith(text)
Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe zaczynają się od określonej wartości.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
text | String | Tekst do porównania z początkiem ciągu. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.
withCriteria(criteria, args)
Ustawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości BooleanCriteria
, zwykle pobierane z criteria
i arguments
istniejącej reguły.
// 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);
Parametry
Nazwa | Typ | Opis |
---|---|---|
criteria | BooleanCriteria | Typ kryteriów formatowania warunkowego. |
args | Object[] | Tablica argumentów odpowiednich do typu kryteriów; liczba argumentów i ich typ są zgodne z odpowiednią metodą when...() powyżej. |
Powroty
ConditionalFormatRuleBuilder
– kreator tworzenia łańcuchów.