JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,058 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
"
function main(workbook: ExcelScript.Workbook) {
// Your code here
//let selectedRange = workbook.getSelectedRange();
//console.log(selectedRange.getAddress());
//console.log(selectedRange.getConditionalFormat().getCustom().getFormat())
//let positive = selectedRange.getConditionalFormat().getType()
//console.log(positive)
var sheet = workbook.getActiveWorksheet();
//var cell = sheet.getRange("G2");
var cell = sheet.getRange("H2");
var conditionalFormats = cell.getConditionalFormats();
//console.log(cell.getConditionalFormat().getCustom().getFormat().getFill().getColor())
for (var i = 0; i < conditionalFormats.length; i++) {
var conditionalFormat = conditionalFormats[i];
var fill = conditionalFormat.getCustom().getFormat().getFill()
//var fill = conditionalFormat.getCustom().getFormat().
console.log("Color: " + fill.getColor())
//console.log("Color: " + fill.getColor().fontcolor())
}
}
"
Based on above script I am getting this out put however I just want the exact color of the conditional formatting in the cell.