הכלי ליצירת כללים של עיצוב מותנה.
// 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 Condition()
מאחזר את המידע 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 Condition()
מאחזר את פרטי 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 Ranges()
מחזירה את הטווחים שהכלל הזה של עיצוב מותנה חל עליהם.
// 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 Background(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | הצבע הרצוי או null כדי לנקות. |
חזרה
Conditional — ה-builder, לשרשור.
set Background Object(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | האובייקט בצבע הרצוי או null כדי לנקות. |
חזרה
Conditional — ה-builder, לשרשור.
set Bold(bold)
הגדרה של הדגשת הטקסט בפורמט של כלל העיצוב המותנה. אם bold הוא true, הכלל מדגיש את הטקסט אם התנאי מתקיים. אם 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 — ה-builder, לשרשור.
set Font Color(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | הצבע הרצוי או null כדי לנקות. |
חזרה
Conditional — ה-builder, לשרשור.
set Font Color Object(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | האובייקט בצבע הרצוי או null כדי לנקות. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Maxpoint(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | הצבע של הנקודה המקסימלית שרוצים להגדיר. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Maxpoint Object(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | אובייקט הצבע של הנקודה המקסימלית להגדרה. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Maxpoint Object With Value(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | הצבע של הנקודה המקסימלית שרוצים להגדיר. |
type | Interpolation | סוג האינטרפולציה של נקודת המקסימום להגדרה. |
value | String | הערך של הנקודה המקסימלית שרוצים להגדיר. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Maxpoint With Value(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | הצבע של הנקודה המקסימלית שרוצים להגדיר. |
type | Interpolation | סוג האינטרפולציה של נקודת המקסימום להגדרה. |
value | String | הערך של הנקודה המקסימלית שרוצים להגדיר. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Midpoint Object With Value(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | צבע נקודת האמצע שרוצים להגדיר. |
type | Interpolation | סוג האינטרפולציה של נקודת האמצע להגדרה או null לביטול. |
value | String | ערך נקודת האמצע להגדרה. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Midpoint With Value(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | צבע נקודת האמצע שרוצים להגדיר. |
type | Interpolation | סוג האינטרפולציה של נקודת האמצע להגדרה או null לביטול. |
value | String | ערך נקודת האמצע להגדרה. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Minpoint(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | הצבע של הנקודה המינימלית שרוצים להגדיר. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Minpoint Object(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | אובייקט הצבע של הנקודה המינימלית להגדרה. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Minpoint Object With Value(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | Color | הצבע של הנקודה המינימלית שרוצים להגדיר. |
type | Interpolation | סוג האינטרפולציה של נקודת המינימום שרוצים להגדיר. |
value | String | הערך של הנקודה המינימלית שרוצים להגדיר. |
חזרה
Conditional — ה-builder, לשרשור.
set Gradient Minpoint With Value(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
color | String | הצבע של הנקודה המינימלית שרוצים להגדיר. |
type | Interpolation | סוג האינטרפולציה של נקודת המינימום שרוצים להגדיר. |
value | String | הערך של הנקודה המינימלית שרוצים להגדיר. |
חזרה
Conditional — ה-builder, לשרשור.
set Italic(italic)
מגדיר את העיצוב של כלל העיצוב המותנה לטקסט נטוי. אם italic הוא true,
הכלל יטה את הטקסט אם התנאי מתקיים. אם 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 — ה-builder, לשרשור.
set Ranges(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
ranges | Range[] | הטווחים שעליהם חל כלל העיצוב המותנה הזה. |
חזרה
Conditional — ה-builder, לשרשור.
set Strikethrough(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
strikethrough | Boolean | האם הטקסט צריך להיות עם קו חוצה אם תנאי הפורמט מתקיים. null מסיר את ההגדרה הזו. |
חזרה
Conditional — ה-builder, לשרשור.
set Underline(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
underline | Boolean | האם הטקסט צריך להיות מודגש אם מתקיים תנאי הפורמט;
null מסיר את ההגדרה הזו. |
חזרה
Conditional — ה-builder, לשרשור.
when Cell Empty()
הגדרת כלל של עיצוב מותנה שמופעל כשהתא ריק.
// 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 — ה-builder, לשרשור.
when Cell Not Empty()
הגדרת הכלל של העיצוב המותנה כך שהוא יופעל כשהתא לא ריק.
// 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 — ה-builder, לשרשור.
when Date After(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
date | Date | התאריך האחרון. |
חזרה
Conditional — ה-builder, לשרשור.
when Date After(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
date | Relative | התאריך האחרון ביחס לסוג התאריך שנבחר. |
חזרה
Conditional — ה-builder, לשרשור.
when Date Before(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
date | Date | התאריך המוקדם ביותר שלא קביל. |
חזרה
Conditional — ה-builder, לשרשור.
when Date Before(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
date | Relative | התאריך האחרון ביחס לסוג התאריך שנבחר. |
חזרה
Conditional — ה-builder, לשרשור.
when Date Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
date | Date | התאריך היחיד שניתן להשתמש בו. |
חזרה
Conditional — ה-builder, לשרשור.
when Date Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
date | Relative | התאריך האחרון ביחס לסוג התאריך שנבחר. |
חזרה
Conditional — ה-builder, לשרשור.
when Formula Satisfied(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
formula | String | נוסחה מותאמת אישית שמחזירה את הערך true אם הקלט תקין. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Between(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
start | Number | הערך הנמוך ביותר שמתקבל. |
end | Number | הערך המקסימלי הקביל. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
number | Number | הערך הקביל היחיד. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Greater Than(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
number | Number | הערך הכי גבוה שלא קביל. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Greater Than Or Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
number | Number | הערך הנמוך ביותר שמתקבל. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Less Than(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
number | Number | הערך הכי נמוך שלא קביל. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Less Than Or Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
number | Number | הערך המקסימלי הקביל. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Not Between(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
start | Number | הערך הכי נמוך שלא קביל. |
end | Number | הערך הכי גבוה שלא קביל. |
חזרה
Conditional — ה-builder, לשרשור.
when Number Not Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
number | Number | הערך הלא קביל היחיד. |
חזרה
Conditional — ה-builder, לשרשור.
when Text Contains(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
text | String | הערך שצריך להיות בקלט. |
חזרה
Conditional — ה-builder, לשרשור.
when Text Does Not Contain(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
text | String | הערך שהקלט לא יכול להכיל. |
חזרה
Conditional — ה-builder, לשרשור.
when Text Ends With(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
text | String | הטקסט להשוואה לסוף המחרוזת. |
חזרה
Conditional — ה-builder, לשרשור.
when Text Equal To(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
text | String | הערך הקביל היחיד. |
חזרה
Conditional — ה-builder, לשרשור.
when Text Starts With(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);
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
text | String | הטקסט שמשווים לתחילת המחרוזת. |
חזרה
Conditional — ה-builder, לשרשור.
with Criteria(criteria, args)
מגדיר את הכלל של העיצוב המותנה לקריטריונים שמוגדרים על ידי ערכי 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 — ה-builder, לשרשור.