Method: Roo::OpenOffice#initialize

Defined in:
lib/roo/open_office.rb

#initialize(filename, options = {}) ⇒ OpenOffice

initialization and opening of a spreadsheet file values for packed: :zip



10
11
12
13
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
39
40
41
# File 'lib/roo/open_office.rb', line 10

def initialize(filename, options={})
  packed = options[:packed]
  file_warning = options[:file_warning] || :error

  @only_visible_sheets = options[:only_visible_sheets]
  file_type_check(filename,'.ods','an Roo::OpenOffice', file_warning, packed)
  @tmpdir = make_tmpdir(filename.split('/').last, options[:tmpdir_root])
  @filename = local_filename(filename, @tmpdir, packed)
  #TODO: @cells_read[:default] = false
  Zip::File.open(@filename) do |zip_file|
    if content_entry = zip_file.glob("content.xml").first
      roo_content_xml_path = File.join(@tmpdir, 'roo_content.xml')
      content_entry.extract(roo_content_xml_path)
      decrypt_if_necessary(
        zip_file,
        content_entry,
        roo_content_xml_path,
        options
      )
    else
      raise ArgumentError, 'file missing required content.xml'
    end
  end
  super(filename, options)
  @formula = Hash.new
  @style = Hash.new
  @style_defaults = Hash.new { |h,k| h[k] = [] }
  @table_display = Hash.new { |h,k| h[k] = true }
  @font_style_definitions = Hash.new
  @comment = Hash.new
  @comments_read = Hash.new
end