Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.25 KB

File metadata and controls

44 lines (30 loc) · 1.25 KB

This is a library for writing to ODF output with Ruby. It currently only supports creating spreadsheets (ODS). Text documents (ODT) and slide shows (ODP) may be added some time in the future.

This is NOT an ODF reading library.

You should be able to install the latest stable version by saying something like

sudo gem install rodf

rODF works pretty much like Builder, but with ODF-aware constructs. Try this:

require 'odf/spreadsheet'

ODF::SpreadSheet.file("my-spreadsheet.ods") do |spreadsheet|
  spreadsheet.table 'My first table from Ruby' do |table|
    table.row {|row|  row.cell 'Hello, rODF world!' }
  end
end

Some basic formatting is also possible:

require 'odf/spreadsheet'

ODF::SpreadSheet.file("my-spreadsheet.ods") do |spreadsheet|
  spreadsheet.style 'red-cell', :family => :cell do |style|
    style.property :text, 'font-weight' => 'bold', 'color' => '#ff0000'
  end
  spreadsheet.table 'Red text table' do |table|
    table.row {|row|  row.cell 'Red', :style => 'red-cell' }
  end
end

The ODF spec doesn’t allow :type to be set for cells with no values or formulas. It’s up to users to ensure that cells are not passed nil values for :type s other than :string