2

In Ms articles they describe how to set the Excel cell color via JavaScript API.

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getActiveWorksheet();
    let usedRange = sheet.getUsedRange();
    let formulaRanges = usedRange.getSpecialCells(Excel.SpecialCellType.formulas);
    formulaRanges.format.fill.color = "pink";

    await context.sync();
});

However, is not really clear, how to get that color. There is any "fill" field when I load the "format"

format: Object
autoIndent: false
columnWidth: 19.5
horizontalAlignment: "Left"
indentLevel: 3
readingOrder: "Context"
rowHeight: 18
shrinkToFit: false
textOrientation: 0
useStandardHeight: true
useStandardWidth: true
verticalAlignment: "Center"
wrapText: false

That is nowhere in documentation samples, as usual in MS poor docs... By testing and guessing I could achieve this:

  let rangeFill = range.format.fill;
  rangaeFill.load(["color"])

  await context.sync();
  console.log("range.format.fill.color", rangeFill.color)

However, the open question remains if there are some conditional formatting applied, how to get the final color? Because this color is one if no conditional formatting applied.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.