Skip to content

Errors should be parsed from string and propagated #63

Description

@wojciechczerniak

Description

Errors entered by the user or included in the data source are not parsed as Error. They are interpreted as a string value.

Error syntax

Error ::= '#' [A-Z0-9]+ ([!?] | ('/' ([A-Z] | ([0-9] [!?]))))

Error types

Name Comments
#DIV/0! Attempt to divide by zero, including division by an empty cell. ERROR.TYPE of 2 6.13.11
#NAME? Unrecognized/deleted name. ERROR.TYPE of 5.
#N/A Not available. ISNA() applied to this value will return TRUE. Lookup functions that failed, and NA(), return this value. ERROR.TYPE of 7.
#NULL! Intersection of ranges produced zero cells. ERROR.TYPE of 1.
#NUM! Failed to meet domain constraints (e.g., input was too large or too small). ERROR.TYPE of 6.
#REF! Reference to invalid cell (e.g., beyond the application’s abilities). ERROR.TYPE of 4.
#VALUE! Parameter is wrong type. ERROR.TYPE of 3.

ODFF 1.3 spec

Spec says it's optional:

Evaluators may allow entry of errors directly, parse them and recognize them as Errors. Functions shall propagate Errors unless stated otherwise.

Although, both XL and GS parse them according to spec. LC does it if = is present.

Example test

it('Errors should be parsed and propagated', () => {
  const engine = HyperFormula.buildFromArray([
    ['#DIV/0!', '=A1', '=ISERROR(B1)', '=ISERROR(#DIV/0!)', '=#DIV/0!'],
  ])

  expect(engine.getCellValue(adr('A1'))).toBe(new CellError(ErrorType.DIV_BY_ZERO))
  expect(engine.getCellValue(adr('B1'))).toBe(new CellError(ErrorType.DIV_BY_ZERO))
  expect(engine.getCellValue(adr('C1'))).toBe(true)
  expect(engine.getCellValue(adr('D1'))).toBe(true)
  expect(engine.getCellValue(adr('E1'))).toBe(new CellError(ErrorType.DIV_BY_ZERO))
})

Other requirements

An unknown Error name shall be mapped into an Error supported by the evaluator when read (e.g., the application's equivalent of #NAME?), though an evaluator may warn the user if this has or will take place. It is desirable to preserve the original specific Error name when writing an Error back out, where possible, but for Errors other than #N/A evaluators may write a different Error for a formula than they did when reading it. Whitespace shall not be included in an Error name.

Evaluators should use a human-comprehensible name, not a numeric id, for Error names they write.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIPublic methods and propertiesBugSomething isn't workingODFF ConformanceODDF 1.3 Evaluator requirementODFF SGEODDF 1.3 Small Group Evaluator requirement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions