Home » excel » html – How to parse an excel file in JavaScript?

html – How to parse an excel file in JavaScript?

Posted by: admin March 9, 2020 Leave a comment


I am trying to write a small web tool which takes an Excel file, parses the contents and then compares the data with another dataset. Can this be easily done in JavaScript? Is there a JavaScript library which does this?

How to&Answers:

How would you load a file into JavaScript in the first place?

In addition, Excel is a proprietary format and complex enough that server side libraries with years in development (such as Apache POI) haven’t yet managed to correctly 100% reverse engineer these Microsoft formats.

So I think that the answer is that you can’t.

Update: That is in pure JavaScript.

Update 2: It is now possible to load files in JavaScript: https://developer.mozilla.org/en-US/docs/DOM/FileReader


In the past four years, there have been many advancements. HTML5 File API has been embraced by the major browser vendors and performance enhancements actually make it somewhat possible to parse excel files (both xls and xlsx) in the browser.

My entries in this space:

Both are pure-JS parsers


To do everything in js, you’ll have to use ActiveX and probably the office web components as well. Just a suggestion, but you probably don’t want to go this route; it’ll be inefficient and IE/Win only. You’ll be better off with a server based solution.


You will need to use ActiveX (see W3C Schools on the use of AJAX) and register the file in the hosting computers Dataconnectors (only the computer hosting the file). Unlike mentioned before, this method is not Microsoft platform dependant (for the client anyways) and you do not need to have Office components installed.

This can be done for most datafiles registered in Windows, including MDB’s, and allows you as much control as you want, as you can assign different Windows Accounts for different purposes.

Like I said before, this all is serverside and has no impact on the client, apart from maybe retrieving credentials, actions and all that.

This method uses JavaScript, SQL (no, not even MSSQL, just SQL standard) and requires only that the hosting computer is running ANY Microsoft NT platform.

What Windows dataconnectors do is provide a generalised interface for various data components much like DirectX does for videocards and other peripherals. You can also use it to link an MDB (Microsoft Access) to a MySQL server and feed data live that way, which I believe is even simpler than using XLS spreadsheets…especially since you can import XLS into MDB.


Do you really need an Excel file? Why not use Excel to export the data in CSV or XML and load that?

The Excel file format is very specific to Excel’s implementation. If you just need the data, use a file format that just contains the data.