Spreadsheet

Library to generate OpenDocument Spreadsheet documents.

Example

sheet = Spreadsheet::Builder.new
sheet.spreadsheet do
  sheet.table 'Time report (simple)' do
    sheet.row {
      sheet.cell 'Developing spreadsheet library'
      sheet.cell 80.0
    }
    sheet.row {
      sheet.cell 'Writing spreadsheet library documentation'
      sheet.cell 2.0
    }
  end

  sheet.table 'Time report (rich)' do
    sheet.column :width => '4in'
    sheet.column :width => '0.5in'

    sheet.header {
      sheet.row {
        sheet.cell 'Time report', :span => 2, :style => 'title'
      }
      sheet.row {
        sheet.cell 'Activity', :align => :left
        sheet.cell 'Hours'
      }
    }

    sheet.row {
      sheet.string_cell 'Developing spreadsheet library'
      sheet.numeric_cell 80.0
    }
    sheet.row {
      sheet.string_cell 'Writing spreadsheet library documentation'
      sheet.numeric_cell 2.0
    }
  end
end

File.open('time_report.ods', 'wb') { |f| f.write sheet.content! }

Copyright © 2009 Maxim Kulkin, released under the MIT license