List<ProposalCsv> proposals = new ArrayList<ProposalCsv>();
for (Proposal proposal : Proposal.find.all()) {
proposals.add(ProposalCsv.fromProposal(proposal));
}
CsvEngine engine = new CsvEngine(ProposalCsv.class);
StringWriter writer = new StringWriter();
engine.writeFile(writer, proposals, ProposalCsv.class);
response().setContentType("application/octet-stream");
response().setHeader("Content-Description", "File Transfer");
response().setHeader("Content-Disposition", "attachment;filename=proposals.csv");
response().setHeader("Content-Transfer-Encoding", "binary");