-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Reading from buffer #337
Comments
If you have a Buffer object, you can pass it directly to XLSX.read() with no options:
If you want to read from a string, it needs to be binary-encoded (but binary strings are deprecated in Node). |
Hello, Code
Error
|
is this issue solved..?i need help here. |
Hi, this work for me. (function fixdata and btoa are the keys).
|
Passing the buffer directly to |
The read functions can take the following input types, controlled by the
The underlying file type is guessed by inspecting the first few bytes of the file. The error message
means that the read function saw a file it didn't know how to handle. That number 161 is the first byte of the file, so the library thought the file started with 0xa1. In general, it's best to make sure you explicitly state the type of data using that type field, but in nodejs the assumed input type is a Buffer. In the browser, where Buffer is not available, the default is base64. This will be added to the README. |
This is in the Input Type subsection of the Parsing Options section in the README. |
You can read data from buffers as follow var workbook = XLSX.read(buffer, {type:"buffer"}); |
I am getting `const buffers = [];
|
@tmzaragoza that looks like lambda is messing with the data. Can you test by modifying your endpoint to read as base64 ( |
Having the same problem with Lambda. @tmzaragoza did you solve this? I'll post here if we find a solution. |
@jzohrab We needed to use |
@tmzaragoza would you share your implementation? I parse data using req.file.buffer.toString('base64') and got the same trouble Error: End of data reached... |
This worked for me: import * as XLSX from "xlsx"
const workbook = XLSX.read(req.file.buffer.data, { type: "buffer" }) |
@tmzaragoza @jzohrab @tiagolabsit https://github.com/SheetJS/sheetjs/tree/master/demos/function#aws-lambda
|
Hello everyone,
I have an api that takes a excel file and I want to be able to read the buffer object in js-xlsx however I just keep getting errors.
I have tried the following
var workbook = XLSX.read(file.toString('utf-8'));
Error
Uncaught error: Unsupported file 161
var workbook = XLSX.read(file);
Error
Uncaught error: Object [object Object] has no method 'substr'
If i save the file to disk and then use xlsx.readFile with the file path it works fine..
The text was updated successfully, but these errors were encountered: