You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
On a similar note, do I understand this correctly and is this an issue:
if the returned value starts with an equal sign, getValues() is supposed to return a formula (string of the formula)
however I get only the calculated value and not the formula with this function
Hi Petyo (@zWarMob), I'm able to replicate this issue and I'm doing some research into the best solution. It looks like I'll need to update our documentation to reflect that getFormula can return both strings and numbers (but not boolean values).
Regarding your second question:
if the returned value starts with an equal sign, getValues() is supposed to return a formula (string of the formula)
however I get only the calculated value and not the formula with this function
The code sample for getFormula in the documentation illustrates the difference between getFormula and getValue. It looks to me like getValue is working as intended -- getValue processes the formula in a cell and returns the formula result (not the formula). I can update the documentation for getValue to make this more clear.
I'll report back here when I've resolved both of these issues.
Activity
zWarMob commentedon Oct 17, 2024
temporary fix
convert your "string" to a string
zWarMob commentedon Oct 17, 2024
On a similar note, do I understand this correctly and is this an issue:

if the returned value starts with an equal sign, getValues() is supposed to return a formula (string of the formula)
however I get only the calculated value and not the formula with this function
AlexJerabek commentedon Oct 17, 2024
Hi Petyo (@zWarMob),
Thanks for reporting this. Alison McKay (@alison-mk), could you please investigate?
alison-mk commentedon Nov 1, 2024
Hi Petyo (@zWarMob), I'm able to replicate this issue and I'm doing some research into the best solution. It looks like I'll need to update our documentation to reflect that getFormula can return both strings and numbers (but not boolean values).
Regarding your second question:
The code sample for getFormula in the documentation illustrates the difference between getFormula and getValue. It looks to me like getValue is working as intended -- getValue processes the formula in a cell and returns the formula result (not the formula). I can update the documentation for getValue to make this more clear.
I'll report back here when I've resolved both of these issues.
Thanks!
Alison
alison-mk commentedon Jan 27, 2026
This bug has been reported internally. Internal tracking number: 11027622.