"array" type does not support Uint8Array #620
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#620
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been having problems using a Uint8Array as data for XLSX.read (using type as 'array').
It's throwing an error when trying to read the signature header of the file. I've checked the array against the signature and everything seemed fined.
I've tracked down the issue to __hexlify which tries to convert the first few bytes into a string but fails to do it correctly.
I have an example of the problem here : https://jsfiddle.net/dullin/hchgjs4g/1/
I've currently circumvented the problem by formating my data as a node Buffer which uses it's version of toString instead of the problematic code.
@dullin So this is a funny issue that boils down to the semantics of typedarray: http://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype.map
The
array
mode assumes Array semantics wherebymap
returns an untyped array, but typed arrays return a typed array. This means you can't do things like map from an array of numbers to an array of strings:When working with typed arrays like those coming from
readAsArrayBuffer
, as explained in the wiki and shown in the drag-and-drop sample in the README the web demo pre-processes typed arrays.We do that type of conversion (mapping from an array of one type to an array of another type) in multiple places :( In this case, we can either add a new input type
typedarray
or restrictarray
to only use features that are supported by both arrays and typed arrays.ping @aymkdn any thoughts?
Wow!
I must admit I'm still new to javascript so didn't know the difference between typed and untyped arrays.
Thank you for the thorough and educational explication!
@dullin typed arrays are relatively new (IE10+, specced in ES6 but not ES5). If you are in node you are better off sticking with
Buffer
(and the"buffer"
type)