AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

XLSX "[Content_Types].xml in zip" #642

Closed tmrk closed 8 years ago

tmrk commented 8 years ago

Hi, I was trying to update my alasql source file to the latest version so that I can use some of the new functions. However, something broke when I did that and I'm getting the following message in the console:

Uncaught Error: Cannot find file [Content_Types].xml in zip

I've found that the 0.2.3 is where something changed, as with 0.2.2 it is still working. I'm using the following code to load in an xlsx file (and this still works with 0.2.2):

alasql('SELECT * FROM XLSX("'+xlsxurl+'",{sheetid:"Sheet1", headers:true})', [],function(listing){

Am I missing something? Where could the problem be?

mathiasrw commented 8 years ago

Thank you very much for taking the time to make an issue about it.

It shuld work.

Is it possible for you to give me an excel file that recreates the problem?

tmrk commented 8 years ago

Not sure if there is anything specific with my Excel file, but I'll attach a stripped version of it here: test.xlsx

I've tested it again (with the exact test.xlsx file above), it works under alasql 0.2.2 but breaks under 0.2.3 and produces the Uncaught error I mentioned.

tmrk commented 8 years ago

I did one more test to get closer to the problem, this time with the latest and full (not minimised) alasql 0.2.5 version:

xlsx.core.min.js:6 Uncaught Error: Cannot find file [Content_Types].xml in zip getzipfile @ xlsx.core.min.js:6 getzipdata @ xlsx.core.min.js:6 parse_zip @ xlsx.core.min.js:9 readSync @ xlsx.core.min.js:9 (anonymous function) @ alasql.js:15243 xhr.onload @ alasql.js:3432

As you can see, there is something in line 3432 and 15243 that used to work under 0.2.2.

mathiasrw commented 8 years ago

Thank you very much for the time to get into the details. I will see what can be done.

It looks like a problem in the xlsx library we are using.

tmrk commented 8 years ago

Okay, so I literally have no idea what I did, because I know very little about alasql's code logic, but I tried to compare 0.2.2 and 0.2.5 and look at the lines that were mentioned in the error message to see if something has changed, and if I change it back, it might still work again.

In line 3434 of the alasql.js version 0.2.5 there's a line that wasn't there in 0.2.2 (but appeared since 0.2.3):

xhr.responseType = "blob";

I removed it from the alasql.js, aaaand voilà, it works again!

Any idea what this means?

mathiasrw commented 8 years ago

@tmrk

You are awesome !

Its a tentative to solve another problem: https://github.com/agershun/alasql/commit/de88a650063d6f86950fc2d32ff1e8a694a809a5

Stop syntax errors I kept getting syntax errors loading csv files and xhr.responseType = "text"; fixed it. I haven't actually loaded any Binary files but I'm guessing xhr.responseType = "blob"; should probably be go there. anyway thanks again for the library :-)

Soooo - looks like we introduced a new error. Hmm.

Ill remove it - but will have to look into the difference before we release...

mathiasrw commented 8 years ago

If you could please try with the last version of https://github.com/agershun/alasql/blob/develop/dist/alasql.js that would be awesome...

tmrk commented 8 years ago

@mathiasrw I tested it now, and it works perfectly! Thanks!