A simple yet powerful DSL to generate Excel spreadsheets built on top of axlsx gem.
Axlsx is awesome and quite complex in usage. Often you need something simple and easy-to-use to generate an excel spreadsheet as easy, as you markup tables with HTML. Now you can.
Add this line to your application's Gemfile:
gem 'lazy-wombat', '~> 0.0.2'
And then execute:
$ bundle
Or install it yourself as:
$ gem install lazy-wombat
Code
LazyWombat::Xlsx.new do
spreadsheet do
row do
cell 'Cyberdyne Systems'
cell 'Model 101'
cell 'The Terminator'
end
end
end.save 'my_laziness.xlsx'
Or shortened:
LazyWombat::Xlsx.new do
cell 'Cyberdyne Systems'
cell 'Model 101'
cell 'The Terminator'
end.save 'my_laziness.xlsx'
will create my_laziness.xlsx
spreadsheet looks like this:
Since spreadsheet elements inheritance is alike spreadsheet -> row -> cell
, you can arbitrary omit every unnecessary
elder element of your spreadsheets.
Oh yeah, I promised you as you markup tables with HTML
: there're logic aliases:
spreadsheet
is table
, row
is tr
, cell
is, of course, td
Thus here's our simplest example:
LazyWombat::Xlsx.new do
table do
tr do
td 'Cyberdyne Systems'
td 'Model 101'
td 'The Terminator'
end
end
end.save 'my_laziness.xlsx'
By default spreadsheets are named as Sheet 1
, Sheet 2
, etc. It can be overwritten using name
option.
LazyWombat::Xlsx.new do
spreadsheet name: 'My Laziness' do
row style: :bold do
cell 'Cyberdyne Systems'
cell 'Model 101', style: :italic
cell 'The Terminator'
end
end
end.save 'my_laziness.xlsx'
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request