= 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. == Installation $ gem install osheet == Basic Example 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' wb = Osheet::Workbook.new { 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 ) } 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 } data.each do |name, stats| row { # data row cell { data name } stats.each do |stat| cell { data stat } end } end } # worksheet } # workbook file = wb.to_file('stats') # => == 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)* === 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 === 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 === 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* - http://github.com/kelredd/osheet * *Spreadsheet* - http://spreadsheet.rubyforge.org/ == License Copyright (c) 2010 and beyond, Kelly Redding (mailto:kelly@kelredd.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.