我正在尝试通过 Office-JS 将条件突出显示添加到 Excel 中的列。我第一次使用该automate
功能,但我似乎无法让它在 Excel 中工作。
这就是自动化吐出的内容:
function main(workbook: ExcelScript.Workbook) {
let conditionalFormatting: ExcelScript.ConditionalFormat;
let selectedSheet = workbook.getActiveWorksheet();
// Change preset criteria from range A:A on selectedSheet
conditionalFormatting = selectedSheet.getRange("A:A").addConditionalFormat(ExcelScript.ConditionalFormatType.presetCriteria);
conditionalFormatting.getPreset().getFormat().getFont().setColor("#9C0006");
conditionalFormatting.getPreset().getFormat().getFill().setColor("#FFC7CE");
conditionalFormatting.getPreset().setRule({criterion: ExcelScript.ConditionalFormatPresetCriterion.duplicateValues,});
}
这是我的转录尝试:
function Do_ApplyHighlightDupsConditionalFormatting(rng) {
ConditionalFormat.rng.addConditionalFormat(ExcelScript.ConditionalFormatType.presetCriteria);
ConditionalFormat.getPreset().getFormat().getFont().setColor("#9C0006");
ConditionalFormat.getPreset().getFormat().getFill().setColor("#FFC7CE");
ConditionalFormat.getPreset().setRule({ criterion: ExcelScript.ConditionalFormatPresetCriterion.duplicateValues, });
}