code: public void generateCsv(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
          ICsvMapWriter csvWriter = null;
          try {
              csvWriter = new CsvMapWriter(new OutputStreamWriter(out), CsvPreference.STANDARD_PREFERENCE);
              // the header elements are used to map the bean values to each column (names must match)
              String[] header = new String[] {};
              CellProcessor[] processors = new CellProcessor[] {};
              if (columns != null)
              {
                  header = (String[])CollectionUtils.collect(columns, new Transformer() {
                      @Override
                      public Object transform(Object input) {
                          ColumnDef column = (ColumnDef)input;
                          return column.getName();
                      }
                  }).toArray(new String[0]) ;
                  processors = (CellProcessor[]) CollectionUtils.collect(columns, new Transformer() {
                      @Override
                      public Object transform(Object input) {
                          return new Optional();
                      }
                  }).toArray(new CellProcessor[0]);
              } else if (rows.size() > 0)
              {
                  header = new ArrayList<String>(rows.get(0).keySet()).toArray(new String[0]);
                  processors = (CellProcessor[]) CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                      @Override
                      public Object transform(Object input) {
                          return new Optional();
                      }
                  }).toArray(new CellProcessor[0]);
              }
              if (header.length > 0)
                  csvWriter.writeHeader(header);
              if (rows != null)
                  for (Map<String, Object> row : rows)
                  {
                      csvWriter.write(row, header, processors);
                  }
          } catch (IOException e) {
              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
          } finally {
              if( csvWriter != null ) {
                  try {
                      csvWriter.close();
                  } catch (IOException e) {
                      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                  }
              }
          }
      }
docs: Takes the output and transforms it into a csv file.
  @param out Output stream.
  @param rows Rows of data from reporting-core
  @param columns Columns to list on report