At 1:56 PM -0400 8/8/07, Jason Pruim wrote:
Hey everyone,
I tried asking this question on the MySQL list but haven't gotten
very many helpful responses... Does anyone know how to successfully
import a excel file into MySQL (To make it on topic) Using PHP? I
have tried using LOAD FILE in mysql and it just imports the first
row of my excel file with no errors...
Some options:
(1) Export to CSV, use the MySQL CSV storage engine to read file &
(if desired) transfer to a table in another storage engine:
http://dev.mysql.com/doc/refman/4.1/en/csv-storage-engine.html
(2) On Windows, you could use PHP's COM interface to open Excel and read it:
http://www.thescripts.com/forum/thread9693.html
(3) You should be able to export Excel data using an ODBC connection
from Excel to your database.
(4) On Unix, you could use an Excel reader to try to read the file.
I've never used this module, and presumably it's going to lag behind
any changes MS makes to Excel file format:
http://sourceforge.net/projects/xlreader
http://sourceforge.net/projects/phpexcelreader
(5) Export to XML, then upload:
http://www-128.ibm.com/developerworks/opensource/library/os-phpexcel/
(6) Export to CSV, then use LOAD DATA or write a custom parser (eg;
using PHP's CSV functions.
You say you've already tried option (6) w/LOAD DATA and had problems.
I would try reposting the question to the MySQL list with a more
detailed description than 'it just imports the first row of my file'
- as in, what does your LOAD DATA statement look like? Were there any
warnings/errors generated? You were doing a LOAD DATA on a tab- or
comma-delimited file, right? MySQL can't eat raw Excel files.
steve
--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center sbedberg@xxxxxxxxxxx |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php