Module: Ruport::Data::Table::FromXLS

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

Overview

Overview

This module provides facilities for creating tables from Excel spreadsheet file (xls).

Instance Method Summary collapse

Instance Method Details

#load_xls(xls_file, options = {}) ⇒ Object

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

Example:

# Load data from an Excel xls file with defaults
table = Table.load_xls('myspreadsheet.xls')

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

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

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


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

def load_xls(xls_file, options={})
  get_table_from_xls_file(xls_file, options)
end

#parse_xls(xls_object, options = {}) ⇒ Object

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

Example:

# parse excel object with defaults. 
table = Table.parse_xls(excel_object)

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

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

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


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

def parse_xls(xls_object, options={})
  get_table_from_xls(xls_object, options)
end