README.rdoc in osheet-0.3.0 vs README.rdoc in osheet-0.4.0

- old
+ new

@@ -1,135 +1,109 @@ = Osheet -* Osheet is under development and should not be relied upon just yet. Thx. * == Description -Pronounced 'oh-sheeeeeet!' - this gem is a DSL wrapper to the spreadsheet gem that hopefully doesn't totally suck. +A DSL for specifying and generating spreadsheets using Ruby. == Installation $ gem install osheet == Basic Example + + require 'osheet' + 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 - require 'osheet' + Osheet::Workbook.new { + title "basic" - wb = Osheet::Workbook.new { + 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 { - width 80 - meta( - :label => f.to_s, - :index => i - ) - } + column :data, f, i end - row { # title row - cell { - colspan columns.count - data worksheet.name - } - } - row { # empty row - cell { - colspan columns.count - data '' - } - } - row { # header row - columns.each do |column| - cell { - data column.meta[:label] - } - end - } + row :title + row :empty + row :header data.each do |name, stats| - row { # data row - cell { - data name - } - stats.each do |stat| - cell { - data stat - } - end - } + row :data, name, stats end - } # worksheet - } # workbook + } + }.to_file('stats.xls') - file = wb.to_file('stats') # => <spreadsheet written to ./stats.xls> - -== Examples - -I've add a few examples to ./examples. Please refer to these for examples on basic usage, using templates, formatting data, and styling data. - == API -These classes define how a spreadsheet is constructed. -=== Osheet::Workbook -* *style(selector, &block)*: define a style for the workbook -* *template(for, named, &block)*: define a named template for the workbook -* *worksheet(&block)*: define a worksheet for the workbook -# TODO: *use(module)* -# TODO: *use(file)* +Check out the wiki: https://github.com/kelredd/osheet/wiki. It covers the full Osheet API. -=== Osheet::Worksheet -* *name(value)*: set the name for this worksheet -* *column(&block)*: define a column for the worksheet -* *column(:template, *args): define a templated column for the worksheet -* *row(&block)*: define a row for the worksheet -* *row(:template, *args): define a templated row for the worksheet +== Examples -=== Xmlss::Column -* *style_class(value)*: (string) the styles selectors should match against -* *width(value)*: (numeric) set the explicit width for the column -* *auto_fit_width(value)*: (bool) set whether the column should auto fit it's width, default: false -* *hidden(value)*: (bool) set whether the column is hidden, default: false -* *meta(data)*: (anything) a generic way to associate meta-data with the column +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. -=== Xmlss::Row -* *style_class(value)*: (string) the styles selectors should match against -* *height(value)*: (numeric) set the explicit width for the column -* *auto_fit_height(value)*: (bool) set whether the row should auto fit it's height, default: false -* *hidden(value)*: (bool) set whether the row is hidden, default: false -* *cell(&block)*: define a cell for the row -* *cell(:template, *args): define a templated cell for the row - -=== Xmlss::Cell -* *style_class(value)*: (string) the styles selectors should match against -* *data(value)*: (anything), data the cell should contain. if not a string, numeric, or date, will cast data to sting using 'inspect'. -* format(value)*: (anything), optional, custom formatting string for the data (see driver documentation for options) -* *colspan(value)*: (int) the number of columns (l to r) the cell should occupy, default: 1 -* *rowspan(value)*: (int) the number of rows (t to b) the cell should occupy, default: 1 -* *href(value)*: (string) set the href the data should link to - == Links -* *GitHub* +* *Osheet* - http://github.com/kelredd/osheet -* *Spreadsheet* - - http://spreadsheet.rubyforge.org/ +* *Wiki* + - https://github.com/kelredd/osheet/wiki == License Copyright (c) 2010 and beyond, Kelly Redding (mailto:kelly@kelredd.com)