Module: Rspreadsheet

Extended by:
Configuration
Defined in:
lib/rspreadsheet/worksheet.rb,
lib/rspreadsheet/row.rb,
lib/rspreadsheet/cell.rb,
lib/rspreadsheet/image.rb,
lib/rspreadsheet/tools.rb,
lib/rspreadsheet/column.rb,
lib/rspreadsheet/version.rb,
lib/rspreadsheet/workbook.rb,
lib/rspreadsheet/cell_format.rb,
lib/rspreadsheet/xml_tied_item.rb,
lib/rspreadsheet/xml_tied_array.rb,
lib/rspreadsheet/xml_tied_repeatable.rb,
lib/rspreadsheet.rb

Overview

Author:

  • Jakub Tesinsky

Defined Under Namespace

Modules: Tools Classes: Border, Cell, Column, Image, Row, Workbook, WorkbookFlat, WorkbookIO, Worksheet, WorksheetImages

Constant Summary collapse

StartOfEpoch =
Time.new(1899,12,30,0,0,0,0)
VERSION =
'0.5.3'

Class Method Summary collapse

Class Method Details

.new(*params) ⇒ Object

makes creating new workbooks as easy as Rspreadsheet.new or `Rspreadsheet.open('filename.ods')

Raises:

  • (ArgumentError)

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rspreadsheet.rb', line 14

def self.new(*params)
  raise ArgumentError.new("wrong number of arguments (given #{params.size}, expected 0-2)") if params.size >2 

  case params.last
    when Hash then options = params.pop 
    else options = {}
  end
  
  if options[:format].nil? # automatické heuristické rozpoznání formátu
    options[:format] = :standard
    unless params.first.nil?
      begin
        Zip::File.open(params.first)
      rescue
        options[:format] = :flat
      end
    end
  end
  
  case options[:format]
    when :flat , :fods then WorkbookFlat.new(*params)
    when :standard then Workbook.new(*params)
    else raise 'format of the file not recognized'
  end
end

.open(filename, options = {}) ⇒ Object


39
40
41
# File 'lib/rspreadsheet.rb', line 39

def self.open(filename, options = {})
  self.new(filename, options)
end