目前,我有一些代码,用于从我拥有的数据中输出一个表格。
require fastercsv
def dump_csv
@users = User.find(:all, :order => "lastname ASC")
@outfile = "members_" + Time.now.strftime("%m-%d-%Y") + ".csv"
csv_data = FasterCSV.generate do |csv|
csv << [
"Last Name",
"First Name",
"Username",
"Email",
"Company",
"Phone",
"Fax",
"Address",
"City",
"State",
"Zip Code"
]
@users.each do |user|
csv << [
user.lastname,
user.firstname,
user.username,
user.email,
user.company,
user.phone,
user.fax,
user.address + " " + user.cb_addresstwo,
user.city,
user.state,
user.zip
]
end
end
send_data csv_data,
:type => text/csv; charset=iso-8859-1; header=present ,
:disposition => "attachment; filename=#{@outfile}"
flash[:notice] = "Export complete!"
end
我的问题是,我如何从我的角度看待这个问题,这项工作将充满希望。 我知道“快车”会利用“积极记录”制作桌子,在试图组织桌子时,会赢得任何用途。