Class ConditionalFormatRuleBuilder

Kreatorregułformatowaniawarunkowego

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

MetodaZwracany typKrótki opis
build()ConditionalFormatRuleTworzy regułę formatowania warunkowego na podstawie ustawień zastosowanych w kreatorze.
copy()ConditionalFormatRuleBuilderZwraca gotowe ustawienia narzędzia do tworzenia reguł z ustawieniami tej reguły.
getBooleanCondition()BooleanConditionPobiera informacje o BooleanCondition reguły, jeśli używa ona kryteriów warunku logicznego.
getGradientCondition()GradientConditionPobiera informacje GradientCondition o regule, jeśli używa ona kryteriów warunku gradientu.
getRanges()Range[]Pobiera zakresy, do których ma zastosowanie ta reguła formatowania warunkowego.
setBackground(color)ConditionalFormatRuleBuilderUstawia kolor tła formatu reguły formatowania warunkowego.
setBackgroundObject(color)ConditionalFormatRuleBuilderUstawia kolor tła formatu reguły formatowania warunkowego.
setBold(bold)ConditionalFormatRuleBuilderUstawia pogrubienie tekstu w formacie reguły formatowania warunkowego.
setFontColor(color)ConditionalFormatRuleBuilderUstawia kolor czcionki formatu reguły formatowania warunkowego.
setFontColorObject(color)ConditionalFormatRuleBuilderUstawia kolor czcionki formatu reguły formatowania warunkowego.
setGradientMaxpoint(color)ConditionalFormatRuleBuilderUsuwa maksymalną wartość punktu gradientu reguły formatowania warunkowego i zamiast niej używa maksymalnej wartości w zakresach reguły.
setGradientMaxpointObject(color)ConditionalFormatRuleBuilderUsuwa maksymalną wartość punktu gradientu reguły formatowania warunkowego i zamiast niej używa maksymalnej wartości w zakresach reguły.
setGradientMaxpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola maksymalnego punktu gradientu reguły formatowania warunkowego.
setGradientMaxpointWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola maksymalnego punktu gradientu reguły formatowania warunkowego.
setGradientMidpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola punktu środkowego gradientu reguły formatowania warunkowego.
setGradientMidpointWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola punktu środkowego gradientu reguły formatowania warunkowego.
setGradientMinpoint(color)ConditionalFormatRuleBuilderUsuwa wartość punktu minimalnego gradientu reguły formatowania warunkowego i zamiast niej używa minimalnej wartości z zakresów reguły.
setGradientMinpointObject(color)ConditionalFormatRuleBuilderUsuwa wartość punktu minimalnego gradientu reguły formatowania warunkowego i zamiast niej używa minimalnej wartości z zakresów reguły.
setGradientMinpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola minimalnego punktu gradientu reguły formatowania warunkowego.
setGradientMinpointWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola minimalnego punktu gradientu reguły formatowania warunkowego.
setItalic(italic)ConditionalFormatRuleBuilderUstawia kursywę tekstu w formacie reguły formatowania warunkowego.
setRanges(ranges)ConditionalFormatRuleBuilderUstawia co najmniej 1 zakres, do którego ma zastosowanie ta reguła formatowania warunkowego.
setStrikethrough(strikethrough)ConditionalFormatRuleBuilderUstawia przekreślenie tekstu w formacie reguły formatowania warunkowego.
setUnderline(underline)ConditionalFormatRuleBuilderUstawia podkreślenie tekstu w formacie reguły formatowania warunkowego.
whenCellEmpty()ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma się uruchamiać, gdy komórka jest pusta.
whenCellNotEmpty()ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka nie jest pusta.
whenDateAfter(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego tak, aby była wywoływana, gdy data jest późniejsza niż podana wartość.
whenDateAfter(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest późniejsza niż podana data względna.
whenDateBefore(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest wcześniejsza niż podana data.
whenDateBefore(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy data jest wcześniejsza niż podana data względna.
whenDateEqualTo(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być uruchamiana, gdy data jest równa podanej dacie.
whenDateEqualTo(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być uruchamiana, gdy data jest równa podanej dacie względnej.
whenFormulaSatisfied(formula)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego tak, aby była wywoływana, gdy podana formuła zwróci wartość true.
whenNumberBetween(start, end)ConditionalFormatRuleBuilderUstawia 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.
whenNumberEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba jest równa podanej wartości.
whenNumberGreaterThan(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba jest większa od podanej wartości.
whenNumberGreaterThanOrEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wywoływana, gdy liczba jest większa lub równa podanej wartości.
whenNumberLessThan(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma się uruchamiać, gdy liczba jest mniejsza od podanej wartości.
whenNumberLessThanOrEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba jest mniejsza lub równa podanej wartości.
whenNumberNotBetween(start, end)ConditionalFormatRuleBuilderUstawia 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.
whenNumberNotEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest aktywowana, gdy liczba nie jest równa podanej wartości.
whenTextContains(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe zawierają podaną wartość.
whenTextDoesNotContain(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe nie zawierają podanej wartości.
whenTextEndsWith(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe kończą się podaną wartością.
whenTextEqualTo(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe są równe podanej wartości.
whenTextStartsWith(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która ma być wywoływana, gdy dane wejściowe zaczynają się od podanej wartości.
withCriteria(criteria, args)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości BooleanCriteria, zwykle pobierane z elementów criteriaarguments istniejącej reguły.

Szczegółowa dokumentacja

build()

Tworzy regułę formatowania warunkowego na podstawie ustawień zastosowanych w kreatorze.

Powrót

ConditionalFormatRule – reprezentacja reguły formatowania warunkowego.


copy()

Zwraca gotowe ustawienia narzędzia do tworzenia reguł z ustawieniami tej reguły.

Powrót

ConditionalFormatRuleBuilder – narzędzie do tworzenia na podstawie ustawień tej reguły.


getBooleanCondition()

Pobiera informacje o BooleanCondition 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

BooleanCondition – obiekt warunku logicznego lub null, jeśli reguła nie używa warunku logicznego.


getGradientCondition()

Pobiera informacje GradientCondition 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

GradientCondition – obiekt warunku gradientu lub null, jeśli reguła nie używa warunku gradientu.


getRanges()

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.


setBackground(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

NazwaTypOpis
colorStringwybrany kolor lub null, aby wyczyścić.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setBackgroundObject(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

NazwaTypOpis
colorColorobiekt z wybranym kolorem lub null, aby wyczyścić.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setBold(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

NazwaTypOpis
boldBooleanOkreśla, czy tekst ma być pogrubiony, jeśli warunek formatowania jest spełniony. null usuwa to ustawienie.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setFontColor(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

NazwaTypOpis
colorStringwybrany kolor lub null, aby wyczyścić.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setFontColorObject(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

NazwaTypOpis
colorColorobiekt z wybranym kolorem lub null, aby wyczyścić.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMaxpoint(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

NazwaTypOpis
colorStringKolor wartości maksymalnej do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMaxpointObject(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

NazwaTypOpis
colorColorObiekt koloru maksymalnej wartości do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMaxpointObjectWithValue(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

NazwaTypOpis
colorColorKolor wartości maksymalnej do ustawienia.
typeInterpolationTypeTyp interpolacji maxpoint do ustawienia.
valueStringWartość maksymalna do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMaxpointWithValue(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

NazwaTypOpis
colorStringKolor wartości maksymalnej do ustawienia.
typeInterpolationTypeTyp interpolacji maxpoint do ustawienia.
valueStringWartość maksymalna do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMidpointObjectWithValue(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

NazwaTypOpis
colorColorKolor punktu środkowego do ustawienia.
typeInterpolationTypeTyp interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia.
valueStringWartość punktu środkowego do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMidpointWithValue(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

NazwaTypOpis
colorStringKolor punktu środkowego do ustawienia.
typeInterpolationTypeTyp interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia.
valueStringWartość punktu środkowego do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMinpoint(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

NazwaTypOpis
colorStringKolor wartości minimalnej do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMinpointObject(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

NazwaTypOpis
colorColorObiekt koloru minimalnej wartości do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMinpointObjectWithValue(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

NazwaTypOpis
colorColorKolor wartości minimalnej do ustawienia.
typeInterpolationTypeTyp interpolacji minpoint do ustawienia.
valueStringWartość minimalna do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setGradientMinpointWithValue(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

NazwaTypOpis
colorStringKolor wartości minimalnej do ustawienia.
typeInterpolationTypeTyp interpolacji minpoint do ustawienia.
valueStringWartość minimalna do ustawienia.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setItalic(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

NazwaTypOpis
italicBooleanOkreśla, czy tekst ma być pisany kursywą, jeśli warunek formatowania jest spełniony.null usuwa to ustawienie.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setRanges(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

NazwaTypOpis
rangesRange[]Zakresy, do których ma zastosowanie ta reguła formatowania warunkowego.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setStrikethrough(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

NazwaTypOpis
strikethroughBooleanOkreśla, czy tekst ma być przekreślony, jeśli warunek formatowania jest spełniony. null usuwa to ustawienie.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


setUnderline(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

NazwaTypOpis
underlineBooleanczy tekst ma być podkreślony, jeśli warunek formatowania jest spełniony;null usuwa to ustawienie.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenCellEmpty()

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

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


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. 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

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenDateAfter(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

NazwaTypOpis
dateDateNajnowsza data.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenDateAfter(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

NazwaTypOpis
dateRelativeDateNajnowsza data w stosunku do wybranego typu daty.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenDateBefore(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

NazwaTypOpis
dateDateNajwcześniejsza niedopuszczalna data.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenDateBefore(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

NazwaTypOpis
dateRelativeDateNajnowsza data w stosunku do wybranego typu daty.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenDateEqualTo(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

NazwaTypOpis
dateDateJedyna akceptowana data.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenDateEqualTo(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

NazwaTypOpis
dateRelativeDateNajnowsza data w stosunku do wybranego typu daty.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenFormulaSatisfied(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

NazwaTypOpis
formulaStringFormuła niestandardowa, która zwraca wartość true, jeśli dane wejściowe są prawidłowe.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberBetween(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

NazwaTypOpis
startNumberNajniższa akceptowalna wartość.
endNumberNajwyższa dopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberEqualTo(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

NazwaTypOpis
numberNumberJedyna dopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberGreaterThan(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

NazwaTypOpis
numberNumberNajwyższa niedopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberGreaterThanOrEqualTo(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

NazwaTypOpis
numberNumberNajniższa akceptowalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberLessThan(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

NazwaTypOpis
numberNumberNajniższa niedopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberLessThanOrEqualTo(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

NazwaTypOpis
numberNumberNajwyższa dopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberNotBetween(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

NazwaTypOpis
startNumberNajniższa niedopuszczalna wartość.
endNumberNajwyższa niedopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenNumberNotEqualTo(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

NazwaTypOpis
numberNumberJedyna niedopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenTextContains(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

NazwaTypOpis
textStringWartość, którą musi zawierać dane wejściowe.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenTextDoesNotContain(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

NazwaTypOpis
textStringWartość, której nie może zawierać dane wejściowe.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenTextEndsWith(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

NazwaTypOpis
textStringTekst do porównania z końcem ciągu.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenTextEqualTo(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

NazwaTypOpis
textStringJedyna dopuszczalna wartość.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


whenTextStartsWith(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

NazwaTypOpis
textStringTekst do porównania z początkiem ciągu.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.


withCriteria(criteria, args)

Ustawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości BooleanCriteria, zwykle pobierane z elementów criteriaarguments 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

NazwaTypOpis
criteriaBooleanCriteriaTyp kryteriów formatowania warunkowego.
argsObject[]Tablica argumentów odpowiednich dla typu kryteriów. Liczba argumentów i ich typ są zgodne z odpowiednią metodą when...() powyżej.

Powrót

ConditionalFormatRuleBuilder – konstruktor do łączenia w łańcuch.