Git Product home page Git Product logo

lazy-wombat's Introduction

LazyWombat Build Status

A simple yet powerful DSL to generate Excel spreadsheets built on top of axlsx gem.

Wombat picture

Why Lazy Wombat?

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.

Installation

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

Usage

Basic sample: no styles, just content

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:

Generated spreadsheet

Since spreadsheet elements inheritance is alike spreadsheet -> row -> cell, you can arbitrary omit every unnecessary elder element of your spreadsheets.

Where is my HTML??

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'

Additional options: spreadsheet names, rows and cells styles

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'

Generated spreadsheet

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.