Add export functionality to your ActiveScaffold interfaces, supporting formats like CSV and Excel. It’s an essential tool for generating reports or sharing data with external systems.

Description

ActiveScaffoldExport adds export functionality to your ActiveScaffold interfaces, allowing users to export data in formats like CSV and Excel. This is essential for generating reports or sharing data with other systems efficiently.

Installation

Add the following line to your Gemfile:

gem 'active_scaffold_export'

Then run:

bundle install

Usage & Options

Enable export in your controller:

class ProductsController < ApplicationController
  active_scaffold :product do |config|
    config.actions << :export
    config.export.columns = [:name, :price, :category]
    config.export.default_deselected_columns = [:category]
  end
end

Customize additional options:

config.export.default_full_download = true
config.export.force_quotes = true
config.export.default_delimiter = ';'
config.export.default_skip_header = true

Example Code

To export products filtered by category:

class ProductsController < ApplicationController
  active_scaffold :product do |config|
    config.actions << :export
    config.export.columns = [:name, :price]
  end

  protected
  
  def conditions_for_collection
    ['category = ?', params[:category]] if params[:category]
  end
end

Get Plugin