Class: Spreadsheet::Excel::Worksheet
- Inherits:
-
Worksheet
- Object
- Worksheet
- Spreadsheet::Excel::Worksheet
- 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
-
#guts ⇒ Object
readonly
Returns the value of attribute guts.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#ole ⇒ Object
readonly
Returns the value of attribute ole.
-
#row_addresses ⇒ Object
readonly
Returns the value of attribute row_addresses.
Attributes included from Offset
Instance Method Summary collapse
- #add_link(row, column, link) ⇒ Object
- #add_note(row, column, note) ⇒ Object
- #column(idx) ⇒ Object
- #date_base ⇒ Object
- #each(*args) ⇒ Object
- #ensure_rows_read ⇒ Object
-
#initialize(opts = {}) ⇒ Worksheet
constructor
A new instance of Worksheet.
- #margins ⇒ Object
- #pagesetup ⇒ Object
- #row(idx) ⇒ Object
- #row_updated(idx, row) ⇒ Object
- #rows ⇒ Object
- #set_row_address(idx, opts) ⇒ Object
- #shared_string(idx) ⇒ Object
Methods included from Offset
Methods included from Compatibility
Constructor Details
#initialize(opts = {}) ⇒ Worksheet
Returns a new instance of Worksheet.
16 17 18 19 20 21 22 23 24 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 16 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
#guts ⇒ Object (readonly)
Returns the value of attribute guts.
15 16 17 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 15 def guts @guts end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
15 16 17 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 15 def links @links end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
15 16 17 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 15 def notes @notes end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
15 16 17 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 15 def offset @offset end |
#ole ⇒ Object (readonly)
Returns the value of attribute ole.
15 16 17 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 15 def ole @ole end |
#row_addresses ⇒ Object (readonly)
Returns the value of attribute row_addresses.
15 16 17 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 15 def row_addresses @row_addresses end |
Instance Method Details
#add_link(row, column, link) ⇒ Object
26 27 28 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 26 def add_link row, column, link @links.store [row, column], link end |
#add_note(row, column, note) ⇒ Object
30 31 32 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 30 def add_note row, column, note @notes.store [row, column], note end |
#column(idx) ⇒ Object
34 35 36 37 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 34 def column idx ensure_rows_read super end |
#date_base ⇒ Object
39 40 41 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 39 def date_base @workbook.date_base end |
#each(*args) ⇒ Object
53 54 55 56 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 53 def each *args ensure_rows_read super end |
#ensure_rows_read ⇒ Object
58 59 60 61 62 63 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 58 def ensure_rows_read return if @row_addresses @dimensions = nil @row_addresses = [] @reader&.read_worksheet self, @offset end |
#margins ⇒ Object
43 44 45 46 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 43 def margins ensure_rows_read super end |
#pagesetup ⇒ Object
48 49 50 51 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 48 def pagesetup ensure_rows_read super end |
#row(idx) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 65 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
85 86 87 88 89 90 91 92 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 85 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 |
#rows ⇒ Object
81 82 83 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 81 def rows to_a end |
#set_row_address(idx, opts) ⇒ Object
94 95 96 97 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 94 def set_row_address idx, opts @offsets.store idx, opts[:row_block] @row_addresses[idx] = opts end |
#shared_string(idx) ⇒ Object
99 100 101 |
# File 'lib/spreadsheet/excel/worksheet.rb', line 99 def shared_string idx @workbook.shared_string idx end |