module ActiveAdmin::Xls::DSL

Extends activeadmin dsl to include xls

Public Instance Methods

xls(options = {}, &block) click to toggle source

Creates a default XLS Builder to respond to xls requests for this resource. Options are passed to the Builder initialize method.

@param [Hash] options the options for the builder @option options [Hash] :header_format a hash of format properties to

apply to the header row. Any properties specified will be merged with
the default header styles.

@option options [Array] :i18n_scope the I18n scope to use when looking

up localized column headers.

@param [Block] block block given will evaluated against the instance of

Builder. That means you can call any method on the builder from within
that block.

@return A new instance of Builder

@example Using the DSL

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) do |post|
    "#{post.author.first_name} #{post.author.last_name}"
  end

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

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

@see Builder @see github.com/zdavatz/spreadsheet/blob/master/lib/spreadsheet/format.rb

# File lib/active_admin/xls/dsl.rb, line 65
def xls(options = {}, &block)
  config.xls_builder = ActiveAdmin::Xls::Builder.new(
    config.resource_class,
    options,
    &block
  )
end