reasoncorp / dossier

Ruby-based report generation/presentation Rails engine.
MIT License
385 stars 79 forks source link

CSV formatted results #39

Closed afhammad closed 10 years ago

afhammad commented 10 years ago

Is there a reason CSV results aren't using the formatters?

adamhunter commented 10 years ago

Hey @afhammad Sorry for the super delayed response. At the moment we aren't formatting the CSV results because we expected end users to do so in excel or whatever the load the csv into. It is possible to format them in a variety of ways, depending on if it should happen every time. I can provide some examples if it's still germane.

In the long term I'd like to make formatting results or any format (html, json, csv) optional but I haven't gotten there yet. Let me know if you have any other questions.

Thanks!

afhammad commented 10 years ago

Thanks for getting back to me @adamhunter. I ended up forking the project as it turns out I had to customise the functionality quite a bit, but it formed a great foundation and is working nicely now.

Thanks.

nathanl commented 10 years ago

Had the same issue and found a simple workaround.

If you're OK with using the exact same formatting for your CSV as you do for your HTML, you can just do this in your report:

def raw_results
  results
end

That's because the responder calls .raw_results when generating the CSV, which are normally unformatted.

https://github.com/adamhunter/dossier/blob/eb5ef7e889062522643f60f838a29767f0e23d5e/lib/dossier/responder.rb#L16