Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emty-ish values parsing #10

Closed
jansiegel opened this issue Nov 15, 2019 · 4 comments
Closed

Emty-ish values parsing #10

jansiegel opened this issue Nov 15, 2019 · 4 comments
Assignees
Milestone

Comments

@jansiegel
Copy link
Member

jansiegel commented Nov 15, 2019

HyperFormula is parsing Handsontable's commonly used empty-ish values in a way that makes them unusable in the table.

For example, passing a dataset/sheet as:
[['', ' ']] (empty string, space)
translates to:
[Symbol(), 0]

and with a null value we get the following error:

Uncaught TypeError: Cannot read property 'length' of null
    at Object.isMatrix (ParserWithCaching.ts:123)
    at HyperFormula.setMultipleCellContents (HyperFormula.ts:258)

(similar in case of undefined)

@swistak35
Copy link
Contributor

I've added possibility to handle null and undefined values. Do we want to handle numbers too (imho if we expanded to null/undefined, it make sense)?

Test:

it('handle different input types', () => {
const engine = HyperFormula.buildFromArray([['', null, undefined]])
expect(engine.getCellValue(adr('A1'))).toBe(EmptyValue)
expect(engine.getCellValue(adr('B1'))).toBe(EmptyValue)
expect(engine.getCellValue(adr('C1'))).toBe(EmptyValue)
})

Also I've fixed bug with " " being understood as number 0.

Test:

expect(cellContentParser.parse(' ')).toStrictEqual(new CellContent.String(' '))

@voodoo11
Copy link
Collaborator

After some arrangements:

  1. Empty string should be treated as CellValue
    1.1. getCellValue on such cell will return empty string
    1.2. getCellValueType will return CellValueType.STRING

  2. null will be treated as EmptyCellValue
    1.1. getCellValue will return EmptyValue
    1.2. getCellValueType will return CellValueType.EMPTY

@voodoo11 voodoo11 reopened this Nov 28, 2019
@voodoo11 voodoo11 added this to the December 2019 milestone Nov 28, 2019
@voodoo11 voodoo11 self-assigned this Nov 28, 2019
@swistak35
Copy link
Contributor

Empty string should be treated as CellValue

I think that if we are going this way, then CsvImporter for empty fields, should change empty strings to null, before constructing HyperFormula. I.e. We'd expect such CSV: ,=ISBLANK(A1) to have true in B1?

@voodoo11
Copy link
Collaborator

Done #46

@voodoo11 voodoo11 assigned jansiegel and unassigned voodoo11 Nov 29, 2019
@wojciechczerniak wojciechczerniak mentioned this issue Dec 2, 2019
89 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants