Excel Spreadsheet to Array via Javascript?

Actually, I was having issues converting Excel Spreadsheet to database. But that does not seem to work directly.

This is the other ongoing thread : http://www.sitepoint.com/forums/showthread.php?1164251-Excel-Spreadsheet-to-multiple-tables

Hence, I read while searching that it might be possible to convert an excel spreadsheet to an array using JS

So is there any way I could upload a CSV file and the JS converts it into a specific array? This could be used by me to pass it to the PHP script which in turn could add it to the database

Thanks for all the help in advance.

Hi jaagare,

Having read your other thread that you linked to, I think your best option is probably to use PHP, with a library such as PHPExcel, to import the data from the spreadsheet into your DB. I’ve done something similar in the past with a system that imported supplier stock lists in Excel format.

@fretburner Thank you for the link. Will definitely check it out and try to work it out as per my requirements. Will let you know how it goes. Thanks

For anyone else wanting a solution that I want, I find that jquery seems to have an option to automatically enter array in to a HTML form online using console.log function.

I am studying in detail regarding this function but I feel that it might solve my issue. First I would need to store the CSV to an array and then from an array run the jQuery script which in turn would fill up all the form data using the above function.

Will keep posted if I succeed or if anyone has already done such a thing it would be great if you could share any link if there are existing examples in this regard.

If you’re interfacing with the CSV for database purposes, you’d probably be better off using PHP. It has native CSV support built in by using the fgetcsv function.

If you need the user to upload the file, and then make changes, you could use a form to post the file, read it, and then return a JSON object to parse on the front-end.

@jaydub Thanks. Will definitely check fgetcsv too.