TypeError !CompObj is not a function #504
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#504
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?
Getting the above error with the following code:
Also when I try the official demo with the same file, the error pops up in the console.
The file is not corrupted and it happens with all files of the same type.
Any ideas?
Is the file that you're trying to process with SheetsJS already opened in MS Excel? If so, close the file in Excel and try again. I only get that error if it's already open in Excel and I try doing something to the same excel file in SheetsJS.
You don't say! I will definitely check that later, there is a good chance I had it open when running the process!
Probably should open a new request for an addition to the error message like "TypeError !CompObj is not a function. Is the file open by MS Excel"
Somehow
TypeError !CompObj is not a function
might also disappear if an Excel file is resaved by LibreOffice (File → Save a copy).Here's a ZIP attachment containing
Santek.xls
(which causes such TypeError) andSantek_LO.xls
(resaved from LibreOffice, does not cause any errors).There's also a visible difference in size:
Santek.xls
is 5939 bytes whileSantek_LO.xls
is 17920 bytes.That
Santek.xls
might serve as a sample for anyone willing to debug such TypeError's original cause.@JanSchuermannPH @chaostheory @Mithgol thanks for the followup!
This is a pre-BIFF5 XLS file. The error is coming because of a change in nodejs behavior :/
Long story short, in the actual
parse_xlscfb
function https://github.com/SheetJS/js-xlsx/blob/master/bits/81_xls.js#L630 the expected input data is either a CFB container or an augmented Buffer. The code checks if the data is a buffer by searching for thefind
key:https://github.com/SheetJS/js-xlsx/blob/master/bits/81_xls.js#L635
As it turns out, node later added Buffer.find:
So the first fix is to change how the data is tested. There are probably more missing records that need to be supported, but thanks @Mithgol for providing a sample!
@SheetJSDev Would
Buffer.isBuffer
work on augmented Buffers?@Mithgol That's one approach, but I'm leaning towards tweaking the CFB parser to add a unique field and check for that.
@chaostheory newer versions of excel are not capable of generating BIFF2-4 files. They use a newer format (BIFF5 or BIFF8) which is why re-saving the file seems to fix the issue.
@JanSchuermannPH @Mithgol as part of this fix, we also added direct BIFF2 exports and filled some missing record types. The updated write script generates an xls file compatible with Excel 2.0