I've created a few (membership) reports, and the client is happy. Only, they would like the csv output of the reports to be combined into one. Preferably with some headers in between. The filters of each report are mutually exclusive, so I can't do it in one report (or can I?).

Is there any smart way to do this ?

1 Answer 1


It would be easiest to do this if the client is willing to accept fixed configurations for at least one report. You want to hook in (or more likely have to override) the creation of the csv export from the report output. IIRC most reports build arrays in PHP before rendering them as csv. After one has been built, build the other. Add column(s) if necessary so the first report array has at least as many as the second, then append the tows of second array to first then send to function that converts array to csv file for download.

A more advanved but nicer approach would be to put each report on a separate sheet in an .xls .xlsx file. (Micosoft opened up the spec for Excel file formats a few years ago and I believe Xavier made an extension to make .xls available as an additional output format for CiviReports.) As I recall it's slightly easier to render first array directly to file then open file and insert second sheet before closing, then sending for download.

A third approach we've taken in an extension was to generate more than one report and zip them into a single file for download. This has the advamtage of single click UI and being relatively easy to program.

  • 1
    Say for example you take the third approach. Where did you write the code to combine the reports into a zip ? How did you execute that code - from the gui, from a cron job ?
    – commonpike
    Jun 14, 2015 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.