Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse an excel file in JavaScript?

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?

like image 697
vivekian2 Avatar asked Mar 09 '09 21:03

vivekian2


2 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

like image 143
cherouvim Avatar answered Oct 10 '22 17:10

cherouvim


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:

  • http://oss.sheetjs.com/js-xls/ (xls)
  • http://oss.sheetjs.com/js-xlsx/ (xlsx)

Both are pure-JS parsers

like image 25
SheetJS Avatar answered Oct 10 '22 15:10

SheetJS