1

How do I pull data and display it in html from a Excel file using Javascript?

I have a code like this:

var myFirstjson = { "firstName":"John",
                    "LastName":"Lenon",
                    "age":23,
                                                                                                              };
document.writeln(myFirstjson["firstName"]+"<br/>"); 
document.writeln(myFirstjson["LastName"]+"<br/>");
document.writeln(myFirstjson["age"]+"<br/>");
</script>

</body>

</html>

What I need to do is parameterize the values in the first name last name and age from an Excel file located in d:\file.xls

1
  • Please just edit your question if you need to add information. Commented Feb 11, 2011 at 10:15

2 Answers 2

1

You either need a server side script to prepare the data for you, usually it's to convert to json format.

or you could save your data to csv and paste that into a text area for javascript to do whatever you want it to.

why are you needing to use javascript with excel, if it's for scripting then i suggest you use vba instead.

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

Comments

1

You are actually asking "How to read data from my local computer in a HTML program (i.e. JavaScript)". If you're running on IE, Chrome, any Web browser due to security concerns the answer is no way. But, try Microsoft HTA and search for ado = new ActiveXObject("ADODB.Stream"); and fso = new ActiveXObject("Scripting.FileSystemObject"); those are the two available interfaces to access local computer file system. Use ADO if your data contains none ANSI characters e.g. utf-8.

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.