Class ConditionalFormatRuleBuilder

ConditionalFormatRuleBuilder

Kreator reguł formatowania warunkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a number between 1 and 10.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Metody

MetodaZwracany typKrótki opis
build()ConditionalFormatRuleKonstruuje regułę formatowania warunkowego na podstawie ustawień zastosowanych do kreatora.
copy()ConditionalFormatRuleBuilderZwraca gotowe ustawienia konstruktora reguł z ustawieniami tej reguły.
getBooleanCondition()BooleanConditionPobiera informacje o BooleanCondition reguły, jeśli ta reguła używa logicznych kryteriów warunku.
getGradientCondition()GradientConditionPobiera informacje o GradientCondition reguły, jeśli ta reguła używa kryteriów warunku gradientu.
getRanges()Range[]Pobiera zakresy, do których zastosowano tę regułę formatowania warunkowego.
setBackground(color)ConditionalFormatRuleBuilderUstawia kolor tła dla formatu reguły formatowania warunkowego.
setBackgroundObject(color)ConditionalFormatRuleBuilderUstawia kolor tła dla formatu reguły formatowania warunkowego.
setBold(bold)ConditionalFormatRuleBuilderUstawia pogrubienie tekstu na potrzeby formatu 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 w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły.
setGradientMaxpointObject(color)ConditionalFormatRuleBuilderUsuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły.
setGradientMaxpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola maks. punktu gradientu w regule formatowania warunkowego.
setGradientMaxpointWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola maks. punktu gradientu w regule formatowania warunkowego.
setGradientMidpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola punktu środkowego gradientu w regule formatowania warunkowego.
setGradientMidpointWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola punktu środkowego gradientu w regule formatowania warunkowego.
setGradientMinpoint(color)ConditionalFormatRuleBuilderCzyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły.
setGradientMinpointObject(color)ConditionalFormatRuleBuilderCzyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły.
setGradientMinpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola punktów minimalnych gradientu w regule formatowania warunkowego.
setGradientMinpointWithValue(color, type, value)ConditionalFormatRuleBuilderUstawia pola punktów minimalnych gradientu w regule formatowania warunkowego.
setItalic(italic)ConditionalFormatRuleBuilderUstawia kursywę tekstu dla formatu reguły formatowania warunkowego.
setRanges(ranges)ConditionalFormatRuleBuilderUstawia co najmniej jeden zakres, do którego stosowana jest ta reguła formatowania warunkowego.
setStrikethrough(strikethrough)ConditionalFormatRuleBuilderUstawia przekreślenie tekstu dla formatu reguły formatowania warunkowego.
setUnderline(underline)ConditionalFormatRuleBuilderUstawia podkreślenie tekstu dla formatu reguły formatowania warunkowego.
whenCellEmpty()ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, 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, która jest wyzwalana, gdy data przypada po podanej wartości.
whenDateAfter(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po określonej dacie względnej.
whenDateBefore(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed tą datą.
whenDateBefore(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed określoną datą względną.
whenDateEqualTo(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy data jest równa tej dacie.
whenDateEqualTo(date)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest uruchamiana, gdy data jest równa podanej dacie względnej.
whenFormulaSatisfied(formula)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy dana formuła zwróci wartość true.
whenNumberBetween(start, end)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba mieści się między 2 określonymi wartościami lub jest jedną z tych wartości.
whenNumberEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest równa podanej wartości.
whenNumberGreaterThan(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa od podanej wartości.
whenNumberGreaterThanOrEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa lub równa danej wartości.
whenNumberLessThan(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która uruchamia się, gdy liczba jest mniejsza od podanej wartości.
whenNumberLessThanOrEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest mniejsza lub równa podanej wartości.
whenNumberNotBetween(start, end)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba nie znajduje się między 2 określonymi wartościami i nie jest żadnej z nich.
whenNumberNotEqualTo(number)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która uruchamia się, gdy liczba nie jest równa podanej wartości.
whenTextContains(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe zawierają określoną wartość.
whenTextDoesNotContain(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe nie zawierają określonej wartości.
whenTextEndsWith(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe będą się kończyć określoną wartością.
whenTextEqualTo(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe będą równe podanej wartości.
whenTextStartsWith(text)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe zaczynają się od określonej wartości.
withCriteria(criteria, args)ConditionalFormatRuleBuilderUstawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości BooleanCriteria, zwykle pobierane z criteria i arguments istniejącej reguły.

Szczegółowa dokumentacja

build()

Konstruuje regułę formatowania warunkowego na podstawie ustawień zastosowanych do kreatora.

Powroty

ConditionalFormatRule – reprezentacja reguły formatowania warunkowego,


copy()

Zwraca gotowe ustawienia konstruktora reguł z ustawieniami tej reguły.

Powroty

ConditionalFormatRuleBuilder – kreator oparty na ustawieniach tej reguły,


getBooleanCondition()

Pobiera informacje o BooleanCondition reguły, jeśli ta reguła używa logicznych kryteriów warunku. W przeciwnym razie zwraca wartość null.

// Log the boolean criteria type of the first conditional format rules of a sheet.
var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
var booleanCondition = rule.getBooleanCondition();
if (booleanCondition != null) {
  Logger.log(booleanCondition.getCriteriaType());
}

Powroty

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


getGradientCondition()

Pobiera informacje o GradientCondition reguły, jeśli ta reguła używa kryteriów warunku gradientu. W przeciwnym razie zwraca wartość null.

// Log the gradient minimum color of the first conditional format rule of a sheet.
var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
var gradientCondition = rule.getGradientCondition();
if (gradientCondition != null) {
  // Assume the color has ColorType.RGB.
  Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString());
}

Powroty

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


getRanges()

Pobiera zakresy, do których zastosowano tę regułę formatowania warunkowego.

// Log each range of the first conditional format rule of a sheet.
var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
var ranges = rule.getRanges();
for (var i = 0; i < ranges.length; i++) {
  Logger.log(ranges[i].getA1Notation());
}

Powroty

Range[] – zakresy, do których stosowana jest reguła formatowania warunkowego;


setBackground(color)

Ustawia kolor tła dla formatu reguły formatowania warunkowego. Przekazywanie wartości null usuwa z reguły ustawienie formatu koloru tła.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color to red if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringWybrany kolor lub null do wyczyszczenia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setBackgroundObject(color)

Ustawia kolor tła dla formatu reguły formatowania warunkowego. Przekazywanie wartości null usuwa z reguły ustawienie formatu koloru tła.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color to theme background color if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBackground(color)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorObiekt koloru lub element null do usunięcia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setBold(bold)

Ustawia pogrubienie tekstu na potrzeby formatu reguły formatowania warunkowego. Jeśli bold ma wartość true, reguła pogrubi tekst, jeśli warunek zostanie spełniony, a jeśli zostanie spełniony warunek false, reguła usunie wszelkie dotychczasowe pogrubienie, jeśli zostanie spełniony. Przekazywanie wartości null powoduje usunięcie z reguły ustawienia pogrubionego formatu.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn their
// text bold if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBold(true)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
boldBooleanOkreśla, czy tekst ma być pogrubiony w przypadku spełnienia warunku formatu. null usuwa to ustawienie.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setFontColor(color)

Ustawia kolor czcionki formatu reguły formatowania warunkowego. Przekazanie parametru null usuwa z reguły ustawienie formatu koloru czcionki.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their font
// color to red if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setFontColor("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringWybrany kolor lub null do wyczyszczenia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setFontColorObject(color)

Ustawia kolor czcionki formatu reguły formatowania warunkowego. Przekazanie parametru null usuwa z reguły ustawienie formatu koloru czcionki.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their font
// color to theme text color if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setFontColor(color)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorObiekt koloru lub element null do usunięcia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setGradientMaxpoint(color)

Usuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły. Ustawia też maksymalny kolor gradientu na kolor wejściowy.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere between white and red, based on their values in comparison to
// the ranges minimum and maximum values.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpoint("#FF0000")
    .setGradientMinpoint("#FFFFFF")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringKolor wartości maksymalnej do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setGradientMaxpointObject(color)

Usuwa maksymalną wartość punktu gradientu w regule formatowania warunkowego, a zamiast tego używa maksymalnej wartości z zakresów reguły. Ustawia też maksymalny kolor gradientu na kolor wejściowy.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere between theme text and background colors, based on their values
// in comparison to the ranges minimum and maximum values.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var textColor = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
    .build();
var backgroundColor = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpoint(textColor)
    .setGradientMinpoint(backgroundColor)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorObiekt koloru maxpoint do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setGradientMaxpointObjectWithValue(color, type, value)

Ustawia pola maks. punktu gradientu w regule formatowania warunkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere from theme accent 1, accent 2 to accent 3 colors, based on their
// values in comparison to the values 0, 50, and 100.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color1 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
    .build();
var color2 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
    .build();
var color3 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorKolor wartości maksymalnej do ustawienia.
typeInterpolationTypeUstawiona wartość interpolacji maksymalnej.
valueStringMaksymalna wartość do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setGradientMaxpointWithValue(color, type, value)

Ustawia pola maks. punktu gradientu w regule formatowania warunkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere from red green to blue, based on their values in comparison to
// the values 0, 50, and 100.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringKolor wartości maksymalnej do ustawienia.
typeInterpolationTypeUstawiona wartość interpolacji maksymalnej.
valueStringMaksymalna wartość do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setGradientMidpointObjectWithValue(color, type, value)

Ustawia pola punktu środkowego gradientu w regule formatowania warunkowego. Jeśli przekazano w ramach interpolacji null, czyści wszystkie pola punktu środkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere from theme accent 1 to accent 2 to accent 3 colors, based on
// their values in comparison to the values 0, 50, and 100.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color1 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
    .build();
var color2 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
    .build();
var color3 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorKolor punktu środkowego do ustawienia.
typeInterpolationTypeTyp interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia.
valueStringPołowa do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setGradientMidpointWithValue(color, type, value)

Ustawia pola punktu środkowego gradientu w regule formatowania warunkowego. Jeśli przekazano w ramach interpolacji null, czyści wszystkie pola punktu środkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere from red green to blue, based on their values in comparison to
// the values 0, 50, and 100.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringKolor punktu środkowego do ustawienia.
typeInterpolationTypeTyp interpolacji punktu środkowego do ustawienia lub null do wyczyszczenia.
valueStringPołowa do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setGradientMinpoint(color)

Czyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły. Ustawia też kolor punktu minimalnego gradientu na kolor wejściowy.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere between white and red, based on their values in comparison to
// the ranges minimum and maximum values.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpoint("#FF0000")
    .setGradientMinpoint("#FFFFFF")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringKolor punktu minimalnego do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setGradientMinpointObject(color)

Czyści minimalną wartość punktu gradientu w regule formatowania warunkowego i zamiast tego używa minimalnej wartości w zakresach reguły. Ustawia też kolor punktu minimalnego gradientu na kolor wejściowy.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere between theme text and background colors, based on their values
// in comparison to the ranges minimum and maximum values.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var textColor = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
    .build();
var backgroundColor = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpoint(textColor)
    .setGradientMinpoint(backgroundColor)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorObiekt koloru punktu minimalnego do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setGradientMinpointObjectWithValue(color, type, value)

Ustawia pola punktów minimalnych gradientu w regule formatowania warunkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere from theme accent 1 to accent 2 to accent 3 colors, based on
// their values in comparison to the values 0, 50, and 100.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color1 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
    .build();
var color2 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
    .build();
var color3 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorColorKolor punktu minimalnego do ustawienia.
typeInterpolationTypeTyp interpolacji punktu minimalnego, który ma zostać ustawiony.
valueStringMinimalna wartość do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator służący do tworzenia łańcuchów.


setGradientMinpointWithValue(color, type, value)

Ustawia pola punktów minimalnych gradientu w regule formatowania warunkowego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their
// background color somewhere from red to green to blue, based on their values in comparison to
// the values 0, 50, and 100.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
colorStringKolor punktu minimalnego do ustawienia.
typeInterpolationTypeTyp interpolacji punktu minimalnego, który ma zostać ustawiony.
valueStringMinimalna wartość do ustawienia.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setItalic(italic)

Ustawia kursywę tekstu dla formatu reguły formatowania warunkowego. Jeśli italic ma wartość true, w przypadku spełnienia warunku reguła wyróżni tekst kursywą. Jeśli warunek zostanie spełniony, reguła spowoduje usunięcie kursywy, jeśli zostanie spełniony warunek false. Przekazanie wartości null powoduje usunięcie z reguły ustawienia formatu kursywy.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn their
// text italic if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setItalic(true)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
italicBooleanOkreśla, czy tekst ma być pisany kursywą w przypadku spełnienia warunku formatu. null usuwa to ustawienie.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setRanges(ranges)

Ustawia co najmniej jeden zakres, do którego stosowana jest ta reguła formatowania warunkowego. Ta operacja zastępuje wszystkie istniejące zakresy. Ustawienie pustej tablicy powoduje wyczyszczenie wszystkich istniejących zakresów. Reguła musi mieć co najmniej jeden zakres.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 and range D4:F6
// to turn red if they contain a number between 1 and 10.
var sheet = SpreadsheetApp.getActiveSheet();
var rangeOne = sheet.getRange("A1:B3");
var rangeTwo = sheet.getRange("D4:F6");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([rangeOne, rangeTwo])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setStrikethrough(strikethrough)

Ustawia przekreślenie tekstu dla formatu reguły formatowania warunkowego. Jeśli strikethrough ma wartość true, reguła przekreśla tekst, jeśli zostanie spełniony warunek. Jeśli zostanie spełniony warunek false, reguła usunie istniejące przekreślenie, jeśli zostanie spełniony warunek. Przekazywanie wartości null powoduje usunięcie z reguły ustawienia formatu przekreślonego.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to strikethrough
// their text if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setStrikethrough(true)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
strikethroughBooleanOkreśla, czy tekst ma być przekreślony w przypadku spełnienia warunku formatu. null usuwa to ustawienie.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


setUnderline(underline)

Ustawia podkreślenie tekstu dla formatu reguły formatowania warunkowego. Jeśli underline ma wartość true, w przypadku spełnienia warunku reguła podkreśla tekst, a jeśli false jest spełniony, reguła usuwa wszelkie istniejące podkreślenia, o ile jest spełniony. Przekazanie parametru null usuwa z reguły ustawienie formatu podkreślenia.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to underline
// their text if the cell has text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setUnderline(true)
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
underlineBooleanOkreśla, czy tekst ma być podkreślony w przypadku spełnienia warunku formatu. null usuwa to ustawienie.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenCellEmpty()

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka jest pusta.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they are empty.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenCellEmpty()
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenCellNotEmpty()

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy komórka nie jest pusta.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they are not empty.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenCellNotEmpty()
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenDateAfter(date)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a date after 11/4/1993.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateAfter(new Date("11/4/1993"))
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
dateDateNajnowsza data.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenDateAfter(date)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada po określonej dacie względnej.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a date after today.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
dateRelativeDateNajnowsza data w odniesieniu do wybranego typu daty.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenDateBefore(date)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed tą datą.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a date before 11/4/1993.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateBefore(new Date("11/4/1993"))
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
dateDateNajwcześniejsza niedopuszczalna data.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenDateBefore(date)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data przypada przed określoną datą względną.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a date before today.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
dateRelativeDateNajnowsza data w odniesieniu do wybranego typu daty.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenDateEqualTo(date)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy data jest równa tej dacie.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain the date 11/4/1993.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateEqualTo(new Date("11/4/1993"))
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
dateDateJedyna akceptowalna data.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenDateEqualTo(date)

Ustawia regułę formatowania warunkowego, która jest uruchamiana, gdy data jest równa podanej dacie względnej.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain todays date.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateEqualTo(SpreadsheetApp.RelativeDate.TODAY)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
dateRelativeDateNajnowsza data w odniesieniu do wybranego typu daty.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenFormulaSatisfied(formula)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dana formuła zwróci wartość true.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they satisfy the condition "=EQ(B4, C3)".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenFormulaSatisfied("=EQ(B4, C3)")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberBetween(start, end)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba mieści się między 2 określonymi wartościami lub jest jedną z tych wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a number between 1 and 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberEqualTo(number)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest równa podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain the number 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
numberNumberJedyna akceptowalna wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberGreaterThan(number)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa od podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red
// if they contain a number greater than 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberGreaterThan(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
numberNumberNajwyższa nieakceptowalna wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberGreaterThanOrEqualTo(number)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest większa lub równa danej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a number greater than or equal to 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberGreaterThanOrEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
numberNumberNajniższa akceptowalna wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberLessThan(number)

Ustawia regułę formatowania warunkowego, która uruchamia się, gdy liczba jest mniejsza od podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a number less than 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberLessThan(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
numberNumberNajniższa niedopuszczalna wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberLessThanOrEqualTo(number)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba jest mniejsza lub równa podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a number less than or equal to 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberLessThanOrEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
numberNumberNajwyższa akceptowana wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberNotBetween(start, end)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy liczba nie znajduje się między 2 określonymi wartościami i nie jest żadnej z nich.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain a number not between 1 and 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberNotBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenNumberNotEqualTo(number)

Ustawia regułę formatowania warunkowego, która uruchamia się, gdy liczba nie jest równa podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they don't contain the number 10.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberNotEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
numberNumberJedyna niedopuszczalna wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenTextContains(text)

Ustawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe zawierają określoną wartość.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they contain the text "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextContains("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenTextDoesNotContain(text)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe nie zawierają określonej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they don't contain the text "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextDoesNotContain("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
textStringWartość, której nie mogą zawierać dane wejściowe.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenTextEndsWith(text)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe będą się kończyć określoną wartością.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they end with the text "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEndsWith("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenTextEqualTo(text)

Ustawia regułę formatowania warunkowego, która będzie wyzwalana, gdy dane wejściowe będą równe podanej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they have text equal to "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

NazwaTypOpis
textStringJedyna akceptowalna wartość.

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


whenTextStartsWith(text)

Ustawia regułę formatowania warunkowego, która jest wyzwalana, gdy dane wejściowe zaczynają się od określonej wartości.

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if
// they start with the text "hello".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextStartsWith("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.


withCriteria(criteria, args)

Ustawia regułę formatowania warunkowego na kryteria zdefiniowane przez wartości BooleanCriteria, zwykle pobierane z criteria i arguments istniejącej reguły.

// Adds a new conditional format rule that is a copy of the first active
// conditional format rule, except it instead sets its cells to have a black
// background color.

var sheet = SpreadsheetApp.getActiveSheet();
var rules = sheet.getConditionalFormatRules();
var booleanCondition = rules[0].getBooleanCondition();
if (booleanCondition != null) {
  var rule = SpreadsheetApp.newConditionalFormatRule()
      .withCriteria(booleanCondition.getCriteriaType(),
         booleanCondition.getCriteriaValues())
      .setBackground("#000000")
      .setRanges(rule.getRanges())
      .build();
  rules.push(rule);
}
sheet.setConditionalFormatRules(rules);

Parametry

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

Powroty

ConditionalFormatRuleBuilder – kreator tworzenia łańcuchów.