כלי לבניית כללים של עיצוב מותנה.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to turn red if // they contain a number between 1 and 10. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
שיטות
שיטה | סוג הערך שמוחזר | תיאור קצר |
---|---|---|
build() | ConditionalFormatRule | בונה כלל של עיצוב מותנה מההגדרות שהוחלו על הבונה. |
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 | מגדירה את שדות ה-maxpoint של כלל העיצוב המותנה. |
setGradientMaxpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | מגדירה את שדות ה-maxpoint של כלל העיצוב המותנה. |
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()
בונה כלל של עיצוב מותנה מההגדרות שהוחלו על הבונה.
החזרות
ConditionalFormatRule
– ייצוג של כלל העיצוב המותנה
copy()
מחזירה הגדרה קבועה מראש של יוצר הכללים עם ההגדרות של כלל זה.
החזרות
ConditionalFormatRuleBuilder
– כלי המבוסס על ההגדרות של הכלל הזה
getBooleanCondition()
אחזור של פרטי BooleanCondition
של הכלל אם הוא משתמש בקריטריונים של תנאי בוליאני. אחרת, הפונקציה מחזירה את הערך null
.
// Log the boolean criteria type of the first conditional format rules of a sheet. var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; var booleanCondition = rule.getBooleanCondition(); if (booleanCondition != null) { Logger.log(booleanCondition.getCriteriaType()); }
החזרות
BooleanCondition
- אובייקט התנאי הבוליאני, או null
אם הכלל לא משתמש בתנאי
בוליאני.
getGradientCondition()
מאחזרת את פרטי GradientCondition
של הכלל, אם הכלל הזה משתמש בקריטריונים של תנאי הדרגתי. אחרת, הפונקציה מחזירה את הערך null
.
// Log the gradient minimum color of the first conditional format rule of a sheet. var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; var gradientCondition = rule.getGradientCondition(); if (gradientCondition != null) { // Assume the color has ColorType.RGB. Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString()); }
החזרות
GradientCondition
– אובייקט התנאי של ההדרגתיות, או null
אם הכלל לא משתמש בתנאי
הדרגתי.
getRanges()
מאחזרת את הטווחים שעליהם חל כלל העיצוב המותנה הזה.
// Log each range of the first conditional format rule of a sheet. var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0]; var ranges = rule.getRanges(); for (var i = 0; i < ranges.length; i++) { Logger.log(ranges[i].getA1Notation()); }
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | הצבע הרצוי או 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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBackground(color) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | אובייקט הצבע הרצוי או null שיש לנקות. |
החזרות
ConditionalFormatRuleBuilder
– הכלי ליצירת שרשורים.
setBold(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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBold(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
bold | Boolean | אם הטקסט צריך להיות מודגש אם תנאי הפורמט מתקיים, המדיניות 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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setFontColor("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | הצבע הרצוי או 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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setFontColor(color) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | אובייקט הצבע הרצוי או null שיש לנקות. |
החזרות
ConditionalFormatRuleBuilder
– הכלי ליצירת שרשורים.
setGradientMaxpoint(color)
הפונקציה מנקה את הערך המקסימלי של נקודת האחיזה של כלל העיצוב המותנה, ובמקום זאת משתמשת בערך המקסימלי בטווחים של הכלל. כמו כן, מגדירה את צבע ה-maxpoint של ההדרגתיות לצבע הקלט.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere between white and red, based on their values in comparison to // the ranges minimum and maximum values. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint("#FF0000") .setGradientMinpoint("#FFFFFF") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | הצבע של הנקודה המקסימלית להגדרה. |
החזרות
ConditionalFormatRuleBuilder
– כלי ליצירת שרשורים
setGradientMaxpointObject(color)
הפונקציה מנקה את הערך המקסימלי של נקודת האחיזה של כלל העיצוב המותנה, ובמקום זאת משתמשת בערך המקסימלי בטווחים של הכלל. כמו כן, מגדירה את צבע ה-maxpoint של ההדרגתיות לצבע הקלט.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere between theme text and background colors, based on their values // in comparison to the ranges minimum and maximum values. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var textColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); var backgroundColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint(textColor) .setGradientMinpoint(backgroundColor) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | אובייקט הצבע maxpoint להגדרה. |
החזרות
ConditionalFormatRuleBuilder
– הכלי ליצירת שרשורים.
setGradientMaxpointObjectWithValue(color, type, value)
מגדירה את שדות ה-maxpoint של כלל העיצוב המותנה.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from theme accent 1, accent 2 to accent 3 colors, based on their // values in comparison to the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); var color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); var color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | הצבע של הנקודה המקסימלית להגדרה. |
type | InterpolationType | סוג האינטרפולציה של maxpoint שיש להגדיר. |
value | String | ערך ה-maxpoint שיש להגדיר. |
החזרות
ConditionalFormatRuleBuilder
– הכלי ליצירת שרשורים.
setGradientMaxpointWithValue(color, type, value)
מגדירה את שדות ה-maxpoint של כלל העיצוב המותנה.
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from red green to blue, based on their values in comparison to // the values 0, 50, and 100. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | הצבע של הנקודה המקסימלית להגדרה. |
type | InterpolationType | סוג האינטרפולציה של maxpoint שיש להגדיר. |
value | String | ערך ה-maxpoint שיש להגדיר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); var color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); var color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | הצבע של נקודת האמצע שיוגדר. |
type | InterpolationType | סוג האינטרפולציה של נקודת האמצע שיש להגדיר או null שיש לנקות. |
value | String | ערך נקודת האמצע שיש להגדיר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | הצבע של נקודת האמצע שיוגדר. |
type | InterpolationType | סוג האינטרפולציה של נקודת האמצע שיש להגדיר או null שיש לנקות. |
value | String | ערך נקודת האמצע שיש להגדיר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint("#FF0000") .setGradientMinpoint("#FFFFFF") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | צבע הנקודה המינימלית להגדרה. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var textColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); var backgroundColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpoint(textColor) .setGradientMinpoint(backgroundColor) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | אובייקט הצבע של הנקודה המינימלית להגדרה. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var color1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); var color2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); var color3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | Color | צבע הנקודה המינימלית להגדרה. |
type | InterpolationType | סוג האינטרפולציה של הנקודה המינימלית שצריך להגדיר. |
value | String | ערך הנקודה המינימלית להגדרה. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100") .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50") .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
color | String | צבע הנקודה המינימלית להגדרה. |
type | InterpolationType | סוג האינטרפולציה של הנקודה המינימלית שצריך להגדיר. |
value | String | ערך הנקודה המינימלית להגדרה. |
החזרות
ConditionalFormatRuleBuilder
– כלי ליצירת שרשורים
setItalic(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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setItalic(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
italic | Boolean | קביעה אם הטקסט צריך להיות נטוי אם תנאי הפורמט מתקיים,
ההגדרה הזו תוסר על ידי 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. var sheet = SpreadsheetApp.getActiveSheet(); var rangeOne = sheet.getRange("A1:B3"); var rangeTwo = sheet.getRange("D4:F6"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground("#FF0000") .setRanges([rangeOne, rangeTwo]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
ranges | Range[] | הטווחים שעליהם חל כלל הפורמט המותנה הזה. |
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setStrikethrough(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
strikethrough | Boolean | מציין אם הטקסט צריך להופיע עם קו תחתון אם התנאי של הפורמט מתקיים,
הפונקציה null מסירה את ההגדרה הזו. |
החזרות
ConditionalFormatRuleBuilder
– כלי ליצירת שרשורים
setUnderline(underline)
מגדיר טקסט עם קו תחתון לפורמט של הכלל של העיצוב המותנה. אם התנאי underline
הוא true
, הכלל מדגיש את הטקסט אם התנאי מתקיים. אם התנאי מתקיים 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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setUnderline(true) .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
underline | Boolean | מציין אם הטקסט צריך להופיע עם קו תחתון אם תנאי הפורמט מתקיים;
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenCellEmpty() .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenCellNotEmpty() .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateAfter(new Date("11/4/1993")) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
date | Date | התאריך המאוחר ביותר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
date | RelativeDate | התאריך המאוחר ביותר ביחס לסוג התאריך שנבחר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateBefore(new Date("11/4/1993")) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
date | Date | התאריך המוקדם ביותר שאינו קביל. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
date | RelativeDate | התאריך המאוחר ביותר ביחס לסוג התאריך שנבחר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateEqualTo(new Date("11/4/1993")) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
date | Date | התאריך היחיד שמקובל. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenDateEqualTo(SpreadsheetApp.RelativeDate.TODAY) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
date | RelativeDate | התאריך המאוחר ביותר ביחס לסוג התאריך שנבחר. |
החזרות
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)". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenFormulaSatisfied("=EQ(B4, C3)") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
formula | String | נוסחה מותאמת אישית שבודקת את הערך 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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
start | Number | הערך המקובל הנמוך ביותר. |
end | Number | הערך הקביל הגבוה ביותר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
number | Number | הערך הקביל היחיד. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberGreaterThan(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
number | Number | הערך הגבוה ביותר שאינו קביל. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberGreaterThanOrEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
number | Number | הערך המקובל הנמוך ביותר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberLessThan(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
number | Number | הערך הנמוך ביותר שאינו קביל. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberLessThanOrEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
number | Number | הערך הקביל הגבוה ביותר. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberNotBetween(1, 10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
start | Number | הערך הנמוך ביותר שאינו קביל. |
end | Number | הערך הגבוה ביותר שאינו קביל. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberNotEqualTo(10) .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
number | Number | הערך היחיד שאינו קביל. |
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextContains("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
text | String | הערך שהקלט חייב להכיל. |
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextDoesNotContain("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
text | String | הערך שהקלט לא יכול להכיל. |
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEndsWith("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
text | String | הטקסט להשוואה מול סוף המחרוזת. |
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextEqualTo("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
text | String | הערך הקביל היחיד. |
החזרות
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". var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:B3"); var rule = SpreadsheetApp.newConditionalFormatRule() .whenTextStartsWith("hello") .setBackground("#FF0000") .setRanges([range]) .build(); var rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
text | String | הטקסט להשוואה עם תחילת המחרוזת. |
החזרות
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. var sheet = SpreadsheetApp.getActiveSheet(); var rules = sheet.getConditionalFormatRules(); var booleanCondition = rules[0].getBooleanCondition(); if (booleanCondition != null) { var rule = SpreadsheetApp.newConditionalFormatRule() .withCriteria(booleanCondition.getCriteriaType(), booleanCondition.getCriteriaValues()) .setBackground("#000000") .setRanges(rule.getRanges()) .build(); rules.push(rule); } sheet.setConditionalFormatRules(rules);
פרמטרים
שם | תיאור | התיאור |
---|---|---|
criteria | BooleanCriteria | סוג הקריטריונים של עיצוב מותנה. |
args | Object[] | מערך של ארגומנטים שמתאים לסוג הקריטריונים, מספר הארגומנטים והסוג שלהם תואמים לשיטה when...() התואמת שלמעלה. |
החזרות
ConditionalFormatRuleBuilder
– כלי ליצירת שרשורים