Skip to content
ActiveAdmin plugin for adding Excel (xls) download links for your resources
Branch: master
Clone or download
Latest commit 5ec34b4 Oct 9, 2019

Active Admin Xls

Excel Spreadsheet Export for Active Admin

Version Travis CI Quality Coverage Inch CI


This gem provides xls downloads for Active Admin resources.

This gem borrows heavily from activeadmin-axlsx and to_xls.


Add the following to your Gemfile. All resource index views will now include a link for download directly to xls.

gem 'activeadmin-xls', '~>2.0.0'

For Active Admin 1.0 and above, you will also have to update config/initializers/active_admin.rb. Update the download_links setting to include xls:

config.download_links = %i[csv xml json xls]


This gem depends on spreadsheet to generate xls files.


Here are a few quick examples of things you can easily tweak.

Localize column headers

# app/admin/posts.rb
ActiveAdmin.register Post do
  config.xls_builder.i18n_scope = [:active_record, :models, :posts]

Use blocks for adding computed fields

# app/admin/posts.rb
ActiveAdmin.register Post do
  config.xls_builder.column('author_name') do |resource|

Change the column header format

# app/admin/posts.rb
ActiveAdmin.register Post do
  config.xls_builder.header_format = { weight: :bold,
                                       color: :blue }

Remove columns

# app/admin/posts.rb
ActiveAdmin.register Post do
  config.xls_builder.delete_columns :id, :created_at, :updated_at

Restrict columns to a list

# app/admin/posts.rb
ActiveAdmin.register Post do
  config.xls_builder.only_columns :title, :author

Using the DSL

Everything that you do with the config's default builder can be done via the resource DSL.

Below is an example of the DSL

ActiveAdmin.register Post do

  # i18n_scope and header style are set via options
  xls(i18n_scope: [:active_admin, :xls, :post],
      header_format: { weight: :bold, color: :blue }) do

    # Specify that you want to white list column output.
    # whitelist

    # Do not serialize the header, only output data.
    # skip_header

    # restrict columns to a list without customization
    # only_columns :title, :author

    # deleting columns from the report
    delete_columns :id, :created_at, :updated_at

    # adding a column to the report with customization
    column(:author) { |post| "#{} #{}" }

    # inserting additional data with after_filter
    after_filter do |sheet|
      # todo

    # inserting data with before_filter
    before_filter do |sheet|
      # todo


Running specs for this gem requires that you construct a rails application.

To execute the specs, navigate to the gem directory, run bundle install and run these to rake tasks:

Rails 4.2

bundle install --gemfile=gemfiles/rails_42.gemfile
BUNDLE_GEMFILE=gemfiles/rails_42.gemfile bundle exec rake setup
BUNDLE_GEMFILE=gemfiles/rails_42.gemfile bundle exec rake

Rails 5.2

bundle install --gemfile=gemfiles/rails_52.gemfile
BUNDLE_GEMFILE=gemfiles/rails_52.gemfile bundle exec rake setup
BUNDLE_GEMFILE=gemfiles/rails_52.gemfile bundle exec rake

Rails 6.0

bundle install --gemfile=gemfiles/rails_60.gemfile
BUNDLE_GEMFILE=gemfiles/rails_60.gemfile bundle exec rake setup
BUNDLE_GEMFILE=gemfiles/rails_60.gemfile bundle exec rake
You can’t perform that action at this time.