Strange behavior: parse buffer works for small file, not a same file with 2000 more rows data. #604
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#604
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
hi, I am struggling with a very basic excel file. It worked for a small file (2 lines of data on "positions" tab), then it stops working after i added 2000 lines of data rows. I use connect-busboy to parse the uploaded file and get the buffer array, then use the xlsx.read(data) to read the buffer. I attached below code of getting the file stream using busboy and then tries to parse it. Can you please help out ! Many thanks!!
WS_template_small.xlsx
WS_template.xlsx
Step1: get file stream using busboy middleware: then call "getExcelData" after finish
var importFile = function (req) {
var promise = new Promise(function (resolve, reject) {
var busboyObj = new Busboy({ headers: req.headers });
var fileStream = {};
var dataResult = {};
req.pipe(req.busboy);
req.busboy.on('file', function (fieldname, file, filename) {
file.on('data', function (data) {
logging.debug('on....data'+data.length);
dataResult = data;
});
file.on('end', function () {
logging.debug('on....end'+dataResult.length);
});
});
req.busboy.on('finish', function() {
console.log('Done parsing form!'+dataResult.length);
var xlsDataTable = getExcelData(dataResult);
resolve('success');
});
Step 2: use getExcelData to parse file stream into excel. Works for WS_template_small, but not for WS_template which has 2000 more lines of rows.
function getExcelData(data) {
//logging.debug('File got ' + data.length + ' bytes');
var workbook = XLSX.read(data);
var sheet_name_list = workbook.SheetNames;
...
...}
Error i got:
Error: Unsupported file 223|165|19|18
@superkang18 I'm not familiar with
busboy
, but can you try writingdata
to a file in yourgetExcelData
function and seeing if you can open it with Excel? If this works for small files but not for larger files you may need to do some sort of buffering to grab the entire file.thanks, @SheetJSDev , will take a look from that side.
I found the issue, it's nothing to do with xlsx. I need to concatenate the buffer before passing into "read" function. thanks.