כלי ליצירת כללים של עיצוב מותנה.
// 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() | Conditional | יוצר כלל של עיצוב מותנה מההגדרות שחלות על ה-builder. | 
| copy() | Conditional | מחזירה הגדרה קבועה מראש של כלי ליצירת כללים עם ההגדרות של הכלל הזה. | 
| get | Boolean | מאחזר את המידע Booleanשל הכלל אם הכלל הזה משתמש בקריטריונים של תנאי בוליאני. | 
| get | Gradient | מאחזר את פרטי Gradientשל הכלל, אם הכלל הזה משתמש בקריטריונים של תנאי הדרגתיות. | 
| get | Range[] | מחזירה את הטווחים שהכלל הזה של עיצוב מותנה חל עליהם. | 
| set | Conditional | הגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה. | 
| set | Conditional | הגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה. | 
| set | Conditional | הגדרת עיצוב מודגש לטקסט בפורמט של כלל העיצוב המותנה. | 
| set | Conditional | הגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה. | 
| set | Conditional | הגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה. | 
| set | Conditional | מנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל. | 
| set | Conditional | מנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל. | 
| set | Conditional | הפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה. | 
| set | Conditional | הפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה. | 
| set | Conditional | הפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה. | 
| set | Conditional | הפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה. | 
| set | Conditional | מנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל. | 
| set | Conditional | מנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל. | 
| set | Conditional | מגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה. | 
| set | Conditional | מגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה. | 
| set | Conditional | מגדיר את הטקסט בכתב נטוי עבור הפורמט של כלל העיצוב המותנה. | 
| set | Conditional | הגדרת טווח אחד או יותר שכלל העיצוב המותנה הזה יחול עליהם. | 
| set | Conditional | הגדרת קו חוצה לטקסט בפורמט של כלל העיצוב המותנה. | 
| set | Conditional | הגדרת קו תחתון לטקסט בפורמט של כלל העיצוב המותנה. | 
| when | Conditional | הגדרת כלל של עיצוב מותנה שמופעל כשהתא ריק. | 
| when | Conditional | הגדרת כלל של עיצוב מותנה שמופעל כשהתא לא ריק. | 
| when | Conditional | הגדרת הכלל לעיצוב מותנה כך שיופעל כשתאריך מאוחר מהערך שצוין. | 
| when | Conditional | הגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מאוחר יותר מהתאריך היחסי שצוין. | 
| when | Conditional | הגדרת כלל של עיצוב מותנה שמופעל כשתאריך מוקדם מהתאריך שצוין. | 
| when | Conditional | הגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מוקדם יותר מהתאריך היחסי הנתון. | 
| when | Conditional | הפעלת כלל העיצוב המותנה כשערך התאריך שווה לתאריך הנתון. | 
| when | Conditional | הפונקציה מגדירה את הכלל של העיצוב המותנה כך שיופעל כשתאריך מסוים שווה לתאריך היחסי שצוין. | 
| when | Conditional | הגדרת הכלל של העיצוב המותנה כך שיופעל כשהנוסחה שצוינה מחזירה את הערך true. | 
| when | Conditional | הפונקציה מגדירה את הכלל של העיצוב המותנה כך שהוא יופעל כשמספר נמצא בין שני ערכים שצוינו, או שווה לאחד מהם. | 
| when | Conditional | הגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר שווה לערך הנתון. | 
| when | Conditional | הגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר גדול מהערך שצוין. | 
| when | Conditional | הכלל לעיצוב מותנה מופעל כשמספר גדול מהערך שצוין או שווה לו. | 
| when | Conditional | הגדרת כלל לעיצוב מותנה שמופעל כשמספר קטן מהערך שצוין. | 
| when | Conditional | מגדירה את הכלל לעיצוב מותנה כך שיופעל כשמספר קטן מהערך שצוין או שווה לו. | 
| when | Conditional | הכלל של העיצוב המותנה מוגדר כך שיופעל כשמספר לא נמצא בין שני ערכים שצוינו, ולא שווה לאף אחד מהם. | 
| when | Conditional | הכלל לעיצוב מותנה מוגדר כך שהוא יופעל כשמספר לא שווה לערך הנתון. | 
| when | Conditional | הכלל לעיצוב מותנה מוגדר כך שיופעל כשהקלט מכיל את הערך הנתון. | 
| when | Conditional | הגדרת כלל של עיצוב מותנה שמופעל כשהקלט לא מכיל את הערך שצוין. | 
| when | Conditional | מגדיר את הכלל לעיצוב מותנה כך שיופעל כשהקלט מסתיים בערך הנתון. | 
| when | Conditional | הגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט שווה לערך שצוין. | 
| when | Conditional | הגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט מתחיל בערך הנתון. | 
| with | Conditional | מגדיר את הכלל של העיצוב המותנה לפי קריטריונים שמוגדרים על ידי ערכי Boolean, בדרך כלל מתוךcriteriaו-argumentsשל כלל קיים. | 
תיעוד מפורט
build()
יוצר כלל של עיצוב מותנה מההגדרות שחלות על ה-builder.
חזרה
Conditional – ייצוג של כלל העיצוב המותנה.
copy()
מחזירה הגדרה קבועה מראש של כלי ליצירת כללים עם ההגדרות של הכלל הזה.
חזרה
Conditional – כלי בנייה שמבוסס על ההגדרות של הכלל הזה.
get
מאחזר את המידע Boolean של הכלל אם הכלל הזה משתמש בקריטריונים של תנאי בוליאני. אחרת, הפונקציה מחזירה את הערך 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()); }
חזרה
Boolean – אובייקט התנאי הבוליאני, או null אם הכלל לא משתמש בתנאי בוליאני.
get
מאחזר את פרטי Gradient של הכלל, אם הכלל הזה משתמש בקריטריונים של תנאי הדרגתיות. אחרת, הפונקציה מחזירה את הערך 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()); }
חזרה
Gradient – אובייקט התנאי של המעבר, או null אם הכלל לא משתמש בתנאי של מעבר.
get
מחזירה את הטווחים שהכלל הזה של עיצוב מותנה חל עליהם.
// 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[] – הטווחים שעליהם חל כלל העיצוב המותנה הזה.
set
הגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה. העברה של 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | הצבע הרצוי או nullכדי לנקות. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרה של צבע הרקע של העיצוב של כלל העיצוב המותנה. העברה של 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | האובייקט בצבע הרצוי או nullכדי לנקות. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרת עיצוב מודגש לטקסט בפורמט של כלל העיצוב המותנה. אם 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| bold | Boolean | האם הטקסט צריך להיות מודגש אם תנאי הפורמט מתקיים. nullמסיר את ההגדרה הזו. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה. העברה של 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | הצבע הרצוי או nullכדי לנקות. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרת צבע הגופן של הפורמט של כלל העיצוב המותנה. העברה של 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | האובייקט בצבע הרצוי או nullכדי לנקות. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המקסימלית של המעבר ההדרגתי לצבע הקלט.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | הצבע של הנקודה המקסימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מנקה את הערך המקסימלי של הגרדיאנט של כלל העיצוב המותנה, ובמקום זאת משתמש בערך המקסימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המקסימלית של המעבר ההדרגתי לצבע הקלט.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | אובייקט הצבע של הנקודה המקסימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | הצבע של הנקודה המקסימלית שרוצים להגדיר. | 
| type | Interpolation | סוג האינטרפולציה של נקודת המקסימום שרוצים להגדיר. | 
| value | String | הערך של הנקודה המקסימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הפונקציה מגדירה את שדות נקודת המקסימום של המעבר ההדרגתי בכלל העיצוב המותנה.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | הצבע של הנקודה המקסימלית שרוצים להגדיר. | 
| type | Interpolation | סוג האינטרפולציה של נקודת המקסימום שרוצים להגדיר. | 
| value | String | הערך של הנקודה המקסימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה. ניקוי כל השדות של נקודת האמצע אם סוג האינטרפולציה שהועבר הוא 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | צבע נקודת האמצע שרוצים להגדיר. | 
| type | Interpolation | סוג האינטרפולציה של נקודת האמצע להגדרה או nullלביטול. | 
| value | String | ערך נקודת האמצע להגדרה. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הפונקציה מגדירה את שדות נקודת האמצע של המעבר ההדרגתי בכלל העיצוב המותנה. ניקוי כל השדות של נקודת האמצע אם סוג האינטרפולציה שהועבר הוא 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | צבע נקודת האמצע שרוצים להגדיר. | 
| type | Interpolation | סוג האינטרפולציה של נקודת האמצע להגדרה או nullלביטול. | 
| value | String | ערך נקודת האמצע להגדרה. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המינימלית של הגרדיאנט לצבע הקלט.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | הצבע של הנקודה המינימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מנקה את ערך נקודת המינימום של המעבר ההדרגתי של הכלל לעיצוב מותנה, ובמקום זאת משתמש בערך המינימלי בטווחים של הכלל. הפונקציה גם מגדירה את צבע הנקודה המינימלית של הגרדיאנט לצבע הקלט.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | אובייקט הצבע של הנקודה המינימלית להגדרה. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | Color | הצבע של הנקודה המינימלית שרוצים להגדיר. | 
| type | Interpolation | סוג האינטרפולציה של נקודת המינימום שרוצים להגדיר. | 
| value | String | הערך של הנקודה המינימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מגדיר את שדות נקודת המינימום של המעבר ההדרגתי בכלל העיצוב המותנה.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| color | String | הצבע של הנקודה המינימלית שרוצים להגדיר. | 
| type | Interpolation | סוג האינטרפולציה של נקודת המינימום שרוצים להגדיר. | 
| value | String | הערך של הנקודה המינימלית שרוצים להגדיר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
מגדיר את הטקסט בכתב נטוי עבור הפורמט של כלל העיצוב המותנה. אם 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| italic | Boolean | האם הטקסט צריך להיות מוטה אם מתקיים תנאי הפורמט;
     nullמסיר את ההגדרה הזו. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרת טווח אחד או יותר שכלל העיצוב המותנה הזה יחול עליהם. הפעולה הזו מחליפה טווחים קיימים. הגדרת מערך ריק תמחק את כל הטווחים הקיימים. כלל חייב לכלול לפחות טווח אחד.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| ranges | Range[] | הטווחים שעליהם חל כלל העיצוב המותנה הזה. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרת קו חוצה לטקסט בפורמט של כלל העיצוב המותנה. אם הערך של 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| strikethrough | Boolean | האם הטקסט צריך להיות עם קו חוצה אם התנאי של הפורמט מתקיים. nullמסיר את ההגדרה הזו. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
set
הגדרת קו תחתון לטקסט בפורמט של כלל העיצוב המותנה. אם 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| underline | Boolean | האם הטקסט צריך להיות מודגש אם מתקיים תנאי הפורמט;
     nullמסיר את ההגדרה הזו. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל של עיצוב מותנה שמופעל כשהתא ריק.
// 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);
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל של עיצוב מותנה שמופעל כשהתא לא ריק.
// 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);
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת הכלל לעיצוב מותנה כך שיופעל כשתאריך מאוחר מהערך שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| date | Date | התאריך האחרון. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מאוחר יותר מהתאריך היחסי שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| date | Relative | התאריך האחרון ביחס לסוג התאריך שנבחר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל של עיצוב מותנה שמופעל כשתאריך מוקדם מהתאריך שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| date | Date | התאריך המוקדם ביותר שלא קביל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל של עיצוב מותנה שמופעל כשהתאריך מוקדם יותר מהתאריך היחסי הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| date | Relative | התאריך האחרון ביחס לסוג התאריך שנבחר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הפעלת כלל העיצוב המותנה כשערך התאריך שווה לתאריך הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| date | Date | התאריך הקביל היחיד. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הפונקציה מגדירה את הכלל של העיצוב המותנה כך שיופעל כשתאריך מסוים שווה לתאריך היחסי שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| date | Relative | התאריך האחרון ביחס לסוג התאריך שנבחר. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת הכלל של העיצוב המותנה כך שיופעל כשהנוסחה שצוינה מחזירה את הערך 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| formula | String | נוסחה מותאמת אישית שמחזירה את הערך trueאם הקלט תקין. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הפונקציה מגדירה את הכלל של העיצוב המותנה כך שהוא יופעל כשמספר נמצא בין שני ערכים שצוינו, או שווה לאחד מהם.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| start | Number | הערך הנמוך ביותר שמתקבל. | 
| end | Number | הערך המקסימלי הקביל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר שווה לערך הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| number | Number | הערך הקביל היחיד. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת הכלל לעיצוב מותנה כך שיופעל כשמספר גדול מהערך שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| number | Number | הערך הכי גבוה שלא מתקבל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הכלל לעיצוב מותנה מופעל כשמספר גדול מהערך שצוין או שווה לו.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| number | Number | הערך הנמוך ביותר שמתקבל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל לעיצוב מותנה שמופעל כשמספר קטן מהערך שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| number | Number | הערך הנמוך ביותר שאינו קביל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
מגדירה את הכלל לעיצוב מותנה כך שיופעל כשמספר קטן מהערך שצוין או שווה לו.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| number | Number | הערך המקסימלי הקביל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הכלל של העיצוב המותנה מוגדר כך שיופעל כשמספר לא נמצא בין שני ערכים שצוינו, ולא שווה לאף אחד מהם.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| start | Number | הערך הנמוך ביותר שאינו קביל. | 
| end | Number | הערך הכי גבוה שלא מתקבל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הכלל לעיצוב מותנה מוגדר כך שהוא יופעל כשמספר לא שווה לערך הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| number | Number | הערך היחיד שלא מתקבל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הכלל לעיצוב מותנה מוגדר כך שיופעל כשהקלט מכיל את הערך הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| text | String | הערך שחייב להיות בקלט. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת כלל של עיצוב מותנה שמופעל כשהקלט לא מכיל את הערך שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| text | String | הערך שהקלט לא יכול להכיל. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
מגדיר את הכלל לעיצוב מותנה כך שיופעל כשהקלט מסתיים בערך הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| text | String | הטקסט להשוואה לסוף המחרוזת. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט שווה לערך שצוין.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| text | String | הערך הקביל היחיד. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
when
הגדרת הכלל לעיצוב מותנה כך שיופעל כשהקלט מתחיל בערך הנתון.
// 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| text | String | הטקסט שמשווים לתחילת המחרוזת. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.
with
מגדיר את הכלל של העיצוב המותנה לפי קריטריונים שמוגדרים על ידי ערכי Boolean, בדרך כלל מתוך 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);
פרמטרים
| שם | סוג | תיאור | 
|---|---|---|
| criteria | Boolean | סוג הקריטריונים לעיצוב מותנה. | 
| args | Object[] | מערך של ארגומנטים שמתאימים לסוג הקריטריון. מספר הארגומנטים והסוג שלהם תואמים לשיטת when...()שמופיעה למעלה. | 
חזרה
Conditional – האובייקט שיוצר את השרשור.