Class: Spreadsheet::Excel::Worksheet

Inherits:
Worksheet
  • Object
show all
Includes:
Offset
Defined in:
lib/spreadsheet/excel/worksheet.rb

Overview

to use any of these.

Instance Attribute Summary collapse

Attributes included from Offset

#changes, #offsets

Attributes inherited from Worksheet

#columns, #merged_cells, #name, #password_hash, #selected, #workbook

Instance Method Summary collapse

Methods included from Offset

append_features

Methods included from Compatibility

#ivar_name, #method_name

Methods inherited from Worksheet

#[], #[]=, #active, #active=, #add_format, #cell, #column_count, #column_updated, #default_format, #default_format=, #delete_row, #dimensions, #encoding, #format_column, #format_dates!, #insert_row, #inspect, #last_row, #last_row_index, #merge_cells, #new_format_column, #protect!, #protected?, #replace_row, #row_count, #update_row, #updated_from, #write, #write_column, #write_row, #write_url

Methods included from Datatypes

append_features

Constructor Details

#initialize(opts = {}) ⇒ Worksheet

Returns a new instance of Worksheet.



15
16
17
18
19
20
21
22
23
# File 'lib/spreadsheet/excel/worksheet.rb', line 15

def initialize opts = {}
  @row_addresses = nil
  super
  @offset, @ole, @reader = opts[:offset], opts[:ole], opts[:reader]
  @dimensions = nil
  @links = {}
  @guts = {}
  @notes = {}
end

Instance Attribute Details

#gutsObject (readonly)

Returns the value of attribute guts.



14
15
16
# File 'lib/spreadsheet/excel/worksheet.rb', line 14

def guts
  @guts
end

Returns the value of attribute links.



14
15
16
# File 'lib/spreadsheet/excel/worksheet.rb', line 14

def links
  @links
end

#notesObject (readonly)

Returns the value of attribute notes.



14
15
16
# File 'lib/spreadsheet/excel/worksheet.rb', line 14

def notes
  @notes
end

#offsetObject (readonly)

Returns the value of attribute offset.



14
15
16
# File 'lib/spreadsheet/excel/worksheet.rb', line 14

def offset
  @offset
end

#oleObject (readonly)

Returns the value of attribute ole.



14
15
16
# File 'lib/spreadsheet/excel/worksheet.rb', line 14

def ole
  @ole
end

Instance Method Details



24
25
26
# File 'lib/spreadsheet/excel/worksheet.rb', line 24

def add_link row, column, link
  @links.store [row, column], link
end

#add_note(row, column, note) ⇒ Object



27
28
29
# File 'lib/spreadsheet/excel/worksheet.rb', line 27

def add_note row, column, note
  @notes.store [row, column], note
end

#column(idx) ⇒ Object



30
31
32
33
# File 'lib/spreadsheet/excel/worksheet.rb', line 30

def column idx
  ensure_rows_read
  super
end

#date_baseObject



34
35
36
# File 'lib/spreadsheet/excel/worksheet.rb', line 34

def date_base
  @workbook.date_base
end

#each(*args) ⇒ Object



45
46
47
48
# File 'lib/spreadsheet/excel/worksheet.rb', line 45

def each *args
  ensure_rows_read
  super
end

#ensure_rows_readObject



49
50
51
52
53
54
# File 'lib/spreadsheet/excel/worksheet.rb', line 49

def ensure_rows_read
  return if @row_addresses
  @dimensions = nil
  @row_addresses = []
  @reader.read_worksheet self, @offset if @reader
end

#marginsObject



37
38
39
40
# File 'lib/spreadsheet/excel/worksheet.rb', line 37

def margins
  ensure_rows_read
  super
end

#pagesetupObject



41
42
43
44
# File 'lib/spreadsheet/excel/worksheet.rb', line 41

def pagesetup
  ensure_rows_read
  super
end

#row(idx) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/spreadsheet/excel/worksheet.rb', line 55

def row idx
  @rows[idx] or begin
    ensure_rows_read
    if addr = @row_addresses[idx]
      row = @reader.read_row self, addr
      [:default_format, :height, :outline_level, :hidden, ].each do |key|
        row.send "unupdated_#{key}=", addr[key]
      end
      row.worksheet = self
      row
    else
      Row.new self, idx
    end
  end
end

#row_updated(idx, row) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/spreadsheet/excel/worksheet.rb', line 73

def row_updated idx, row
  res = super
  @workbook.changes.store self, true
  @workbook.changes.store :boundsheets, true
  @changes.store idx, true
  @changes.store :dimensions, true
  res
end

#rowsObject



70
71
72
# File 'lib/spreadsheet/excel/worksheet.rb', line 70

def rows
  self.to_a
end

#set_row_address(idx, opts) ⇒ Object



81
82
83
84
# File 'lib/spreadsheet/excel/worksheet.rb', line 81

def set_row_address idx, opts
  @offsets.store idx, opts[:row_block]
  @row_addresses[idx] = opts
end

#shared_string(idx) ⇒ Object



85
86
87
# File 'lib/spreadsheet/excel/worksheet.rb', line 85

def shared_string idx
  @workbook.shared_string idx
end