Export Data to CSV

For the past two client projects I worked on, both requested the ability to export their data to comma separated value files (CSV), so that they could view the data in Microsoft Excel. Although it's a very simple thing to do (read in data from the database and spit it out, separated by commas), I wanted something that would make it easier to export next time a client requests it.

Well, Drupal once again came to the rescue. It seemed that work was already being done to add the ability to export a view to a CSV file. Although it kind of worked, it wasn't really well designed. So I talked to dmitdrig01, the maintainer of Views Bonus Pack, and redesigned it. I added the ability to use arguments to export the data, as well as made it so that it would be easily expandable if we wanted to export any other type of file format in the future. After testing it a bunch and sticking it in the client project, I committed the work I did to the Drupal CVS.

Now, when you want to export data to a CSV file, you enable the Views Bonus Pack Export module, and add a CSV argument to your view that selects the data. When the user looks at the view, they're presented with an option to export the data to a CSV file (myview/csv). Very nice to work with, and I will definitely be using this for this client project, as well as future ones.