Class ConditionalFormatRuleBuilder

Trình tạo quy tắcđịnh dạngcó điều kiện

Trình tạo quy tắc định dạng có điều kiện.

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

Phương thức

Phương thứcKiểu dữ liệu trả vềMô tả ngắn
build()ConditionalFormatRuleTạo một quy tắc định dạng có điều kiện từ các chế độ cài đặt được áp dụng cho trình tạo.
copy()ConditionalFormatRuleBuilderTrả về một chế độ đặt sẵn của trình tạo quy tắc với các chế độ cài đặt của quy tắc này.
getBooleanCondition()BooleanConditionTruy xuất thông tin BooleanCondition của quy tắc nếu quy tắc này sử dụng tiêu chí điều kiện boolean.
getGradientCondition()GradientConditionTruy xuất thông tin GradientCondition của quy tắc, nếu quy tắc này sử dụng tiêu chí điều kiện chuyển màu.
getRanges()Range[]Truy xuất các dải ô mà quy tắc định dạng có điều kiện này được áp dụng.
setBackground(color)ConditionalFormatRuleBuilderĐặt màu nền cho định dạng của quy tắc định dạng có điều kiện.
setBackgroundObject(color)ConditionalFormatRuleBuilderĐặt màu nền cho định dạng của quy tắc định dạng có điều kiện.
setBold(bold)ConditionalFormatRuleBuilderĐặt chế độ in đậm văn bản cho định dạng của quy tắc định dạng có điều kiện.
setFontColor(color)ConditionalFormatRuleBuilderĐặt màu phông chữ cho định dạng của quy tắc định dạng có điều kiện.
setFontColorObject(color)ConditionalFormatRuleBuilderĐặt màu phông chữ cho định dạng của quy tắc định dạng có điều kiện.
setGradientMaxpoint(color)ConditionalFormatRuleBuilderXoá giá trị điểm tối đa của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối đa trong các dải của quy tắc.
setGradientMaxpointObject(color)ConditionalFormatRuleBuilderXoá giá trị điểm tối đa của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối đa trong các dải của quy tắc.
setGradientMaxpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderĐặt các trường điểm tối đa của dải màu trong quy tắc định dạng có điều kiện.
setGradientMaxpointWithValue(color, type, value)ConditionalFormatRuleBuilderĐặt các trường điểm tối đa của dải màu trong quy tắc định dạng có điều kiện.
setGradientMidpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderĐặt các trường trung điểm của dải màu trong quy tắc định dạng có điều kiện.
setGradientMidpointWithValue(color, type, value)ConditionalFormatRuleBuilderĐặt các trường trung điểm của dải màu trong quy tắc định dạng có điều kiện.
setGradientMinpoint(color)ConditionalFormatRuleBuilderXoá giá trị điểm tối thiểu của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối thiểu trong các dải của quy tắc.
setGradientMinpointObject(color)ConditionalFormatRuleBuilderXoá giá trị điểm tối thiểu của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối thiểu trong các dải của quy tắc.
setGradientMinpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilderĐặt các trường minpoint của dải màu trong quy tắc định dạng có điều kiện.
setGradientMinpointWithValue(color, type, value)ConditionalFormatRuleBuilderĐặt các trường minpoint của dải màu trong quy tắc định dạng có điều kiện.
setItalic(italic)ConditionalFormatRuleBuilderĐặt văn bản in nghiêng cho định dạng của quy tắc định dạng có điều kiện.
setRanges(ranges)ConditionalFormatRuleBuilderĐặt một hoặc nhiều dải ô mà quy tắc định dạng có điều kiện này được áp dụng.
setStrikethrough(strikethrough)ConditionalFormatRuleBuilderĐặt hiệu ứng gạch ngang cho văn bản trong định dạng của quy tắc định dạng có điều kiện.
setUnderline(underline)ConditionalFormatRuleBuilderĐặt chế độ gạch chân văn bản cho định dạng của quy tắc định dạng có điều kiện.
whenCellEmpty()ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ô trống.
whenCellNotEmpty()ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ô không trống.
whenDateAfter(date)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ngày sau giá trị đã cho.
whenDateAfter(date)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ngày sau ngày tương đối đã cho.
whenDateBefore(date)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một ngày trước ngày đã cho.
whenDateBefore(date)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ngày trước ngày tương đối đã cho.
whenDateEqualTo(date)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ngày bằng với ngày đã cho.
whenDateEqualTo(date)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi ngày bằng với ngày tương đối đã cho.
whenFormulaSatisfied(formula)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi công thức đã cho đánh giá thành true.
whenNumberBetween(start, end)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số nằm trong khoảng hoặc là một trong hai giá trị được chỉ định.
whenNumberEqualTo(number)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số bằng với giá trị đã cho.
whenNumberGreaterThan(number)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số lớn hơn giá trị đã cho.
whenNumberGreaterThanOrEqualTo(number)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số lớn hơn hoặc bằng giá trị đã cho.
whenNumberLessThan(number)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số nhỏ hơn giá trị đã cho.
whenNumberLessThanOrEqualTo(number)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số nhỏ hơn hoặc bằng giá trị đã cho.
whenNumberNotBetween(start, end)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số không nằm trong khoảng và không phải là một trong hai giá trị được chỉ định.
whenNumberNotEqualTo(number)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi một số không bằng với giá trị đã cho.
whenTextContains(text)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào chứa giá trị đã cho.
whenTextDoesNotContain(text)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào không chứa giá trị đã cho.
whenTextEndsWith(text)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào kết thúc bằng giá trị đã cho.
whenTextEqualTo(text)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào bằng với giá trị đã cho.
whenTextStartsWith(text)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào bắt đầu bằng giá trị đã cho.
withCriteria(criteria, args)ConditionalFormatRuleBuilderĐặt quy tắc định dạng có điều kiện theo tiêu chí do các giá trị BooleanCriteria xác định, thường lấy từ criteriaarguments của một quy tắc hiện có.

Tài liệu chi tiết

build()

Tạo một quy tắc định dạng có điều kiện từ các chế độ cài đặt được áp dụng cho trình tạo.

Cầu thủ trả bóng

ConditionalFormatRule – Biểu thị quy tắc định dạng có điều kiện.


copy()

Trả về một chế độ đặt sẵn của trình tạo quy tắc với các chế độ cài đặt của quy tắc này.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo dựa trên các chế độ cài đặt của quy tắc này.


getBooleanCondition()

Truy xuất thông tin BooleanCondition của quy tắc nếu quy tắc này sử dụng tiêu chí điều kiện boolean. Nếu không, hàm này sẽ trả về 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()); }

Cầu thủ trả bóng

BooleanCondition – Đối tượng điều kiện boolean hoặc null nếu quy tắc không sử dụng điều kiện boolean.


getGradientCondition()

Truy xuất thông tin GradientCondition của quy tắc, nếu quy tắc này sử dụng tiêu chí điều kiện chuyển màu. Nếu không, hàm này sẽ trả về 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()); }

Cầu thủ trả bóng

GradientCondition – Đối tượng điều kiện chuyển màu hoặc null nếu quy tắc không sử dụng điều kiện chuyển màu.


getRanges()

Truy xuất các dải ô mà quy tắc định dạng có điều kiện này được áp dụng.

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

Cầu thủ trả bóng

Range[] – Dải ô mà quy tắc định dạng có điều kiện này được áp dụng.


setBackground(color)

Đặt màu nền cho định dạng của quy tắc định dạng có điều kiện. Việc truyền null sẽ xoá chế độ cài đặt định dạng màu nền khỏi quy tắc.

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

Thông số

TênLoạiMô tả
colorStringMàu bạn muốn hoặc null để xoá.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setBackgroundObject(color)

Đặt màu nền cho định dạng của quy tắc định dạng có điều kiện. Việc truyền null sẽ xoá chế độ cài đặt định dạng màu nền khỏi quy tắc.

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

Thông số

TênLoạiMô tả
colorColorĐối tượng màu hoặc null bạn muốn xoá.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setBold(bold)

Đặt chế độ in đậm văn bản cho định dạng của quy tắc định dạng có điều kiện. Nếu boldtrue, quy tắc sẽ in đậm văn bản nếu điều kiện được đáp ứng; nếu false, quy tắc sẽ xoá mọi văn bản in đậm hiện có nếu điều kiện được đáp ứng. Truyền vào null sẽ xoá chế độ cài đặt định dạng in đậm khỏi quy tắc.

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

Thông số

TênLoạiMô tả
boldBooleanVăn bản có được in đậm hay không nếu điều kiện định dạng được đáp ứng; null sẽ xoá chế độ cài đặt này.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setFontColor(color)

Đặt màu phông chữ cho định dạng của quy tắc định dạng có điều kiện. Truyền vào null sẽ xoá chế độ cài đặt định dạng màu phông chữ khỏi quy tắc.

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

Thông số

TênLoạiMô tả
colorStringMàu bạn muốn hoặc null để xoá.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setFontColorObject(color)

Đặt màu phông chữ cho định dạng của quy tắc định dạng có điều kiện. Truyền vào null sẽ xoá chế độ cài đặt định dạng màu phông chữ khỏi quy tắc.

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

Thông số

TênLoạiMô tả
colorColorĐối tượng màu hoặc null bạn muốn xoá.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMaxpoint(color)

Xoá giá trị điểm tối đa của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối đa trong các dải của quy tắc. Đồng thời đặt màu điểm lớn nhất của độ dốc thành màu đầu vào.

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

Thông số

TênLoạiMô tả
colorStringMàu điểm tối đa cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMaxpointObject(color)

Xoá giá trị điểm tối đa của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối đa trong các dải của quy tắc. Đồng thời đặt màu điểm lớn nhất của độ dốc thành màu đầu vào.

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

Thông số

TênLoạiMô tả
colorColorĐối tượng màu maxpoint cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMaxpointObjectWithValue(color, type, value)

Đặt các trường điểm tối đa của dải màu trong quy tắc định dạng có điều kiện.

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

Thông số

TênLoạiMô tả
colorColorMàu điểm tối đa cần đặt.
typeInterpolationTypeLoại nội suy maxpoint cần đặt.
valueStringGiá trị điểm tối đa cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMaxpointWithValue(color, type, value)

Đặt các trường điểm tối đa của dải màu trong quy tắc định dạng có điều kiện.

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

Thông số

TênLoạiMô tả
colorStringMàu điểm tối đa cần đặt.
typeInterpolationTypeLoại nội suy maxpoint cần đặt.
valueStringGiá trị điểm tối đa cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMidpointObjectWithValue(color, type, value)

Đặt các trường trung điểm của dải màu trong quy tắc định dạng có điều kiện. Xoá tất cả các trường điểm giữa nếu loại nội suy được truyền vào là 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);

Thông số

TênLoạiMô tả
colorColorMàu điểm trung bình cần đặt.
typeInterpolationTypeLoại nội suy điểm giữa cần đặt hoặc null để xoá.
valueStringGiá trị trung điểm cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMidpointWithValue(color, type, value)

Đặt các trường trung điểm của dải màu trong quy tắc định dạng có điều kiện. Xoá tất cả các trường điểm giữa nếu loại nội suy được truyền vào là 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);

Thông số

TênLoạiMô tả
colorStringMàu điểm trung bình cần đặt.
typeInterpolationTypeLoại nội suy điểm giữa cần đặt hoặc null để xoá.
valueStringGiá trị trung điểm cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMinpoint(color)

Xoá giá trị điểm tối thiểu của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối thiểu trong các dải của quy tắc. Đồng thời đặt màu điểm nhỏ nhất của độ dốc thành màu đầu vào.

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

Thông số

TênLoạiMô tả
colorStringMàu điểm nhỏ nhất cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMinpointObject(color)

Xoá giá trị điểm tối thiểu của dải màu trong quy tắc định dạng có điều kiện và thay vào đó, sử dụng giá trị tối thiểu trong các dải của quy tắc. Đồng thời đặt màu điểm nhỏ nhất của độ dốc thành màu đầu vào.

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

Thông số

TênLoạiMô tả
colorColorĐối tượng màu minpoint cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMinpointObjectWithValue(color, type, value)

Đặt các trường minpoint của dải màu trong quy tắc định dạng có điều kiện.

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

Thông số

TênLoạiMô tả
colorColorMàu điểm nhỏ nhất cần đặt.
typeInterpolationTypeLoại nội suy minpoint cần đặt.
valueStringGiá trị điểm nhỏ nhất cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setGradientMinpointWithValue(color, type, value)

Đặt các trường minpoint của dải màu trong quy tắc định dạng có điều kiện.

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

Thông số

TênLoạiMô tả
colorStringMàu điểm nhỏ nhất cần đặt.
typeInterpolationTypeLoại nội suy minpoint cần đặt.
valueStringGiá trị điểm nhỏ nhất cần đặt.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setItalic(italic)

Đặt văn bản in nghiêng cho định dạng của quy tắc định dạng có điều kiện. Nếu italictrue, quy tắc sẽ in nghiêng văn bản nếu điều kiện được đáp ứng; nếu false, quy tắc sẽ xoá mọi kiểu in nghiêng hiện có nếu điều kiện được đáp ứng. Truyền vào null sẽ xoá chế độ cài đặt định dạng in nghiêng khỏi quy tắc.

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

Thông số

TênLoạiMô tả
italicBooleanVăn bản có nên được in nghiêng hay không nếu điều kiện định dạng được đáp ứng; null sẽ xoá chế độ cài đặt này.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setRanges(ranges)

Đặt một hoặc nhiều dải ô mà quy tắc định dạng có điều kiện này được áp dụng. Thao tác này sẽ thay thế mọi dải ô hiện có. Việc đặt một mảng trống sẽ xoá mọi dải ô hiện có. Một quy tắc phải có ít nhất một dải ô.

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

Thông số

TênLoạiMô tả
rangesRange[]Các dải ô mà quy tắc định dạng có điều kiện này được áp dụng.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setStrikethrough(strikethrough)

Đặt hiệu ứng gạch ngang cho văn bản trong định dạng của quy tắc định dạng có điều kiện. Nếu strikethroughtrue, quy tắc sẽ gạch ngang văn bản nếu điều kiện được đáp ứng; nếu là false, quy tắc sẽ xoá mọi định dạng gạch ngang hiện có nếu điều kiện được đáp ứng. Truyền vào null sẽ xoá chế độ cài đặt định dạng gạch ngang khỏi quy tắc.

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

Thông số

TênLoạiMô tả
strikethroughBooleanCó nên gạch ngang văn bản hay không nếu điều kiện định dạng được đáp ứng; null sẽ xoá chế độ cài đặt này.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


setUnderline(underline)

Đặt chế độ gạch chân văn bản cho định dạng của quy tắc định dạng có điều kiện. Nếu underlinetrue, quy tắc sẽ gạch chân văn bản nếu điều kiện được đáp ứng; nếu false, quy tắc sẽ xoá mọi dấu gạch chân hiện có nếu điều kiện được đáp ứng. Truyền vào null sẽ xoá chế độ cài đặt định dạng gạch chân khỏi quy tắc.

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

Thông số

TênLoạiMô tả
underlineBooleanVăn bản có được gạch chân hay không nếu điều kiện định dạng được đáp ứng; null sẽ xoá chế độ cài đặt này.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenCellEmpty()

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ô trống.

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

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenCellNotEmpty()

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ô không trống.

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

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenDateAfter(date)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ngày sau giá trị đã cho.

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

Thông số

TênLoạiMô tả
dateDateNgày mới nhất.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenDateAfter(date)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ngày sau ngày tương đối đã cho.

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

Thông số

TênLoạiMô tả
dateRelativeDateNgày mới nhất so với loại ngày đã chọn.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenDateBefore(date)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một ngày trước ngày đã cho.

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

Thông số

TênLoạiMô tả
dateDateNgày sớm nhất không được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenDateBefore(date)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ngày trước ngày tương đối đã cho.

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

Thông số

TênLoạiMô tả
dateRelativeDateNgày mới nhất so với loại ngày đã chọn.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenDateEqualTo(date)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ngày bằng với ngày đã cho.

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

Thông số

TênLoạiMô tả
dateDateNgày duy nhất được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenDateEqualTo(date)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi ngày bằng với ngày tương đối đã cho.

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

Thông số

TênLoạiMô tả
dateRelativeDateNgày mới nhất so với loại ngày đã chọn.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenFormulaSatisfied(formula)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi công thức đã cho đánh giá thành 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);

Thông số

TênLoạiMô tả
formulaStringMột công thức tuỳ chỉnh đánh giá là true nếu dữ liệu đầu vào hợp lệ.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberBetween(start, end)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số nằm trong khoảng hoặc là một trong hai giá trị được chỉ định.

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

Thông số

TênLoạiMô tả
startNumberGiá trị thấp nhất có thể chấp nhận.
endNumberGiá trị cao nhất có thể chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberEqualTo(number)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số bằng với giá trị đã cho.

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

Thông số

TênLoạiMô tả
numberNumberGiá trị duy nhất được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberGreaterThan(number)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số lớn hơn giá trị đã cho.

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

Thông số

TênLoạiMô tả
numberNumberGiá trị cao nhất không được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberGreaterThanOrEqualTo(number)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số lớn hơn hoặc bằng giá trị đã cho.

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

Thông số

TênLoạiMô tả
numberNumberGiá trị thấp nhất có thể chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberLessThan(number)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số nhỏ hơn giá trị đã cho.

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

Thông số

TênLoạiMô tả
numberNumberGiá trị thấp nhất không được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberLessThanOrEqualTo(number)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số nhỏ hơn hoặc bằng giá trị đã cho.

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

Thông số

TênLoạiMô tả
numberNumberGiá trị cao nhất có thể chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberNotBetween(start, end)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số không nằm trong khoảng và không phải là một trong hai giá trị được chỉ định.

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

Thông số

TênLoạiMô tả
startNumberGiá trị thấp nhất không được chấp nhận.
endNumberGiá trị cao nhất không được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenNumberNotEqualTo(number)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi một số không bằng với giá trị đã cho.

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

Thông số

TênLoạiMô tả
numberNumberGiá trị duy nhất không được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenTextContains(text)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào chứa giá trị đã cho.

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

Thông số

TênLoạiMô tả
textStringGiá trị mà dữ liệu đầu vào phải chứa.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenTextDoesNotContain(text)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào không chứa giá trị đã cho.

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

Thông số

TênLoạiMô tả
textStringGiá trị mà dữ liệu đầu vào không được chứa.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenTextEndsWith(text)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào kết thúc bằng giá trị đã cho.

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

Thông số

TênLoạiMô tả
textStringVăn bản cần so sánh với phần cuối của chuỗi.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenTextEqualTo(text)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào bằng với giá trị đã cho.

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

Thông số

TênLoạiMô tả
textStringGiá trị duy nhất được chấp nhận.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


whenTextStartsWith(text)

Đặt quy tắc định dạng có điều kiện để kích hoạt khi dữ liệu đầu vào bắt đầu bằng giá trị đã cho.

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

Thông số

TênLoạiMô tả
textStringVăn bản cần so sánh với phần đầu của chuỗi.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.


withCriteria(criteria, args)

Đặt quy tắc định dạng có điều kiện theo tiêu chí do các giá trị BooleanCriteria xác định, thường lấy từ criteriaarguments của một quy tắc hiện có.

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

Thông số

TênLoạiMô tả
criteriaBooleanCriteriaLoại tiêu chí định dạng có điều kiện.
argsObject[]Một mảng các đối số phù hợp với loại tiêu chí; số lượng đối số và loại đối số tương ứng với phương thức when...() tương ứng ở trên.

Cầu thủ trả bóng

ConditionalFormatRuleBuilder – Trình tạo, để liên kết.