Jump to content

Import excel data script into mySQL?


ballhogjoni

Recommended Posts

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.

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

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.