ballhogjoni Posted October 8, 2007 Share Posted October 8, 2007 Does anyone know of a script(way) to import an excel file into mysql? Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/ Share on other sites More sharing options...
Barand Posted October 8, 2007 Share Posted October 8, 2007 Easiest is save as CSV then use MySql LOAD DATA INFILE Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/#findComment-364829 Share on other sites More sharing options...
lessthanthree Posted October 8, 2007 Share Posted October 8, 2007 If your server is a Windows machine running > PHP5.0, you can use a .xls workbook directly by loading it as a COM object. Something like: $excel_app = new COM("Excel.application"); You can then do what you want with the data, check the PHP manual for full info here However, as it's unlikely your server is running Windows and doing this will make your code extremely unportable (only ever going to work on a Windows box, which lets face it, aren't all that common in the PHP world) I suggest you follow the advice above and export the files as CSV, which not only is more portable, but far far easier to manipulate/get into MySQL. Just though I'd let you and anyone else that may want to try it, that it is actually possible to work directly with a .xls (and other) file type. Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/#findComment-364840 Share on other sites More sharing options...
Barand Posted October 8, 2007 Share Posted October 8, 2007 If I use the COM method on my PC it works fine. If I try it on the network web server, also Windows, it doesn't. I assume the difference is that my PC has Excel application and the network server does not. http://web.informbank.com/articles/technology/php-office-documents.htm Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/#findComment-364850 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 http://www.rietta.com/sqlconverter/ Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/#findComment-364852 Share on other sites More sharing options...
lessthanthree Posted October 8, 2007 Share Posted October 8, 2007 If I use the COM method on my PC it works fine. If I try it on the network web server, also Windows, it doesn't. I assume the difference is that my PC has Excel application and the network server does not. http://web.informbank.com/articles/technology/php-office-documents.htm Quite possibly you have to have some installation of Excel on the machine you're attempting to run the COM code on. My mistake, hadn't thought of that, thanks for pointing it out! Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/#findComment-364875 Share on other sites More sharing options...
ballhogjoni Posted October 8, 2007 Author Share Posted October 8, 2007 I am actually just looking to code a script to upload a csv, xls, etc... so I can manipulate the data before it is stored in my DB. I am running php 4 and mysql 4 ( I think ). Quote Link to comment https://forums.phpfreaks.com/topic/72325-import-excel-data-script-into-mysql/#findComment-365018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.