Last Updated: January 12, 2017
·
3.441K
· randym

Excel Downloads for Rails Active Admin

Using Active Admin?
https://github.com/gregbell/active_admin

You are going to love this:

Picture
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?

3 Responses
Add your response

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 ·