homepage Welcome to WebmasterWorld Guest from 54.205.106.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Javascript and Excel
Can they work together?
j2trumpet




msg:4060291
 11:58 pm on Jan 13, 2010 (gmt 0)

Is it possible for Javascript to retrieve data from an Excel spreadsheet and create an array with that data?

 

j2trumpet




msg:4060300
 12:19 am on Jan 14, 2010 (gmt 0)

Or maybe even from a .csv file exported from Excel.

j2trumpet




msg:4067687
 11:09 pm on Jan 25, 2010 (gmt 0)

*bump*

I'm still hoping to find a way for Javascript to read .csv files. Thanks.

daveVk




msg:4068552
 11:10 pm on Jan 26, 2010 (gmt 0)

Javascript can read any file, provided it resides on the server (not the client) and placed such that it can be accessed via a URL.

But not sure if that is what you are asking ?

j2trumpet




msg:4068588
 11:53 pm on Jan 26, 2010 (gmt 0)

Okay. Since you say it is possible, how would I go about looping through the .csv file, loading each line into a new item in an array?

Example:

CSV
item1value1,item1value2
item2value1,item2value2
item3value1,item3value2

Javascript
var list = new Array();
list[0] = "item1value1,item1value2";
list[1] = "item2value1,item2value2";
list[2] = "item3value1,item3value2";

The array won't be written out like it is here as its content will be pulled directly from the specified .csv file.

daveVk




msg:4068684
 3:03 am on Jan 27, 2010 (gmt 0)

assuming replyS contains the csv file

var list = replyS.split( '\n' );

j2trumpet




msg:4068741
 6:19 am on Jan 27, 2010 (gmt 0)

I didn't know \n worked in Javascript too. I thought it was just a PHP thing.

How would I load the .csv content into replyS?

daveVk




msg:4068857
 12:36 pm on Jan 27, 2010 (gmt 0)

The short answer is AJAX, using one of the frameworks like JQuery makes it a lot easier.

Eg.

jQuery.ajax({"url":"/my.csv"
,"cache":false
,"type":"get"
,"success":function(replyS){ alert( replyS); }
,"error":function(req,errorS,excep) { alert( errorS ); }
});

j2trumpet




msg:4069405
 11:03 pm on Jan 27, 2010 (gmt 0)

I'm not that familiar with jQuery. Is it something I'd have to load or install onto the server? I have FTP access to my area of the server but not admin rights.

daveVk




msg:4069421
 11:22 pm on Jan 27, 2010 (gmt 0)

It's just a matter of moving the js files into your area of the server typically a jquery directory in the main directory.

Alternatively I understand that 3rd parties like google serve these files as a free service.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved