0.0
No release in over a year
Xlsx stream download for rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 7.0
>= 2.4.0
 Project Readme

XlsxtreamRails

Xlsx stream download for rails.

Installation

Add this line to your application's Gemfile:

gem "xlsxtream_rails"

And then execute:

$ bundle

Or install it yourself as:

$ gem install xlsxtream_rails

Controller

Set your instance variables in your controller and configure the response if needed:

class PostsController < ApplicationController
  def index
    @posts = Post.all
    respond_to do |format|
      format.xlsx { render xlsx: @posts }
    end
  end
end

Model

Add xlsx_columns method for model:

class Post < ApplicationRecord
   def xlsx_columns
     [:id, :title, :body]
   end
end

or

class Post < ApplicationRecord
   belongs_to :category

   def xlsx_columns
     [
       [:category, category.name],
       :title,
       :body
    ]
   end
end

This gem is inspired by the following

spreadsheet_architect

caxlsx_rails

License

The gem is available as open source under the terms of the MIT License.