Greetings,
Try this:
http://phpexcel.codeplex.com/ or even a google for 'creating excel files with php' and you'll get a few results.
If you want speed, as creating excel files can be quite slow, depending on the size of the data set, you may want to think about creating an XML file instead and then simply open the XML file with Excel.