Class: Spreadsheet::Excel::Worksheet

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

Overview

Excel-specific Worksheet methods. These are mostly pertinent to the Excel reader, and to recording changes to the Worksheet. You should have no reason 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, #rows, #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

Constructor Details

- (Worksheet) initialize(opts = {})

A new instance of Worksheet



15
16
17
18
19
20
21
22
# 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 = {}
end

Instance Attribute Details

- (Object) guts (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

- (Object) offset (readonly)

Returns the value of attribute offset



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

def offset
  @offset
end

- (Object) ole (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



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

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

- (Object) column(idx)



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

def column idx
  ensure_rows_read
  super
end

- (Object) date_base



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

def date_base
  @workbook.date_base
end

- (Object) each(*args)



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

def each *args
  ensure_rows_read
  super
end

- (Object) ensure_rows_read



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

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

- (Object) row(idx)



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/spreadsheet/excel/worksheet.rb', line 43

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

- (Object) row_updated(idx, row)



58
59
60
61
62
63
64
65
# File 'lib/spreadsheet/excel/worksheet.rb', line 58

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

- (Object) set_row_address(idx, opts)



66
67
68
69
# File 'lib/spreadsheet/excel/worksheet.rb', line 66

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

- (Object) shared_string(idx)



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

def shared_string idx
  @workbook.shared_string idx
end