enable programmatic enum for default properties for sheet_to_json #1536

Closed
opened 2019-06-13 17:49:06 +00:00 by michaelhyman · 2 comments
michaelhyman commented 2019-06-13 17:49:06 +00:00 (Migrated from github.com)

perhaps i haven't found the right thing to try, but i would like to be able to use default values for some of the properties in sheet_to_json. e.g.

header Description
1 Generate an array of arrays ("2D Array")
"A" Row object keys are literal column labels
array of strings Use specified strings as keys in row objects
(default) Read and disambiguate first row as keys

I'd like to be able to pass the default -- read and disambiguate -- into the header property -- couldn't find a way to do so

perhaps i haven't found the right thing to try, but i would like to be able to use default values for some of the properties in sheet_to_json. e.g. header | Description -- | -- 1 | Generate an array of arrays ("2D Array") "A" | Row object keys are literal column labels array of strings | Use specified strings as keys in row objects (default) | Read and disambiguate first row as keys I'd like to be able to pass the default -- read and disambiguate -- into the header property -- couldn't find a way to do so
SheetJSDev commented 2019-07-29 10:01:30 +00:00 (Migrated from github.com)

The current implementation takes any other value as default, as represented in the test at https://github.com/SheetJS/js-xlsx/blob/master/bits/90_utils.js#L51-L53 . The safest thing to do is to set it to null, and we'll make that the official case. If you'd like to submit a PR, the fix would be adding a line just after line 53, something like

	else if(o.header == null) header = 0;
The current implementation takes any other value as default, as represented in the test at https://github.com/SheetJS/js-xlsx/blob/master/bits/90_utils.js#L51-L53 . The safest thing to do is to set it to `null`, and we'll make that the official case. If you'd like to submit a PR, the fix would be adding a line just after line 53, something like ```js else if(o.header == null) header = 0; ```
SheetJSDev commented 2019-09-04 02:11:18 +00:00 (Migrated from github.com)

fixed in ee862e3adf

fixed in ee862e3adfd927175a573ee9198eb395d0159cf2
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1536
No description provided.