0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
An Osheet writer (https://github.com/kellyredding/osheet) for the XMLSS format (https://github.com/kellyredding/xmlss)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.16.1

Runtime

~> 1.1.1
~> 1.0.1
 Project Readme

=== This has been archived and is not maintained. ===

Osheet::Xmlss

A writer for Osheet (https://github.com/kellyredding/osheet). Use this with Osheet to write workbooks in the Xmlss format (https://github.com/kellyredding/xmlss.)

Usage

require 'osheet/xmlss'

fields = ['Sex', 'Age', 'Height', 'Weight']
data = {
  'Tom' => ['M', 52, "6'2\"", '220 lbs.'],
  'Dick' => ['M', 33, "6'5\"", '243 lbs.'],
  'Sally' => ['F', 29, "5'3\"", '132 lbs.']
}

# this will dump the above data to a single-sheet workbook w/ no styles
# - this example is using the Xmlss writer (https://github.com/kellyredding/xmlss)

Osheet::Workbook.new(Osheet::XmlssWriter.new) {
  title "basic"

  template(:column, :data) { |field, index|
    width 80
    meta(
      :label => field.to_s,
      :index => index
    )
  }

  template(:row, :title) {
    cell {
      colspan columns.count
      data worksheet.name
    }
  }

  template(:row, :empty) {
    cell {
      colspan columns.count
      data ''
    }
  }

  template(:row, :header) {
    columns.each do |column|
      cell {
        data column.meta[:label]
      }
    end
  }

  template(:row, :data) { |name, stats|
    cell {
      data name
    }
    stats.each do |stat|
      cell {
        data stat
      }
    end
  }

  worksheet {
    name "Stats: #{fields.join(', ')}"

    column {
      width 200
      meta(
        :label => "Name"
      )
    }
    fields.each_with_index do |f, i|
      column :data, f, i
    end

    row :title
    row :empty
    row :header

    data.each do |name, stats|
      row :data, name, stats
    end
  }
}.to_file('stats.xls')

Writer Options

API

Check out the Osheet wiki: https://github.com/kelredd/osheet/wiki. It covers the full Osheet API.

Examples

I've add a few examples to ./examples. Please refer first to the API then to these for examples on basic usage, using templates, formatting data, and styling data.

Links

Installation

Add this line to your application's Gemfile:

gem 'osheet-xmlss'

And then execute:

$ bundle

Or install it yourself as:

$ gem install osheet-xmlss

Osheet::Xmlss will install Osheet and Xmlss for you and you are all set.

Contributing

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