checkFormulaResult(result, allowReturnArray = false) {
        const type = typeof result;
        // number
        if (type === 'number') {
            if (isNaN(result)) {
                return FormulaError.VALUE;
            } else if (!isFinite(result)) {
                return FormulaError.NUM;
            }
            result += 0; // make -0 to 0
        } else if (type === 'object') {
            if (result instanceof FormulaError)
                return result;
            if (allowReturnArray) {
                if (result.ref) {
                    result = this.retrieveRef(result);
                }
                // Disallow union, and other unknown data types.
                // e.g. `=(A1:C1, A2:E9)` -> #VALUE!
                if (typeof result === 'object' && !Array.isArray(result) && result != null) {
                    return FormulaError.VALUE;
                }

            } else {
                if (result.ref && result.ref.row && !result.ref.from) {
                    // single cell reference
                    result = this.retrieveRef(result);
                } else if (result.ref && result.ref.from && result.ref.from.col === result.ref.to.col) {
                    // single Column reference
                    result = this.retrieveRef({
                        ref: {
                            row: result.ref.from.row, col: result.ref.from.col
                        }
                    });
                } else if (Array.isArray(result)) {
                    result = result[0][0]
                } else {
                    // array, range reference, union collections
                    return FormulaError.VALUE;
                }
            }
        }
        return result;
    }
Check and return the appropriate formula result.
@param result
@param {boolean} [allowReturnArray] - If the formula can return an array
@return {*}