[thelist] Reading Values from Excel into PHP

Jay Blanchard jblanchard at pocket.com
Thu Mar 23 09:43:40 CST 2006


[snip]
Sorry for being so unspecific,
I am running on a windows OS and with Apache, php and mysql.

However I was thinking, if the best way was as you mentioned, create a
txt
file or csv file, and then get php to put into the sql database, however
this is easier said than done...
[/snip]

Why? Because you have to train the user to save a text file, or the
actual operation itself? A tab-del example;

$foo = fopen("sheet.txt", "r");
while(!feof($foo)){
   $glorp = fgets($foo, 4096); //get a line
   $splunk = explode("\t", $glorp); // put each item in array $splunk
}
fclose($foo);

Now, take the array and create a sql insert statement.

If you can get users to store text spreadsheets to a central location
you can run a cron (or Task Scheduler) to automagicically grep the
spreadsheets on a regular basis for inclusion in the database. Also, I
would suggest joining the PHP general mailing list at
http://www.php.net/mailinglists




More information about the thelist mailing list