I needed to quickly dump bunch of MySQL tables into Excel so that our directors can play around with the data. It does make sense, believe me. It would take me at least a day or two to implement, test, and integrate the statistical analysis they want to do on the data into our web application. Meanwhile they can perform the same calculations on an excel sheet in the next 15 minutes. So I get to add bunch of items to my todo list, and they get bunch of data to play around with. Everyone wins :)
And yes, they specifically asked for Excel format, and the future reports must have “export to Excel” feature.
Anyways, here is why I love MySQL:
SELECT * INTO OUTFILE 'result.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM my_table;
You get a CSV file formated nicely for Excel. Now you can just open it, and save it as xls file if that is what you need.
If your table is to big for Excel you can of course use a WHY clause to cut down the number of results.
[tags]mysql, excel, mysql export, sql, databases[/tags]