เครื่องมือสร้างสําหรับกฎการจัดรูปแบบตามเงื่อนไข
// 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 | ตั้งค่าการทําข้อความเป็นตัวหนาสําหรับรูปแบบกฎแบบมีเงื่อนไข's |
setFontColor(color) | ConditionalFormatRuleBuilder | ตั้งค่าสีแบบอักษรสําหรับรูปแบบกฎแบบมีเงื่อนไข's |
setFontColorObject(color) | ConditionalFormatRuleBuilder | ตั้งค่าสีแบบอักษรสําหรับรูปแบบกฎแบบมีเงื่อนไข's |
setGradientMaxpoint(color) | ConditionalFormatRuleBuilder | ล้างกฎการจัดรูปแบบจุดสูงสุดของกฎแบบมีเงื่อนไข และใช้ค่าสูงสุดในช่วงของกฎแทน |
setGradientMaxpointObject(color) | ConditionalFormatRuleBuilder | ล้างกฎการจัดรูปแบบจุดสูงสุดของกฎแบบมีเงื่อนไข และใช้ค่าสูงสุดในช่วงของกฎแทน |
setGradientMaxpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | ตั้งค่าช่องรูปแบบการไล่ระดับสีของกฎแบบมีเงื่อนไข |
setGradientMaxpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | ตั้งค่าช่องรูปแบบการไล่ระดับสีของกฎแบบมีเงื่อนไข |
setGradientMidpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | ตั้งค่าช่องรูปแบบไล่ระดับสีตามกฎของเงื่อนไข |
setGradientMidpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | ตั้งค่าช่องรูปแบบไล่ระดับสีตามกฎของเงื่อนไข |
setGradientMinpoint(color) | ConditionalFormatRuleBuilder | ล้างกฎการจัดรูปแบบจุดแบบมีเงื่อนไขของกฎแบบมีเงื่อนไข และใช้ค่าต่ําสุด ในช่วงของกฎแทน |
setGradientMinpointObject(color) | ConditionalFormatRuleBuilder | ล้างกฎการจัดรูปแบบจุดแบบมีเงื่อนไขของกฎแบบมีเงื่อนไข และใช้ค่าต่ําสุด ในช่วงของกฎแทน |
setGradientMinpointObjectWithValue(color, type, value) | ConditionalFormatRuleBuilder | ตั้งค่ากฎการจัดรูปแบบช่องของเงื่อนไขแบบมีเงื่อนไข |
setGradientMinpointWithValue(color, type, value) | ConditionalFormatRuleBuilder | ตั้งค่ากฎการจัดรูปแบบช่องของเงื่อนไขแบบมีเงื่อนไข |
setItalic(italic) | ConditionalFormatRuleBuilder | ตั้งค่าตัวเอียงของข้อความสําหรับรูปแบบกฎแบบมีเงื่อนไข |
setRanges(ranges) | ConditionalFormatRuleBuilder | ตั้งค่าช่วงอย่างน้อย 1 ช่วงที่จะนํากฎรูปแบบตามเงื่อนไขนี้ไปใช้ |
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 | ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อมีตัวเลขอยู่ระหว่าง หรือเป็นค่าใดค่าหนึ่งจาก 2 ค่า |
whenNumberEqualTo(number) | ConditionalFormatRuleBuilder | ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อตัวเลขเท่ากับค่าที่ระบุ |
whenNumberGreaterThan(number) | ConditionalFormatRuleBuilder | ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อตัวเลขมีค่ามากกว่าค่าที่ระบุ |
whenNumberGreaterThanOrEqualTo(number) | ConditionalFormatRuleBuilder | ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อตัวเลขมากกว่าหรือเท่ากับค่าที่ระบุ |
whenNumberLessThan(number) | ConditionalFormatRuleBuilder | ตั้งค่ากฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อมีค่าน้อยกว่าค่าที่ระบุ |
whenNumberLessThanOrEqualTo(number) | ConditionalFormatRuleBuilder | ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อจํานวนน้อยกว่าหรือเท่ากับค่าที่ระบุ |
whenNumberNotBetween(start, end) | ConditionalFormatRuleBuilder | ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อตัวเลขไม่อยู่ระหว่าง และไม่มีค่าที่ระบุ 2 ค่า |
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)
ตั้งค่าการทําข้อความเป็นตัวหนาสําหรับรูปแบบกฎแบบมีเงื่อนไข's หาก 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)
ตั้งค่าสีแบบอักษรสําหรับรูปแบบกฎแบบมีเงื่อนไข's การส่ง 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)
ตั้งค่าสีแบบอักษรสําหรับรูปแบบกฎแบบมีเงื่อนไข's การส่ง 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)
ล้างกฎการจัดรูปแบบจุดสูงสุดของกฎแบบมีเงื่อนไข และใช้ค่าสูงสุดในช่วงของกฎแทน และยังตั้งค่าสีจุดสูงสุดของการไล่ระดับสีเป็น #39;
// 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)
ล้างกฎการจัดรูปแบบจุดสูงสุดของกฎแบบมีเงื่อนไข และใช้ค่าสูงสุดในช่วงของกฎแทน และยังตั้งค่าสีจุดสูงสุดของการไล่ระดับสีเป็น #39;
// 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)
ตั้งค่าช่องรูปแบบการไล่ระดับสีของกฎแบบมีเงื่อนไข
// 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 | ประเภทการประมาณจุดสูงสุดที่จะตั้งค่า |
value | String | ค่าสูงสุดที่กําหนด |
ไปกลับ
ConditionalFormatRuleBuilder
— เครื่องมือสร้างสําหรับเชน
setGradientMaxpointWithValue(color, type, value)
ตั้งค่าช่องรูปแบบการไล่ระดับสีของกฎแบบมีเงื่อนไข
// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to set their // background color somewhere from red green to blue, based on their values in comparison to // the values 0, 50, and 100. 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
— เครื่องมือสร้างสําหรับเชน
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 | ออบเจ็กต์สี Minpoint ที่จะตั้งค่า |
ไปกลับ
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)
ตั้งค่าช่วงอย่างน้อย 1 ช่วงที่จะนํากฎรูปแบบตามเงื่อนไขนี้ไปใช้ การดําเนินการนี้จะแทนที่ช่วงที่มีอยู่ การตั้งค่าอาร์เรย์ที่ว่างเปล่าจะล้างช่วงที่มีอยู่ กฎต้องมีช่วงอย่างน้อย 1 ช่วง
// 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)
ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อมีตัวเลขอยู่ระหว่าง หรือเป็นค่าใดค่าหนึ่งจาก 2 ค่า
// 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)
ตั้งกฎรูปแบบตามเงื่อนไขให้ทริกเกอร์เมื่อตัวเลขไม่อยู่ระหว่าง และไม่มีค่าที่ระบุ 2 ค่า
// 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
— เครื่องมือสร้างสําหรับเชน