OfficeDev / OfficeDev/office-scripts-docs-reference

Range.getFormula() invalid return type

Open
#365 5 comments 0 reactions 1 assignee View on GitHub

@alison-mk is already working on this.

Since Oct 17, 2024.

Status: in backlog Type: product bug
Dominant language
TypeScript
Stars
71
Forks
36
Avg merge
4d 14h
Merged PRs (30d)
12

Description

Article URL
ExcelScript.Range interface - getFormula()

Describe the problem
Documentation (and the interface itself) suggests getFormula() is supposed to return a string.
Not the case.. getFormula() behaves like getValue() and can return non-string values

let sheet = workbook.getWorksheet("Env.data");
[ . . . ]
let aQ = sheet .getCell(1, 1);
let qFormula: string = aQ.getFormula();
try{
  qFormula = qFormula.startsWith('=') ? qFormula.slice(1) : qFormula;
}catch(e){
  console.log(typeof(qFormula));
  console.log(qFormula);
  throw e;
}

logs and error:

number
0
qFormula.startsWith is not a function

Screenshots
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.