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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Metody
| Metoda | Zwracany typ | Krótki opis |
|---|---|---|
build() | Conditional | Tworzy regułę formatowania warunkowego na podstawie ustawień zastosowanych w kreatorze. |
copy() | Conditional | Zwraca gotowe ustawienia narzędzia do tworzenia reguł z ustawieniami tej reguły. |
get | Boolean | Pobiera informacje o Boolean reguły, jeśli używa ona kryteriów warunku logicznego. |
get | Gradient | Pobiera informacje Gradient o regule, jeśli używa ona kryteriów warunku gradientu. |
get | Range[] | Pobiera zakresy, do których ma zastosowanie ta reguła formatowania warunkowego. |
set | Conditional | Ustawia kolor tła formatu reguły formatowania warunkowego. |
set | Conditional | Ustawia kolor tła formatu reguły formatowania warunkowego. |
set | Conditional | Ustawia pogrubienie tekstu w formacie reguły formatowania warunkowego. |
set | Conditional | Ustawia kolor czcionki formatu reguły formatowania warunkowego. |
set | Conditional | Ustawia kolor czcionki formatu reguły formatowania warunkowego. |
set | Conditional | Usuwa maksymalną wartość punktu gradientu reguły formatowania warunkowego i zamiast niej używa maksymalnej wartości w zakresach reguły. |
set | Conditional | Usuwa maksymalną wartość punktu gradientu reguły formatowania warunkowego i zamiast niej używa maksymalnej wartości w zakresach reguły. |
set | Conditional | Ustawia pola maksymalnego punktu gradientu reguły formatowania warunkowego. |
set | Conditional | Ustawia pola maksymalnego punktu gradientu reguły formatowania warunkowego. |
set | Conditional | Ustawia pola punktu środkowego gradientu reguły formatowania warunkowego. |
set | Conditional | Ustawia pola punktu środkowego gradientu reguły formatowania warunkowego. |
set | Conditional | Usuwa wartość punktu minimalnego gradientu reguły formatowania warunkowego i zamiast niej używa minimalnej wartości z zakresów reguły. |
set | Conditional | Usuwa wartość punktu minimalnego gradientu reguły formatowania warunkowego i zamiast niej używa minimalnej wartości z zakresów reguły. |
set | Conditional | Ustawia pola minimalnego punktu gradientu reguły formatowania warunkowego. |
set | Conditional | Ustawia pola minimalnego punktu gradientu reguły formatowania warunkowego. |
set | Conditional | Ustawia kursywę tekstu w formacie reguły formatowania warunkowego. |
set | Conditional | Ustawia co najmniej 1 zakres, do którego ma zastosowanie ta reguła formatowania warunkowego. |
set | Conditional | Ustawia przekreślenie tekstu w formacie reguły formatowania warunkowego. |
set | Conditional | Ustawia podkreślenie tekstu w formacie reguły formatowania warunkowego. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma się uruchamiać, gdy komórka jest pusta. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka nie jest pusta. |
when | Conditional | Ustawia regułę formatowania warunkowego tak, aby była wywoływana, gdy data jest późniejsza niż podana wartość. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest późniejsza niż podana data względna. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest wcześniejsza niż podana data. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest wcześniejsza niż podana data względna. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być uruchamiana, gdy data jest równa podanej dacie. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być uruchamiana, gdy data jest równa podanej dacie względnej. |
when | Conditional | Ustawia regułę formatowania warunkowego tak, aby była wywoływana, gdy podana formuła zwróci wartość true. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba mieści się w przedziale między dwiema określonymi wartościami lub jest równa jednej z nich. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba jest równa podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba jest większa od podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest wywoływana, gdy liczba jest większa lub równa podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma się uruchamiać, gdy liczba jest mniejsza od podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba jest mniejsza lub równa podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba nie mieści się w przedziale między dwiema określonymi wartościami i nie jest żadną z nich. |
when | Conditional | Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba nie jest równa podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe zawierają podaną wartość. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe nie zawierają podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe kończą się podaną wartością. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe są równe podanej wartości. |
when | Conditional | Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe zaczynają się od podanej wartości. |
with | Conditional | Ustawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości Boolean, zwykle pobierane z elementów criteria i arguments istniejącej reguły. |
Szczegółowa dokumentacja
build()
Tworzy regułę formatowania warunkowego na podstawie ustawień zastosowanych w kreatorze.
Powrót
Conditional – reprezentacja reguły formatowania warunkowego.
copy()
Zwraca gotowe ustawienia narzędzia do tworzenia reguł z ustawieniami tej reguły.
Powrót
Conditional – narzędzie do tworzenia na podstawie ustawień tej reguły.
get Boolean Condition()
Pobiera informacje o Boolean reguły, jeśli używa ona kryteriów warunku logicznego. W przeciwnym razie zwraca wartość null.
// Log the boolean criteria type of the first conditional format rules of a // sheet. const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; const booleanCondition = rule.getBooleanCondition(); if (booleanCondition != null) { Logger.log(booleanCondition.getCriteriaType()); }
Powrót
Boolean – obiekt warunku logicznego lub null, jeśli reguła nie używa warunku logicznego.
get Gradient Condition()
Pobiera informacje Gradient o regule, jeśli używa ona kryteriów warunku gradientu. W przeciwnym razie zwraca wartość null.
// Log the gradient minimum color of the first conditional format rule of a // sheet. const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; const gradientCondition = rule.getGradientCondition(); if (gradientCondition != null) { // Assume the color has ColorType.RGB. Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString()); }
Powrót
Gradient – obiekt warunku gradientu lub null, jeśli reguła nie używa warunku gradientu.
get Ranges()
Pobiera zakresy, do których ma zastosowanie ta reguła formatowania warunkowego.
// Log each range of the first conditional format rule of a sheet. const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; const ranges = rule.getRanges(); for (let i = 0; i < ranges.length; i++) { Logger.log(ranges[i].getA1Notation()); }
Powrót
Range[] – zakresy, do których stosowana jest ta reguła formatowania warunkowego.
set Background(color)
Ustawia kolor tła formatu reguły formatowania warunkowego. Przekazanie 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | wybrany kolor lub null, aby wyczyścić. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Background Object(color)
Ustawia kolor tła formatu reguły formatowania warunkowego. Przekazanie 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setBackground(color) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | obiekt z wybranym kolorem lub null, aby wyczyścić. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Bold(bold)
Ustawia pogrubienie tekstu w formacie reguły formatowania warunkowego. Jeśli bold ma wartość true, reguła pogrubia tekst, jeśli warunek jest spełniony. Jeśli false, reguła usuwa istniejące pogrubienie, jeśli warunek jest spełniony. Przekazanie wartości null usuwa z reguły ustawienie formatu pogrubionego.
// 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setBold(true) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
bold | Boolean | Określa, czy tekst ma być pogrubiony, jeśli warunek formatowania jest spełniony. null usuwa to ustawienie. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Font Color(color)
Ustawia kolor czcionki formatu reguły formatowania warunkowego. Przekazanie wartości 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setFontColor('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | wybrany kolor lub null, aby wyczyścić. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Font Color Object(color)
Ustawia kolor czcionki formatu reguły formatowania warunkowego. Przekazanie wartości 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setFontColor(color) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | obiekt z wybranym kolorem lub null, aby wyczyścić. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Maxpoint(color)
Usuwa maksymalną wartość punktu gradientu reguły formatowania warunkowego i zamiast niej używa maksymalnej wartości w zakresach reguły. Ustawia też kolor maksymalnej wartości 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint('#FF0000') .setGradientMinpoint('#FFFFFF') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | Kolor wartości maksymalnej do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Maxpoint Object(color)
Usuwa maksymalną wartość punktu gradientu reguły formatowania warunkowego i zamiast niej używa maksymalnej wartości w zakresach reguły. Ustawia też kolor maksymalnej wartości 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const textColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); const backgroundColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint(textColor) .setGradientMinpoint(backgroundColor) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | Obiekt koloru maksymalnej wartości do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Maxpoint Object With Value(color, type, value)
Ustawia pola maksymalnego punktu gradientu reguły 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue( color1, SpreadsheetApp.InterpolationType.NUMBER, '100', ) .setGradientMidpointWithValue( color2, SpreadsheetApp.InterpolationType.NUMBER, '50', ) .setGradientMinpointWithValue( color3, SpreadsheetApp.InterpolationType.NUMBER, '0', ) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | Kolor wartości maksymalnej do ustawienia. |
type | Interpolation | Typ interpolacji maxpoint do ustawienia. |
value | String | Wartość maksymalna do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Maxpoint With Value(color, type, value)
Ustawia pola maksymalnego punktu gradientu reguły 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue( '#0000FF', SpreadsheetApp.InterpolationType.NUMBER, '100', ) .setGradientMidpointWithValue( '#00FF00', SpreadsheetApp.InterpolationType.NUMBER, '50', ) .setGradientMinpointWithValue( '#FF0000', SpreadsheetApp.InterpolationType.NUMBER, '0', ) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | Kolor wartości maksymalnej do ustawienia. |
type | Interpolation | Typ interpolacji maxpoint do ustawienia. |
value | String | Wartość maksymalna do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Midpoint Object With Value(color, type, value)
Ustawia pola punktu środkowego gradientu reguły formatowania warunkowego. Czyści wszystkie pola punktu środkowego, jeśli przekazany typ interpolacji to 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue( color1, SpreadsheetApp.InterpolationType.NUMBER, '100', ) .setGradientMidpointWithValue( color2, SpreadsheetApp.InterpolationType.NUMBER, '50', ) .setGradientMinpointWithValue( color3, SpreadsheetApp.InterpolationType.NUMBER, '0', ) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | Kolor punktu środkowego do ustawienia. |
type | Interpolation | Typ interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia. |
value | String | Wartość punktu środkowego do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Midpoint With Value(color, type, value)
Ustawia pola punktu środkowego gradientu reguły formatowania warunkowego. Czyści wszystkie pola punktu środkowego, jeśli przekazany typ interpolacji to 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue( '#0000FF', SpreadsheetApp.InterpolationType.NUMBER, '100', ) .setGradientMidpointWithValue( '#00FF00', SpreadsheetApp.InterpolationType.NUMBER, '50', ) .setGradientMinpointWithValue( '#FF0000', SpreadsheetApp.InterpolationType.NUMBER, '0', ) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | Kolor punktu środkowego do ustawienia. |
type | Interpolation | Typ interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia. |
value | String | Wartość punktu środkowego do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Minpoint(color)
Usuwa wartość punktu minimalnego gradientu reguły formatowania warunkowego i zamiast niej używa minimalnej wartości z zakresów reguły. Ustawia też kolor minimalnej wartości 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint('#FF0000') .setGradientMinpoint('#FFFFFF') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | Kolor wartości minimalnej do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Minpoint Object(color)
Usuwa wartość punktu minimalnego gradientu reguły formatowania warunkowego i zamiast niej używa minimalnej wartości z zakresów reguły. Ustawia też kolor minimalnej wartości 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const textColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); const backgroundColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint(textColor) .setGradientMinpoint(backgroundColor) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | Obiekt koloru minimalnej wartości do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Minpoint Object With Value(color, type, value)
Ustawia pola minimalnego punktu gradientu reguły 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue( color1, SpreadsheetApp.InterpolationType.NUMBER, '100', ) .setGradientMidpointWithValue( color2, SpreadsheetApp.InterpolationType.NUMBER, '50', ) .setGradientMinpointWithValue( color3, SpreadsheetApp.InterpolationType.NUMBER, '0', ) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | Color | Kolor wartości minimalnej do ustawienia. |
type | Interpolation | Typ interpolacji minpoint do ustawienia. |
value | String | Wartość minimalna do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Gradient Minpoint With Value(color, type, value)
Ustawia pola minimalnego punktu gradientu reguły 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue( '#0000FF', SpreadsheetApp.InterpolationType.NUMBER, '100', ) .setGradientMidpointWithValue( '#00FF00', SpreadsheetApp.InterpolationType.NUMBER, '50', ) .setGradientMinpointWithValue( '#FF0000', SpreadsheetApp.InterpolationType.NUMBER, '0', ) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
color | String | Kolor wartości minimalnej do ustawienia. |
type | Interpolation | Typ interpolacji minpoint do ustawienia. |
value | String | Wartość minimalna do ustawienia. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Italic(italic)
Ustawia kursywę tekstu w formacie reguły formatowania warunkowego. Jeśli italic ma wartość true, reguła zapisuje tekst kursywą, jeśli warunek jest spełniony. Jeśli false, reguła usuwa istniejącą kursywę, jeśli warunek jest spełniony. Przekazanie wartości null usuwa z reguły ustawienie 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setItalic(true) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
italic | Boolean | Określa, czy tekst ma być pisany kursywą, jeśli warunek formatowania jest spełniony.null usuwa to ustawienie. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Ranges(ranges)
Ustawia co najmniej 1 zakres, do którego ma zastosowanie ta reguła formatowania warunkowego. Ta operacja zastępuje wszystkie istniejące zakresy. Ustawienie pustej tablicy spowoduje wyczyszczenie wszystkich istniejących zakresów. Reguła musi zawierać co najmniej 1 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. const sheet = SpreadsheetApp.getActiveSheet(); const rangeOne = sheet.getRange('A1:B3'); const rangeTwo = sheet.getRange('D4:F6'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground('#FF0000') .setRanges([rangeOne, rangeTwo]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
ranges | Range[] | Zakresy, do których ma zastosowanie ta reguła formatowania warunkowego. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Strikethrough(strikethrough)
Ustawia przekreślenie tekstu w formacie reguły formatowania warunkowego. Jeśli strikethrough jest równe true, reguła przekreśla tekst, jeśli warunek jest spełniony. Jeśli false, reguła usuwa istniejące formatowanie przekreślenia, jeśli warunek jest spełniony. Przekazanie wartości null
usuwa z reguły ustawienie formatu przekreślenia.
// 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setStrikethrough(true) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
strikethrough | Boolean | Określa, czy tekst ma być przekreślony, jeśli warunek formatowania jest spełniony. null usuwa to ustawienie. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
set Underline(underline)
Ustawia podkreślenie tekstu w formacie reguły formatowania warunkowego. Jeśli underline ma wartość true, reguła podkreśla tekst, jeśli warunek jest spełniony. Jeśli false, reguła usuwa wszystkie istniejące podkreślenia, jeśli warunek jest spełniony. Przekazanie wartości null usuwa z reguły ustawienie formatowania 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setUnderline(true) .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
underline | Boolean | czy tekst ma być podkreślony, jeśli warunek formatowania jest spełniony;null usuwa to ustawienie. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Cell Empty()
Ustawia regułę formatowania warunkowego, która ma się uruchamiać, 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenCellEmpty() .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Cell Not Empty()
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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenCellNotEmpty() .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Date After(date)
Ustawia regułę formatowania warunkowego tak, aby była wywoływana, gdy data jest późniejsza niż podana wartość.
// 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenDateAfter(new Date('11/4/1993')) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
date | Date | Najnowsza data. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Date After(date)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest późniejsza niż podana data względna.
// 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
date | Relative | Najnowsza data w stosunku do wybranego typu daty. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Date Before(date)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest wcześniejsza niż podana data.
// 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenDateBefore(new Date('11/4/1993')) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
date | Date | Najwcześniejsza niedopuszczalna data. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Date Before(date)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest wcześniejsza niż podana data względna.
// 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
date | Relative | Najnowsza data w stosunku do wybranego typu daty. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Date Equal To(date)
Ustawia regułę formatowania warunkowego, która ma być uruchamiana, gdy data jest równa podanej 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenDateEqualTo(new Date('11/4/1993')) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
date | Date | Jedyna akceptowana data. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Date Equal To(date)
Ustawia regułę formatowania warunkowego, która ma być 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenDateEqualTo(SpreadsheetApp.RelativeDate.TODAY) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
date | Relative | Najnowsza data w stosunku do wybranego typu daty. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Formula Satisfied(formula)
Ustawia regułę formatowania warunkowego tak, aby była wywoływana, gdy podana 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)". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenFormulaSatisfied('=EQ(B4, C3)') .setBackground('#FF0000') .setRanges([range]) .build(); const 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. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Between(start, end)
Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba mieści się w przedziale między dwiema określonymi wartościami lub jest równa jednej 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 between 1 and 10. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
start | Number | Najniższa akceptowalna wartość. |
end | Number | Najwyższa dopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Equal To(number)
Ustawia regułę formatowania warunkowego, która jest aktywowana, 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberEqualTo(10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
number | Number | Jedyna dopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Greater Than(number)
Ustawia regułę formatowania warunkowego, która jest aktywowana, 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberGreaterThan(10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
number | Number | Najwyższa niedopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Greater Than Or Equal To(number)
Ustawia regułę formatowania warunkowego, która jest wywoływana, gdy liczba jest większa 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 greater than or equal to 10. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberGreaterThanOrEqualTo(10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
number | Number | Najniższa akceptowalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Less Than(number)
Ustawia regułę formatowania warunkowego, która ma się uruchamiać, 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberLessThan(10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
number | Number | Najniższa niedopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Less Than Or Equal To(number)
Ustawia regułę formatowania warunkowego, która jest aktywowana, 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberLessThanOrEqualTo(10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
number | Number | Najwyższa dopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Not Between(start, end)
Ustawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba nie mieści się w przedziale między dwiema określonymi wartościami i nie jest żadną 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberNotBetween(1, 10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
start | Number | Najniższa niedopuszczalna wartość. |
end | Number | Najwyższa niedopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Number Not Equal To(number)
Ustawia regułę formatowania warunkowego, która jest aktywowana, 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. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberNotEqualTo(10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
number | Number | Jedyna niedopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Text Contains(text)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe zawierają podaną 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextContains('hello') .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
text | String | Wartość, którą musi zawierać dane wejściowe. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Text Does Not Contain(text)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe nie zawierają 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 text "hello". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextDoesNotContain('hello') .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
text | String | Wartość, której nie może zawierać dane wejściowe. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Text Ends With(text)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe kończą się podaną 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEndsWith('hello') .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
text | String | Tekst do porównania z końcem ciągu. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Text Equal To(text)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe są 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo('hello') .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
text | String | Jedyna dopuszczalna wartość. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
when Text Starts With(text)
Ustawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe zaczynają się od podanej 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". const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenTextStartsWith('hello') .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
text | String | Tekst do porównania z początkiem ciągu. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.
with Criteria(criteria, args)
Ustawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości Boolean, zwykle pobierane z elementów 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. const sheet = SpreadsheetApp.getActiveSheet(); const rules = sheet.getConditionalFormatRules(); const booleanCondition = rules[0].getBooleanCondition(); if (booleanCondition != null) { const rule = SpreadsheetApp.newConditionalFormatRule() .withCriteria( booleanCondition.getCriteriaType(), booleanCondition.getCriteriaValues(), ) .setBackground('#000000') .setRanges(rules[0].getRanges()) .build(); rules.push(rule); } sheet.setConditionalFormatRules(rules);
Parametry
| Nazwa | Typ | Opis |
|---|---|---|
criteria | Boolean | Typ kryteriów formatowania warunkowego. |
args | Object[] | Tablica argumentów odpowiednich dla typu kryteriów. Liczba argumentów i ich typ są zgodne z odpowiednią metodą when...() powyżej. |
Powrót
Conditional – konstruktor do łączenia w łańcuch.