Class BooleanCondition

BooleanCondition

يمكنك الوصول إلى الشروط المنطقية في ConditionalFormatRules. يمكن أن تحتوي كل قاعدة تنسيق شرطي على شرط منطقي واحد. يتضمّن الشرط المنطقي نفسه معايير منطقية (مع قيم) وإعدادات التنسيق. يتم تقييم المعايير مقابل محتوى الخلية، ما يؤدي إلى ظهور القيمة true أو false. إذا تم تقييم المعايير على أنّها true، يتم تطبيق إعدادات التنسيق الخاصة بالشرط على الخلية.

الطُرق

الطريقةنوع القيمة التي يتم إرجاعهاوصف قصير
getBackgroundObject()Color|nullتعرض هذه السمة لون الخلفية لشرط القيمة المنطقية هذا.
getBold()Boolean|nullتعرِض true إذا كان شرط القيمة المنطقية هذا يبرز النص، وتعرض false إذا كان شرط القيمة المنطقية هذا يزيل التمييز من النص.
getCriteriaType()BooleanCriteriaتعرض هذه السمة نوع معايير القاعدة كما هو محدّد في التعداد BooleanCriteria.
getCriteriaValues()Object[]تعرض هذه الدالة مصفوفة من وسيطات معايير القاعدة.
getFontColorObject()Color|nullتعرض هذه السمة لون الخط لشرط القيمة المنطقية هذا.
getItalic()Boolean|nullتعرض القيمة true إذا كان هذا الشرط المنطقي يميل النص، وتعرض القيمة false إذا كان هذا الشرط المنطقي يزيل الميل من النص.
getStrikethrough()Boolean|nullتعرِض true إذا كان هذا الشرط المنطقي يشطب النص، وتعرض false إذا كان هذا الشرط المنطقي يزيل الشطب من النص.
getUnderline()Boolean|nullتعرض هذه السمة القيمة true إذا كان الشرط المنطقي يضع خطًا تحت النص، وتعرض القيمة false إذا كان الشرط المنطقي يزيل الخط من تحت النص.

مستندات تفصيلية

getBackgroundObject()

تعرض هذه السمة لون الخلفية لشرط القيمة المنطقية هذا. تعرِض الدالة القيمة null إذا لم يتم ضبطها.

// Logs the boolean condition background color for each conditional format rule
// on a sheet.
const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
for (const rule of rules) {
  const color = rule.getBooleanCondition().getBackgroundObject();
  Logger.log(`Background color: ${color.asRgbColor().asHexString()}`);
}

الإرجاع

Color|null — لون الخلفية، أو null إذا لم يتم ضبطه لهذا الشرط.


getBold()

تعرِض true إذا كان شرط القيمة المنطقية هذا يبرز النص، وتعرض false إذا كان شرط القيمة المنطقية هذا يزيل التمييز من النص. تعرِض null إذا لم يتأثّر النص الغامق.

// Logs the boolean condition font weight for each conditional format rule on a
// sheet.
const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
for (const rule of rules) {
  const bold = rule.getBooleanCondition().getBold();
  Logger.log(`Bold: ${bold}`);
}

الإرجاع

Boolean|null: ما إذا كان الشرط المنطقي يغمّق النص أم لا، أو null إذا لم يتأثّر التغميق


getCriteriaType()

تعرض هذه السمة نوع معايير القاعدة كما هو محدّد في التعداد BooleanCriteria. للحصول على وسيطات المعايير، استخدِم getCriteriaValues(). لمعرفة كيفية استخدام هذه القيم لإنشاء قاعدة تنسيق مشروط أو تعديلها، اطّلِع على ConditionalFormatRuleBuilder.withCriteria(criteria, args).

// Log information about the conditional formats on the active sheet that use
// boolean conditions.

const formats = SpreadsheetApp.getActiveSheet.getConditionalFormats();
SpreadsheetApp.getActiveSheet.getConditionalFormats().forEach((format) => {
  const booleanCondition = format.getBooleanCondition();
  if (booleanCondition) {
    const criteria = booleanCondition.getCriteriaType();
    const args = booleanCondition.getCriteriaValues();
    Logger.log(`The conditional format rule is ${criteria} ${args}`);
  }
});

الإرجاع

BooleanCriteria: نوع معايير التنسيق الشرطي.


getCriteriaValues()

تعرض هذه الدالة مصفوفة من وسيطات معايير القاعدة. للحصول على نوع المعايير، استخدِم getCriteriaType(). لاستخدام هذه القيم لإنشاء قاعدة تنسيق شرطي أو تعديلها، راجِع ConditionalFormatRuleBuilder.withCriteria(criteria, args).

// Log information about the conditional formats on the active sheet that use
// boolean conditions.

const formats = SpreadsheetApp.getActiveSheet.getConditionalFormats();
SpreadsheetApp.getActiveSheet.getConditionalFormats().forEach((format) => {
  const booleanCondition = format.getBooleanCondition();
  if (booleanCondition) {
    const criteria = booleanCondition.getCriteriaType();
    const args = booleanCondition.getCriteriaValues();
    Logger.log(`The conditional format rule is ${criteria} ${args}`);
  }
});

الإرجاع

Object[] — مصفوفة من الوسيطات المناسبة لنوع معايير القاعدة، ويتطابق عدد الوسيطات ونوعها مع طريقة when...() المقابلة لفئة ConditionalFormatRuleBuilder.


getFontColorObject()

تعرض هذه السمة لون الخط لشرط القيمة المنطقية هذا. تعرِض الدالة القيمة null إذا لم يتم ضبطها.

// Logs the boolean condition font color for each conditional format rule on a
// sheet.
const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
for (const rule of rules) {
  const color = rule.getBooleanCondition().getFontColorObject();
  Logger.log(`Font color: ${color.asRgbColor().asHexString()}`);
}

الإرجاع

Color|null: لون الخط، أو null إذا لم يتم ضبطه لهذا الشرط.


getItalic()

تعرض true إذا كان هذا الشرط المنطقي يميل النص، وتعرض false إذا كان هذا الشرط المنطقي يزيل الميل من النص. تعرِض null إذا لم تتأثّر الخطوط المائلة.

// Logs the boolean condition font style for each conditional format rule on a
// sheet.
const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
for (const rule of rules) {
  const italic = rule.getBooleanCondition().getItalic();
  Logger.log(`Italic: ${italic}`);
}

الإرجاع

Boolean|null: تحدّد ما إذا كان الشرط المنطقي يجعل النص مائلاً أم لا، أو null إذا لم يتأثر النص بالميلان


getStrikethrough()

تعرِض true إذا كان هذا الشرط المنطقي يشطب النص، وتعرض false إذا كان هذا الشرط المنطقي يزيل الشطب من النص. لا تتأثر المرتجعات null إذا لم يتأثر التشطيب.

// Logs the boolean condition strikethrough setting for each conditional format
// rule on a sheet.
const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
for (const rule of rules) {
  const strikethrough = rule.getBooleanCondition().getStrikethrough();
  Logger.log(`Strikethrough: ${strikethrough}`);
}

الإرجاع

Boolean|null: ما إذا كان الشرط المنطقي يشطب النص أم لا، أو null إذا لم يتأثر النص بالشطب


getUnderline()

تعرض هذه السمة القيمة true إذا كان الشرط المنطقي يضع خطًا تحت النص، وتعرض القيمة false إذا كان الشرط المنطقي يزيل الخط من تحت النص. تعرِض null إذا لم يتأثّر التسطير.

// Logs the boolean condition underline setting for each conditional format rule
// on a sheet.
const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
for (const rule of rules) {
  const underline = rule.getBooleanCondition().getUnderline();
  Logger.log(`Underline: ${underline}`);
}

الإرجاع

Boolean|null: تحدّد ما إذا كان الشرط المنطقي يضع خطًا تحت النص أم لا، أو null إذا لم يتأثر النص بالخط

الطُرق المتوقّفة