I'm trying to get the example working from here: https://github.com/agershun/alasql/wiki/Angular.js
Toward the bottom of the page, there's a section "Import data from file in client computer"...
That example doesn't seem to work. The error when clicking on the browse button is this:
xlsx.core.min.js:13 Uncaught TypeError: f.charCodeAt is not a function
firstbyte @ xlsx.core.min.js:13
readSync @ xlsx.core.min.js:13
(anonymous function) @ alasql.min.js:2
h.onload @ alasql.min.js:9
Would you be able supply the file you are importing?
Also, could you try using https://github.com/agershun/alasql/blob/develop/dist/alasql.js
If the error is still occurring with that, could you supply the error using the unminified version above?
I didn't have any issue when I did it server-side with nodejs... I'll have to redact some of the data in the spreadsheet (which will hopefully not taint the results). Let me try that version first.
ok. that script does it, too... but... here's a file with just the headers, and it produces the error... I think it's one of the characters in the headers (which I have no control over unit I am able to import it), although I can import it on the node side
test.xlsx
.
Hmm, I ran a few tests and it seems that importing ANY xlsx file causes it to fail.
E.g If you import the following file, it still returns the error.
john.xlsx
The full error message (using 0.2.5-develop-1262 alasql unminified and 0.8.0 xlsx unminified:
xlsx.js:11363 Uncaught TypeError: f.charCodeAt is not a function
firstbyte @ xlsx.js:11363
readSync @ xlsx.js:11388
(anonymous function) @ alasql.js:15253
reader.onload @ alasql.js:3443
I'm not sure whether alasql manipulates the file or hands it directly to xlsx, so perhaps this is a bug in xlsx.
@mathiasrw Thoughs?
Is it only with angular?
We should to try to import the files directly to xlsx.js without alasql to see where the problem originates. Don't have time the next days to get into it. If no one have proceeded this I will get back to the issue in the end of next week.
I just tried to import the file to xlsx.js using their sample page here (http://oss.sheetjs.com/js-xlsx/)... which just uses jquery and file input box... and it can read it.
I'll try putting that into an angular scenario and see what happens.
ok, it looks like XLSX works just fine with angular. I'll see if I can get some time to debug FILE and see what's going on now that I'm a little more familiar with xlsx.js...
Alternatively, is there a way to import an already parsed XLSX into alasql?
already parsed XLSX into alasql?
Not without changing the source code
I had the exact same issue as angelok1. I've figured out that using xlsx.js version 0.7.12 instead of 0.8 as what alasql 0.2.6 is requesting as requirement worked for me importing xlsx files. Btw. I am using angular in my code but isolated a test using just alasql.js 0.2.6 and xlsx.js 0.8 and it was giving the same problem. Changing to xlsx.js 0.7.12 fixed the issue. One issue though is bower doesnt pick up version 0.7.12 I had to get it from here https://cdnjs.com/libraries/xlsx/0.7.12
@Aelrath Very interesting. Thank you for letting us know.
I will make a new issue with "make sure xlsx.js 0.8 works with alasql"
similar issue, occurs for me aswell and occurs without using angular on normal onchange()
function loadFile(event) {
console.log(event);
var path = $('#readfile').val();
console.log(path);
var data;
alasql('SELECT * FROM FILE(?,{headers:true})',[event],function(res){
data = res;
document.getElementById("res").textContent = JSON.stringify(res);
});
}
as @yogendrakarekar wrote I can confirm this bug for alasql 0.2.7 as well.
I've tested to find out from where the error appears at [alasql releases].(https://github.com/agershun/alasql/releases)
With 0.0.50 version to 0.2.3 version of alasql it works OK. From that point I get errors
I used this code:
<script src="libraries/alasql/dist/alasql.min.js"></script>
<script src="libraries/Blob/Blob.js"></script>
<script src="libraries/js-xlsx/dist/xlsx.full.min.js"></script>
That is really awesome - thanks for looking into this.
I will see if I can find out what changed in the way we use xlsx
Is it version 0.8 your are using?
Is there any hope of this getting fixed? Right now, in order to make it work, I have to have this in my bower.json:
"js-xlsx": "https://cdnjs.com/libraries/xlsx/0.7.12",
"alasql": "0.2.3"
That's too far back to rely on. It looks like nobody is assigned to it. Is it possible to retry that commit from issue #678 that was later removed but only have that code active for FILE so that it is used for browser based usage? Should we be looking at alternatives to alasql for importing Excel files?
Take a look over at issues #678. I think I found the issue. Code was removed from 0.2.3 to 0.2.4. The js-xlsx page says you need that code.
Hi i have the same issue
that is
xlsx.core.min.js:13 Uncaught TypeError: f.charCodeAt is not a function
at firstbyte (xlsx.core.min.js:13)
at Object.readSync [as read] (xlsx.core.min.js:13)
at alasql.min.js:2
at FileReader.i.onload (alasql.min.js:10)

​how to resolve
i am using AlaSQL v0.3.4
Hmm. AlaSQL should support last version of xlsx.js as I recall... try updating yoru version of xlsx.js to the latest one
ya i have changed both alasql and xlsx.js versions , now it is working fine,
but one more problem is, why it's not taking .xls format
why it's not taking .xls format
Please make a new issue describing the problem in details