Excel Downloads for Rails Active Admin
Using Active Admin?
https://github.com/gregbell/active_admin
You are going to love this:
https://github.com/randym/activeadmin-axlsx
Just the facts [gender neutral honorific]
Put this in your Gemfile
gem 'activeadmin-axlsx'
That's it. You are done.
And because I love you so much, there are a few toys you should know about too:
Localize your column headers!
config.xlsx_builder.i18n_scope [:active_record, :models, :posts]
Pass in blocks for calculated fields!
config.xlsx_builder.column('author_name') do |resource|
resource.author.name
end
Customize your header row style!
config.xlsx_builder.header_style = { :bg_color => 'FF0000', :fg_color => 'FF' }
rant
I get wanting JSON or XML data downloads but can we please stop using CSV for reporting?
Written by Randy Morgan
Related protips
3 Responses
Great work!
over 1 year ago
·
Nice!
over 1 year ago
·
Can we download filtered data in the excel?Please help
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#