THIS IS AN OLD POST AND IS KEPT LIVE FOR ARCHIVING PURPOSES ONLY

I recently had to write a little script which allowed one of my clients to download the contents of a MySQL table in a format which would open in Excel – so as usual I decided to make the script in a way which could be reused very easily.

Basically you just add your connection details and the name of the table you want to export into this little script and save it – then browse to it and you’ll be presented with a tab separated file which will open in Excel.

You can get the code here: http://mj7.co.uk/ampw

NOTE: this script uses MySQLi rather than MySQL – if anyone needs it changed to MySQL just shout – it’ll only take 5 mins.

TO DO: at the moment line breaks can cause it all to go a bit wrong so they are replaced by a comma followed by a space – you can change this in the code if you need.

Next on the list – export complete database to Excel with each table as a separate worksheet.

As always if you use this script I’d really appreciate a comment below (I do not ever send spammy emails) – if you’re feeling incredibly generous then a link to this post would be fantastic.