Varinder
Varinder

Reputation: 2664

Using Javascript to read files

Im building an html form which shows price for traveling from destination1 to destination2

The trouble is, 'price' is stored in an excel file (which can be changed to almost any format) so is there any way to use javascript to find price from destination1 to destination2?

Im afraid i cant post any code upfront (probably because i have no clue where to start)

Upvotes: 1

Views: 233

Answers (5)

Varinder
Varinder

Reputation: 2664

As quentin suggested, using a JSON solved my problem

converting csv to JSON was a huge help aswel

Upvotes: 0

Otto Allmendinger
Otto Allmendinger

Reputation: 28288

Using the new HTML5 File API you can read local files or download the file using an XMLHttpRequest.

I would suggest using the CSV format for reading since it is much easier to parse than Excel files.

Upvotes: 2

Vitalii Ivanov
Vitalii Ivanov

Reputation: 3250

Use Html5 File API and maybe it would be great to have at least CSV

http://www.w3.org/TR/FileAPI/

Upvotes: 0

Andrew McGivery
Andrew McGivery

Reputation: 1400

If you are ok with only modern browser support (html5), you can use the filesystem api...

http://www.html5rocks.com/en/tutorials/file/dndfiles/

However, older browsers(as far as I know) do not support reading files.

Upvotes: 0

Nickon
Nickon

Reputation: 10156

I don't know if it's what u need, but u cant use ActiveXObject to read Excel files.

http://www.codeproject.com/Questions/85672/Read-Excel-values-using-Javascript

Upvotes: 1

Related Questions