1

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)

3
  • I'm afraid you will have to convert your Excel to a more usable format first, something like XML Commented Jul 13, 2012 at 13:33
  • 1
    Possible? 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). Commented 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. Commented Jul 13, 2012 at 13:34

5 Answers 5

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

The question implies that the Excel file is provided by the site, not the user, so the File API wouldn't be any help.
I didn't read it that way. Just going by the question title, the answer is the File API.
1

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

2 Comments

Internet Explorer only solutions are not generally good solutions.
Ye, I agree, but there are some ActiveXObject-like solutions for other web browsers:) it was just an idea how to do this:)
0

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

The question implies that the Excel file is provided by the site, not the user, so the File API wouldn't be any help.
0

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

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

2 Comments

The question implies that the Excel file is provided by the site, not the user, so the File API wouldn't be any help.
I don't see the problem to create http handler or something to get the file and open it through the FileAPI
0

As quentin suggested, using a JSON solved my problem

converting csv to JSON was a huge help aswel

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.