Class ConditionalFormatRuleBuilder

הכלי ליצירת כלליםלתבניתמותנית

כלי ליצירת כללים של עיצוב מותנה.

// 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);

Methods

שיטהסוג הערך שמוחזרתיאור קצר
build()ConditionalFormatRuleיוצר כלל של עיצוב מותנה מההגדרות שחלות על ה-builder.
copy()ConditionalFormatRuleBuilderמחזירה הגדרה קבועה מראש של כלי ליצירת כללים עם ההגדרות של הכלל הזה.
getBooleanCondition()BooleanConditionמאחזר את המידע BooleanCondition של הכלל אם הכלל הזה משתמש בקריטריונים של תנאי בוליאני.
getGradientCondition()GradientConditionמאחזר את פרטי GradientCondition של הכלל, אם הכלל הזה משתמש בקריטריונים של תנאי הדרגתיות.
getRanges()Range[]מחזירה את הטווחים שהכלל הזה של עיצוב מותנה חל עליהם.
setBackground(color)ConditionalFormatRuleBuilderהגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה.
setBackgroundObject(color)ConditionalFormatRuleBuilderהגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה.
setBold(bold)ConditionalFormatRuleBuilderהגדרת עיצוב מודגש לטקסט בפורמט של כלל העיצוב המותנה.
setFontColor(color)ConditionalFormatRuleBuilderהגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה.
setFontColorObject(color)ConditionalFormatRuleBuilderהגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה.
setGradientMaxpoint(color)ConditionalFormatRuleBuilderמנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל.
setGradientMaxpointObject(color)ConditionalFormatRuleBuilderמנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל.
setGradientMaxpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderהפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה.
setGradientMaxpointWithValue(color, type, value)ConditionalFormatRuleBuilderהפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה.
setGradientMidpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderהפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה.
setGradientMidpointWithValue(color, type, value)ConditionalFormatRuleBuilderהפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה.
setGradientMinpoint(color)ConditionalFormatRuleBuilderמנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל.
setGradientMinpointObject(color)ConditionalFormatRuleBuilderמנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל.
setGradientMinpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderמגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה.
setGradientMinpointWithValue(color, type, value)ConditionalFormatRuleBuilderמגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה.
setItalic(italic)ConditionalFormatRuleBuilderמגדיר את הטקסט בכתב נטוי עבור הפורמט של כלל העיצוב המותנה.
setRanges(ranges)ConditionalFormatRuleBuilderהגדרת טווח אחד או יותר שכלל העיצוב המותנה הזה יחול עליהם.
setStrikethrough(strikethrough)ConditionalFormatRuleBuilderהגדרת קו חוצה לטקסט בפורמט של כלל העיצוב המותנה.
setUnderline(underline)ConditionalFormatRuleBuilderהגדרת קו תחתון לטקסט בפורמט של כלל העיצוב המותנה.
whenCellEmpty()ConditionalFormatRuleBuilderהגדרת כלל של עיצוב מותנה שמופעל כשהתא ריק.
whenCellNotEmpty()ConditionalFormatRuleBuilderהגדרת כלל של עיצוב מותנה שמופעל כשהתא לא ריק.
whenDateAfter(date)ConditionalFormatRuleBuilderהגדרת הכלל לעיצוב מותנה כך שיופעל כשתאריך מאוחר מהערך שצוין.
whenDateAfter(date)ConditionalFormatRuleBuilderהגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מאוחר יותר מהתאריך היחסי שצוין.
whenDateBefore(date)ConditionalFormatRuleBuilderהגדרת כלל של עיצוב מותנה שמופעל כשתאריך מוקדם מהתאריך שצוין.
whenDateBefore(date)ConditionalFormatRuleBuilderהגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מוקדם יותר מהתאריך היחסי הנתון.
whenDateEqualTo(date)ConditionalFormatRuleBuilderהפעלת כלל העיצוב המותנה כשערך התאריך שווה לתאריך הנתון.
whenDateEqualTo(date)ConditionalFormatRuleBuilderהפונקציה מגדירה את הכלל של העיצוב המותנה כך שיופעל כשתאריך מסוים שווה לתאריך היחסי שצוין.
whenFormulaSatisfied(formula)ConditionalFormatRuleBuilderהגדרת הכלל של העיצוב המותנה כך שיופעל כשהנוסחה שצוינה מחזירה את הערך true.
whenNumberBetween(start, end)ConditionalFormatRuleBuilderהפונקציה מגדירה את הכלל של העיצוב המותנה כך שהוא יופעל כשמספר נמצא בין שני ערכים שצוינו, או שווה לאחד מהם.
whenNumberEqualTo(number)ConditionalFormatRuleBuilderהגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר שווה לערך הנתון.
whenNumberGreaterThan(number)ConditionalFormatRuleBuilderהגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר גדול מהערך שצוין.
whenNumberGreaterThanOrEqualTo(number)ConditionalFormatRuleBuilderהכלל לעיצוב מותנה מופעל כשמספר גדול מהערך שצוין או שווה לו.
whenNumberLessThan(number)ConditionalFormatRuleBuilderהגדרת כלל לעיצוב מותנה שמופעל כשמספר קטן מהערך שצוין.
whenNumberLessThanOrEqualTo(number)ConditionalFormatRuleBuilderמגדירה את הכלל לעיצוב מותנה כך שיופעל כשמספר קטן מהערך שצוין או שווה לו.
whenNumberNotBetween(start, end)ConditionalFormatRuleBuilderהכלל של העיצוב המותנה מוגדר כך שיופעל כשמספר לא נמצא בין שני ערכים שצוינו, ולא שווה לאף אחד מהם.
whenNumberNotEqualTo(number)ConditionalFormatRuleBuilderהכלל לעיצוב מותנה מוגדר כך שהוא יופעל כשמספר לא שווה לערך הנתון.
whenTextContains(text)ConditionalFormatRuleBuilderהכלל לעיצוב מותנה מוגדר כך שיופעל כשהקלט מכיל את הערך הנתון.
whenTextDoesNotContain(text)ConditionalFormatRuleBuilderהגדרת כלל של עיצוב מותנה שמופעל כשהקלט לא מכיל את הערך שצוין.
whenTextEndsWith(text)ConditionalFormatRuleBuilderמגדיר את הכלל לעיצוב מותנה כך שיופעל כשהקלט מסתיים בערך הנתון.
whenTextEqualTo(text)ConditionalFormatRuleBuilderהגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט שווה לערך שצוין.
whenTextStartsWith(text)ConditionalFormatRuleBuilderהגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט מתחיל בערך הנתון.
withCriteria(criteria, args)ConditionalFormatRuleBuilderמגדיר את הכלל של העיצוב המותנה לפי קריטריונים שמוגדרים על ידי ערכי BooleanCriteria, בדרך כלל מתוך criteria ו-arguments של כלל קיים.

תיעוד מפורט

build()

יוצר כלל של עיצוב מותנה מההגדרות שחלות על ה-builder.

חזרה

ConditionalFormatRule – ייצוג של כלל העיצוב המותנה.


copy()

מחזירה הגדרה קבועה מראש של כלי ליצירת כללים עם ההגדרות של הכלל הזה.

חזרה

ConditionalFormatRuleBuilder – כלי בנייה שמבוסס על ההגדרות של הכלל הזה.


getBooleanCondition()

מאחזר את המידע BooleanCondition של הכלל אם הכלל הזה משתמש בקריטריונים של תנאי בוליאני. אחרת, הפונקציה מחזירה את הערך 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()); }

חזרה

BooleanCondition – אובייקט התנאי הבוליאני, או null אם הכלל לא משתמש בתנאי בוליאני.


getGradientCondition()

מאחזר את פרטי GradientCondition של הכלל, אם הכלל הזה משתמש בקריטריונים של תנאי הדרגתיות. אחרת, הפונקציה מחזירה את הערך 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()); }

חזרה

GradientCondition – אובייקט התנאי של המעבר, או null אם הכלל לא משתמש בתנאי של מעבר.


getRanges()

מחזירה את הטווחים שהכלל הזה של עיצוב מותנה חל עליהם.

// 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()); }

חזרה

Range[] – הטווחים שעליהם חל כלל העיצוב המותנה הזה.


setBackground(color)

הגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה. העברה של null מסירה את הגדרת העיצוב של צבע הרקע מהכלל.

// 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);

פרמטרים

שםסוגתיאור
colorStringהצבע הרצוי או null כדי לנקות.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setBackgroundObject(color)

הגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה. העברה של null מסירה את הגדרת העיצוב של צבע הרקע מהכלל.

// 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);

פרמטרים

שםסוגתיאור
colorColorהאובייקט בצבע הרצוי או null כדי לנקות.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setBold(bold)

הגדרת עיצוב מודגש לטקסט בפורמט של כלל העיצוב המותנה. אם bold הוא true, הכלל מדגיש את הטקסט אם התנאי מתקיים. אם bold הוא false, הכלל מסיר את ההדגשה הקיימת אם התנאי מתקיים. העברה של null מסירה את הגדרת העיצוב המודגש מהכלל.

// 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);

פרמטרים

שםסוגתיאור
boldBooleanהאם הטקסט צריך להיות מודגש אם תנאי הפורמט מתקיים. null מסיר את ההגדרה הזו.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setFontColor(color)

הגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה. העברה של null מסירה את הגדרת העיצוב של צבע הגופן מהכלל.

// 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);

פרמטרים

שםסוגתיאור
colorStringהצבע הרצוי או null כדי לנקות.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setFontColorObject(color)

הגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה. העברה של null מסירה את הגדרת העיצוב של צבע הגופן מהכלל.

// 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);

פרמטרים

שםסוגתיאור
colorColorהאובייקט בצבע הרצוי או null כדי לנקות.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMaxpoint(color)

מנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המקסימלית של המעבר ההדרגתי לצבע הקלט.

// 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);

פרמטרים

שםסוגתיאור
colorStringהצבע של הנקודה המקסימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMaxpointObject(color)

מנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המקסימלית של המעבר ההדרגתי לצבע הקלט.

// 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);

פרמטרים

שםסוגתיאור
colorColorאובייקט הצבע של הנקודה המקסימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMaxpointObjectWithValue(color, type, value)

הפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה.

// 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);

פרמטרים

שםסוגתיאור
colorColorהצבע של הנקודה המקסימלית שרוצים להגדיר.
typeInterpolationTypeסוג האינטרפולציה של נקודת המקסימום שרוצים להגדיר.
valueStringהערך של הנקודה המקסימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMaxpointWithValue(color, type, value)

הפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה.

// 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);

פרמטרים

שםסוגתיאור
colorStringהצבע של הנקודה המקסימלית שרוצים להגדיר.
typeInterpolationTypeסוג האינטרפולציה של נקודת המקסימום שרוצים להגדיר.
valueStringהערך של הנקודה המקסימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMidpointObjectWithValue(color, type, value)

הפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה. ניקוי כל השדות של נקודת האמצע אם סוג האינטרפולציה שהועבר הוא 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);

פרמטרים

שםסוגתיאור
colorColorצבע נקודת האמצע שרוצים להגדיר.
typeInterpolationTypeסוג האינטרפולציה של נקודת האמצע להגדרה או null לביטול.
valueStringערך נקודת האמצע להגדרה.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMidpointWithValue(color, type, value)

הפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה. ניקוי כל השדות של נקודת האמצע אם סוג האינטרפולציה שהועבר הוא 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);

פרמטרים

שםסוגתיאור
colorStringצבע נקודת האמצע שרוצים להגדיר.
typeInterpolationTypeסוג האינטרפולציה של נקודת האמצע להגדרה או null לביטול.
valueStringערך נקודת האמצע להגדרה.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMinpoint(color)

מנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המינימלית של הגרדיאנט לצבע הקלט.

// 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);

פרמטרים

שםסוגתיאור
colorStringהצבע של הנקודה המינימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMinpointObject(color)

מנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המינימלית של הגרדיאנט לצבע הקלט.

// 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);

פרמטרים

שםסוגתיאור
colorColorאובייקט הצבע של הנקודה המינימלית להגדרה.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMinpointObjectWithValue(color, type, value)

מגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה.

// 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);

פרמטרים

שםסוגתיאור
colorColorהצבע של הנקודה המינימלית שרוצים להגדיר.
typeInterpolationTypeסוג האינטרפולציה של נקודת המינימום שרוצים להגדיר.
valueStringהערך של הנקודה המינימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setGradientMinpointWithValue(color, type, value)

מגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה.

// 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);

פרמטרים

שםסוגתיאור
colorStringהצבע של הנקודה המינימלית שרוצים להגדיר.
typeInterpolationTypeסוג האינטרפולציה של נקודת המינימום שרוצים להגדיר.
valueStringהערך של הנקודה המינימלית שרוצים להגדיר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setItalic(italic)

מגדיר את הטקסט בכתב נטוי עבור הפורמט של כלל העיצוב המותנה. אם italic הוא true, הכלל מדגיש את הטקסט אם התנאי מתקיים. אם italic הוא false, הכלל מסיר את ההדגשה הקיימת אם התנאי מתקיים. העברת null מסירה את הגדרת העיצוב של הטקסט הנטוי מהכלל.

// 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);

פרמטרים

שםסוגתיאור
italicBooleanהאם הטקסט צריך להיות מוטה אם מתקיים תנאי הפורמט; ‫null מסיר את ההגדרה הזו.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setRanges(ranges)

הגדרת טווח אחד או יותר שכלל העיצוב המותנה הזה יחול עליהם. הפעולה הזו מחליפה טווחים קיימים. הגדרת מערך ריק תמחק את כל הטווחים הקיימים. כלל חייב לכלול לפחות טווח אחד.

// 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);

פרמטרים

שםסוגתיאור
rangesRange[]הטווחים שעליהם חל כלל העיצוב המותנה הזה.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setStrikethrough(strikethrough)

הגדרת קו חוצה לטקסט בפורמט של כלל העיצוב המותנה. אם הערך של strikethrough הוא true, הכלל מוסיף קו חוצה לטקסט אם התנאי מתקיים. אם הערך הוא false, הכלל מסיר את העיצוב של הקו החוצה אם התנאי מתקיים. העברה של null מסירה את הגדרת העיצוב של הקו החוצה מהכלל.

// 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);

פרמטרים

שםסוגתיאור
strikethroughBooleanהאם הטקסט צריך להיות עם קו חוצה אם התנאי של הפורמט מתקיים. null מסיר את ההגדרה הזו.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


setUnderline(underline)

הגדרת קו תחתון לטקסט בפורמט של כלל העיצוב המותנה. אם underline הוא true, הכלל מדגיש את הטקסט אם התנאי מתקיים. אם underline הוא false, הכלל מסיר את כל ההדגשות הקיימות אם התנאי מתקיים. העברת null מסירה את הגדרת העיצוב של הקו התחתון מהכלל.

// 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);

פרמטרים

שםסוגתיאור
underlineBooleanהאם הטקסט צריך להיות מודגש אם מתקיים תנאי הפורמט; ‫null מסיר את ההגדרה הזו.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenCellEmpty()

הגדרת כלל של עיצוב מותנה שמופעל כשהתא ריק.

// 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);

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenCellNotEmpty()

הגדרת כלל של עיצוב מותנה שמופעל כשהתא לא ריק.

// 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);

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenDateAfter(date)

הגדרת הכלל לעיצוב מותנה כך שיופעל כשתאריך מאוחר מהערך שצוין.

// 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);

פרמטרים

שםסוגתיאור
dateDateהתאריך האחרון.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenDateAfter(date)

הגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מאוחר יותר מהתאריך היחסי שצוין.

// 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);

פרמטרים

שםסוגתיאור
dateRelativeDateהתאריך האחרון ביחס לסוג התאריך שנבחר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenDateBefore(date)

הגדרת כלל של עיצוב מותנה שמופעל כשתאריך מוקדם מהתאריך שצוין.

// 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);

פרמטרים

שםסוגתיאור
dateDateהתאריך המוקדם ביותר שלא קביל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenDateBefore(date)

הגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מוקדם יותר מהתאריך היחסי הנתון.

// 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);

פרמטרים

שםסוגתיאור
dateRelativeDateהתאריך האחרון ביחס לסוג התאריך שנבחר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenDateEqualTo(date)

הפעלת כלל העיצוב המותנה כשערך התאריך שווה לתאריך הנתון.

// 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);

פרמטרים

שםסוגתיאור
dateDateהתאריך הקביל היחיד.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenDateEqualTo(date)

הפונקציה מגדירה את הכלל של העיצוב המותנה כך שיופעל כשתאריך מסוים שווה לתאריך היחסי שצוין.

// 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);

פרמטרים

שםסוגתיאור
dateRelativeDateהתאריך האחרון ביחס לסוג התאריך שנבחר.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenFormulaSatisfied(formula)

הגדרת הכלל של העיצוב המותנה כך שיופעל כשהנוסחה שצוינה מחזירה את הערך 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);

פרמטרים

שםסוגתיאור
formulaStringנוסחה מותאמת אישית שמחזירה את הערך true אם הקלט תקין.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberBetween(start, end)

הפונקציה מגדירה את הכלל של העיצוב המותנה כך שהוא יופעל כשמספר נמצא בין שני ערכים שצוינו, או שווה לאחד מהם.

// 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);

פרמטרים

שםסוגתיאור
startNumberהערך הנמוך ביותר שמתקבל.
endNumberהערך המקסימלי הקביל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberEqualTo(number)

הגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר שווה לערך הנתון.

// 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);

פרמטרים

שםסוגתיאור
numberNumberהערך הקביל היחיד.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberGreaterThan(number)

הגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר גדול מהערך שצוין.

// 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);

פרמטרים

שםסוגתיאור
numberNumberהערך הכי גבוה שלא מתקבל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberGreaterThanOrEqualTo(number)

הכלל לעיצוב מותנה מופעל כשמספר גדול מהערך שצוין או שווה לו.

// 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);

פרמטרים

שםסוגתיאור
numberNumberהערך הנמוך ביותר שמתקבל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberLessThan(number)

הגדרת כלל לעיצוב מותנה שמופעל כשמספר קטן מהערך שצוין.

// 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);

פרמטרים

שםסוגתיאור
numberNumberהערך הנמוך ביותר שאינו קביל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberLessThanOrEqualTo(number)

מגדירה את הכלל לעיצוב מותנה כך שיופעל כשמספר קטן מהערך שצוין או שווה לו.

// 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);

פרמטרים

שםסוגתיאור
numberNumberהערך המקסימלי הקביל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberNotBetween(start, end)

הכלל של העיצוב המותנה מוגדר כך שיופעל כשמספר לא נמצא בין שני ערכים שצוינו, ולא שווה לאף אחד מהם.

// 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);

פרמטרים

שםסוגתיאור
startNumberהערך הנמוך ביותר שאינו קביל.
endNumberהערך הכי גבוה שלא מתקבל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenNumberNotEqualTo(number)

הכלל לעיצוב מותנה מוגדר כך שהוא יופעל כשמספר לא שווה לערך הנתון.

// 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);

פרמטרים

שםסוגתיאור
numberNumberהערך היחיד שלא מתקבל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenTextContains(text)

הכלל לעיצוב מותנה מוגדר כך שיופעל כשהקלט מכיל את הערך הנתון.

// 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);

פרמטרים

שםסוגתיאור
textStringהערך שחייב להיות בקלט.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenTextDoesNotContain(text)

הגדרת כלל של עיצוב מותנה שמופעל כשהקלט לא מכיל את הערך שצוין.

// 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);

פרמטרים

שםסוגתיאור
textStringהערך שהקלט לא יכול להכיל.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenTextEndsWith(text)

מגדיר את הכלל לעיצוב מותנה כך שיופעל כשהקלט מסתיים בערך הנתון.

// 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);

פרמטרים

שםסוגתיאור
textStringהטקסט להשוואה לסוף המחרוזת.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenTextEqualTo(text)

הגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט שווה לערך שצוין.

// 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);

פרמטרים

שםסוגתיאור
textStringהערך הקביל היחיד.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


whenTextStartsWith(text)

הגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט מתחיל בערך הנתון.

// 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);

פרמטרים

שםסוגתיאור
textStringהטקסט שמשווים לתחילת המחרוזת.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.


withCriteria(criteria, args)

מגדיר את הכלל של העיצוב המותנה לפי קריטריונים שמוגדרים על ידי ערכי BooleanCriteria, בדרך כלל מתוך criteria ו-arguments של כלל קיים.

// 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);

פרמטרים

שםסוגתיאור
criteriaBooleanCriteriaסוג הקריטריונים לעיצוב מותנה.
argsObject[]מערך של ארגומנטים שמתאימים לסוג הקריטריון. מספר הארגומנטים והסוג שלהם תואמים לשיטת when...() שמופיעה למעלה.

חזרה

ConditionalFormatRuleBuilder – האובייקט שיוצר את השרשור.