Module: Ruport::Data::Table::FromODS

Included in:
Ruport::Data::Table
Defined in:
lib/ruport/util/ods_table.rb

Overview

Overview

This module provides facilities for creating tables from Openoffice spreadsheet file (ods).

Instance Method Summary collapse

Instance Method Details

#load_ods(ods_file, options = {}) ⇒ Object

Loads a ods file directly into a Table using the roo library.

Example:

# Load data from Openoffice ods file with defaults
table = Table.load_ods('myspreadsheet.ods')

# do not assume the data has column names - default is false.
table = Table.load_ods('myspreadsheet.ods',{:has_column_names => false})

# Select sheet - default is the first sheet.
table = Table.load_ods('myspreadsheet.ods', {:select_sheet => 1})

# Start row - default is the first row. Use this to override where
              the first row should start.
table = Table.load_ods('myspreadsheet.ods', {:start_row => 1})


39
40
41
# File 'lib/ruport/util/ods_table.rb', line 39

def load_ods(ods_file, options={})
  get_table_from_ods_file(ods_file, options)
end

#parse_ods(ods_object, options = {}) ⇒ Object

Creates a Table from an Openoffice object (from roo library).

Example:

# parse openoffice object with defaults. 
table = Table.parse_ods(openoffice_object)

# do not assume the data has column names.
table = Table.parse_ods(openoffice_object,{:has_column_names => false})

# Select sheet - default is the first sheet.
table = Table.parse_ods(openoffice_object, {:select_sheet => 1})

# Start row - default is the first row. Use this to override where
              the first row should start.
table = Table.parse_ods('myspreadsheet.ods', {:start_row => 1})


60
61
62
# File 'lib/ruport/util/ods_table.rb', line 60

def parse_ods(ods_object, options={})
  get_table_from_ods(ods_object, options)
end