/ gem

Download or Export excel records from active admin

activeadmin-axlsx gem

[activeadmin-axlsx][1] gem is very useful to download or export excel records from active admin.

It provides "XLSX" links to download Active Admin resources.

We can use this gem by include this line in gem file:

gem 'activeadmin-axlsx'

then run:

bundle install

Now all resources of active admin index page include a 'XLSX' link.

There is some example to customize 'activeadmin-axlsx'.

  1. Remove unnecessary column:

    app/admin/orders.rb

    ActiveAdmin.register Order do
    config.xlsx_builder.delete_columns :created_at, :updated_at
    end

  2. Change the style of column header:

    app/admin/orders.rb

    ActiveAdmin.register Order do
    config.xlsx_builder.header_style = { bg_color: 'FF0000', fg_color: 'FF' }
    end

For more details [activeadmin-axlx][2]
[1]: https://github.com/randym/activeadmin-axlsx
[2]: https://github.com/randym/activeadmin-axlsx