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)
-
I'm afraid you will have to convert your Excel to a more usable format first, something like XMLJulien Ch.– Julien Ch.2012年07月13日 13:33:08 +00:00Commented Jul 13, 2012 at 13:33
-
1Possible? Yes. But complex and inefficient. Convert your data to a more sensible format first (JSON is a good choice). (I'd also just embed the data on the page, unless there was a lot of it, in which case a server side look up would be better).Quentin– Quentin2012年07月13日 13:33:39 +00:00Commented Jul 13, 2012 at 13:33
-
You don't say whether this form is to be used on one PC, an intranet, or the Internet. This may have implications on the solution.Lee Taylor– Lee Taylor2012年07月13日 13:34:02 +00:00Commented Jul 13, 2012 at 13:34
5 Answers 5
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.
2 Comments
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
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.
1 Comment
Use Html5 File API and maybe it would be great to have at least CSV
2 Comments
As quentin suggested, using a JSON solved my problem
converting csv to JSON was a huge help aswel