EasyAxlsx
This is gem lets you generate axlsx object of an any class. Very easy. TODO: Description readme.
Installation
$ gem install easy_axlsx
or in your Gemfile
gem 'easy_axlsx'
Examples
class User
include EasyAxlsx::ClassConfig
attr_reader :id, :name, :last_name
def initialize(args = {})
@id = args.fetch(:id)
@name = args.fetch(:name)
@last_name = args.fetch(:last_name)
end
def second_name
end
as_easy_axlsx_fields :id, :name, :last_name # this is method names,which will be use as row info
as_easy_axlsx_widths 1.5, 2.5, 3.5 # this is with column as pt
end
@row_items = (1...3).map { |i| User.new(id: i, name: "Name#{i}", last_name: "Last Name #{i}") } # create your object array
# and after build axlsx object
@axlsx_object = EasyAxlsx::Builder.build @row_items
# after you can save this axlsx object as xlsx file
@axlsx_object.package.serialize('simple.xlsx')
This code generate next xlsx file




