hello everyone,
i want to take data from a Microsoft excel file using php. i need then dump this data in the mysql database.. i am using Appache web server.. can you please tell me how to do it ?? if anyone can get me the code, that would help me a lot.. i have searched a couple of sites but i could not find direct solution..
i have to achieve this functionality by wednesday... so please consider this urgent!! reply back.. Any help will be appreciated..
thanks,
ravi
Note: i know how to do it in ASP.. if anyone is interested in knowing how it is done using ASP and Access/SQLServer i can tell them..
how to dump data from excel file in mysql database using php
Moderator: General Moderators
If you dont need it to update automatically, save your Excel file in CSV format (Comma Seperated Values).
There is a function in PHP for reading CSV, fgetcsv, http://www.php.net/manual/en/function.fgetcsv.php, or I think you can do it with phpMyAdmin.
I'm not sure how you can set it automatically to save as CSV, probably through ActiveX.
Or, you could load Apache with ASP, and combine your PHP/ASP files somehow. Oh, Oh! Use DSN or ODBC to connect ASP to your MySQL database.
There is a function in PHP for reading CSV, fgetcsv, http://www.php.net/manual/en/function.fgetcsv.php, or I think you can do it with phpMyAdmin.
I'm not sure how you can set it automatically to save as CSV, probably through ActiveX.
Or, you could load Apache with ASP, and combine your PHP/ASP files somehow. Oh, Oh! Use DSN or ODBC to connect ASP to your MySQL database.
Excel to PHP parser class.
There is a commercial solution for parsing Excel file:
http://www.zakkis.ca/products/abc_excelparser/
This is a pure PHP class which parse Excel file of any Excel version into the PHP array structures. Certanly you can not get any embedded OLE objects on the Unix, but there are no any problems to get all worksheets data with its Excel formatting etc....
Good luck.
Regards,
Maxim.
http://www.zakkis.ca/products/abc_excelparser/
This is a pure PHP class which parse Excel file of any Excel version into the PHP array structures. Certanly you can not get any embedded OLE objects on the Unix, but there are no any problems to get all worksheets data with its Excel formatting etc....
Good luck.
Regards,
Maxim.
LOAD DATA INFILE is specifically designed to load data from files (including csv) very quickly - see manual mysql.com or use phpMyadmin, as suggested above (open a table and click the "insert file" option to run LOAD DATA, if I remember rightly).
I haven't used fgetcsv but I suspect LOAD DATA is a more efficient option to get the data into mysql particularly for a very large file.
If you have to do some php processing on the data fgetcsv might be the way to go - or you could get it into php after a LOAD DATA.
I haven't used fgetcsv but I suspect LOAD DATA is a more efficient option to get the data into mysql particularly for a very large file.
If you have to do some php processing on the data fgetcsv might be the way to go - or you could get it into php after a LOAD DATA.