Answers.Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-14T12:32:41.523Z
Answers.Text: 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 ?
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-13T20:29:59.347Z
Answers.LastActivityDate: 2015-06-13T20:29:59.347Z
Answers.UserDisplayName: Joe Murray
Body: <p>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?).</p>
  
  <p>Is there any smart way to do this ?</p>
  
Tags: <civireport>
Title: Combining reports
ThreadText: # Combining reports
  
  (Asked by: username_0 on 2015-06-13)
  
  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 ?
  
  **Tags:** civireport
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-13. Score: 3
  
  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.
  
  > **Comments:**
  > **username_0**: 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 ?  
  
  ---
  
  