Class: POI::Area
- Inherits:
-
Object
- Object
- POI::Area
- Defined in:
- lib/poi/workbook/area.rb
Instance Method Summary collapse
- #in(workbook) ⇒ Object
-
#initialize(reference) ⇒ Area
constructor
A new instance of Area.
- #single_cell_reference? ⇒ Boolean
Constructor Details
#initialize(reference) ⇒ Area
Returns a new instance of Area.
3 4 5 |
# File 'lib/poi/workbook/area.rb', line 3 def initialize reference @ref = reference end |
Instance Method Details
#in(workbook) ⇒ Object
7 8 9 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 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/poi/workbook/area.rb', line 7 def in workbook if single_cell_reference? ref = area.all_referenced_cells.first return [workbook.single_cell, ref] end begin by_column = {} # refs = area.all_referenced_cells # slices = refs.enum_slice(refs.length/15) # slices.collect do |cell_refs| # Thread.start do # cell_refs.each do |cell_ref| # first = workbook.worksheets[cell_ref.sheet_name].first_row # last = workbook.worksheets[cell_ref.sheet_name].last_row # next unless cell_ref.row >= first && cell_ref.row <= last # # # ref = POI::CELL_REF.new(c.format_as_string) # cell = workbook.single_cell cell_ref # (by_column[cell_ref.cell_ref_parts.collect.last] ||= []) << cell # end # end # end.each {|t| t.join} area.all_referenced_cells.each do |cell_ref| first = workbook.worksheets[cell_ref.sheet_name].first_row last = workbook.worksheets[cell_ref.sheet_name].last_row next unless cell_ref.row >= first && cell_ref.row <= last # ref = POI::CELL_REF.new(c.format_as_string) cell = workbook.single_cell cell_ref (by_column[cell_ref.cell_ref_parts.collect.last] ||= []) << cell end by_column.each do |key, cells| by_column[key] = cells.compact end if by_column.length == 1 by_column.values.flatten else by_column end rescue [] end end |
#single_cell_reference? ⇒ Boolean
55 56 57 |
# File 'lib/poi/workbook/area.rb', line 55 def single_cell_reference? area.single_cell? #@ref == getFirstCell.formatAsString rescue false end |