Skip to content
Saverio Miroddi edited this page Jun 28, 2017 · 1 revision

Base access

document   = Document.new
tables     = document.tables
value      = table[1, 2]
value      = table['A', 2]            # the column name is case-insensitive
row_values = table.row(1)             # no styles are included; only data

Initializing a table with data and styles

The first entry is the name; the second, the columns; the other, the rows.

document.tables << Table.new(
  'abc', [],
  [my_style,    'abc',              [my_date, my_style_3]],
  [             [123, my_style_2] , my_date              ],
]

In each row, if first entry is a Style, it's the row style.

Each data entry can have two formats:

<object>
[<object>, <style>]

An <object> can be nil.

Writing to cells

table[1, 2] = 'abc'
table[1, 3] = ['abc', my_style]
table['A', 2]  = 'abc'                # column is case-insensitive

If a cell has an value/date-value/formula, but no text, an error will be raised.

Styles

Date styles don't have the same semantic of the openoffice specification, where they are templates. here they are merged into the style concept - the layer will take care of translating between the domains.

document.styles << Style.new('style_name', :bold, date: 'YYYY-MM-DD')

Names must be unique; adding a new style with an existing name will raise an error.

Clone this wiki locally