= CSV Builder The CSV Builder Rails plugin provides a simple templating system for serving dynamically generated CSV files from your application. == Requirements CSV Builder requires Rails v2.1. It also depends upon the FasterCSV gem http://fastercsv.rubyforge.org, which you can install with $ sudo gem install fastercsv == Example CSV template files are suffixed with '.csv.csvbuilder', for example 'index.csv.csvbuilder' Add rows to your CSV file in the template by pushing arrays of columns into the csv object. # First row csv << [ 'cell 1', 'cell 2' ] # Second row csv << [ 'another cell value', 'and another' ] # etc... You can set the default filename for that a browser will use for 'save as' by setting <tt>@filename</tt> instance variable in your controller's action method e.g. @filename = 'report.csv' You can also set the input encoding and output encoding by setting <tt>@input_encoding</tt> and <tt>@output_encoding</tt> instance variables. These default to 'UTF-8' and 'LATIN1' respectively. e.g. @output_encoding = 'UTF-8' You can also attach a csv file to mail sent out by your application by including a snippet like the following in your mailer method attachment "text/csv" do |attachment| attachment.body = render(:file => 'example/index.csv.csvbuilder') attachment.filename = 'report.csv' end You can change the separator character and that is as simple as writing this in your controller's action method: csv_builder :sep => ';' Actually, all default FasterCSV options can be overriden thanks to the previous statement. Copyright (c) 2008 Econsultancy.com, released under the MIT license
Project
did_csv_builder
CSV template Rails plugin
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
Development
Dependencies
Project Readme