hyperformula
Version:
HyperFormula is a JavaScript engine for efficient processing of spreadsheet-like data and formulas
35 lines • 1.19 kB
JavaScript
/**
* @license
* Copyright (c) 2025 Handsoncode. All rights reserved.
*/
import { CellError, ErrorType } from "../../Cell.mjs";
import { ErrorMessage } from "../../error-message.mjs";
import { FunctionPlugin } from "../index.mjs";
import { FunctionArgumentType } from "./FunctionPlugin.mjs";
export class FormulaTextPlugin extends FunctionPlugin {
/**
* Corresponds to FORMULATEXT(value)
*
* Returns a formula in a given cell as a string.
*
* @param ast
* @param state
*/
formulatext(ast, state) {
return this.runFunctionWithReferenceArgument(ast.args, state, this.metadata('FORMULATEXT'), () => new CellError(ErrorType.NA, ErrorMessage.WrongArgNumber), cellReference => {
var _a;
return (_a = this.serialization.getCellFormula(cellReference)) !== null && _a !== void 0 ? _a : new CellError(ErrorType.NA, ErrorMessage.Formula);
});
}
}
FormulaTextPlugin.implementedFunctions = {
'FORMULATEXT': {
method: 'formulatext',
parameters: [{
argumentType: FunctionArgumentType.NOERROR
}],
doesNotNeedArgumentsToBeComputed: true,
isDependentOnSheetStructureChange: true,
vectorizationForbidden: true
}
};