Class: RubyFromExcel::SharingFormulaCell
- Inherits:
-
FormulaCell
- Object
- Cell
- FormulaCell
- RubyFromExcel::SharingFormulaCell
- Defined in:
- lib/cells/shared/sharing_formula_cell.rb
Instance Attribute Summary collapse
-
#sharing_range ⇒ Object
Returns the value of attribute sharing_range.
Attributes inherited from FormulaCell
Attributes inherited from Cell
#dependencies, #reference, #worksheet, #xml_type, #xml_value
Instance Method Summary collapse
- #alter_other_cells_if_required ⇒ Object
- #offset_from(cell) ⇒ Object
- #parse_xml(xml) ⇒ Object
- #share_formula ⇒ Object
- #share_formula_with_cell(cell) ⇒ Object
Methods inherited from FormulaCell
#debug, #ruby_value, #work_out_dependencies
Methods inherited from Cell
#can_be_replaced_with_value?, #debug, #initialize, #inspect, #test, #to_ruby, #to_s, #to_test, #tolerance_for, #value, #value_for_including, #work_out_dependencies
Constructor Details
This class inherits a constructor from RubyFromExcel::Cell
Instance Attribute Details
#sharing_range ⇒ Object
Returns the value of attribute sharing_range.
4 5 6 |
# File 'lib/cells/shared/sharing_formula_cell.rb', line 4 def sharing_range @sharing_range end |
Instance Method Details
#alter_other_cells_if_required ⇒ Object
13 14 15 |
# File 'lib/cells/shared/sharing_formula_cell.rb', line 13 def alter_other_cells_if_required share_formula end |
#offset_from(cell) ⇒ Object
33 34 35 |
# File 'lib/cells/shared/sharing_formula_cell.rb', line 33 def offset_from(cell) cell.reference - self.reference end |
#parse_xml(xml) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/cells/shared/sharing_formula_cell.rb', line 6 def parse_xml(xml) super sharing_range = xml.at_css("f")['ref'] sharing_range = "#{sharing_range}:#{sharing_range}" unless sharing_range =~ /:/ self.sharing_range = Area.new(worksheet,*sharing_range.split(':')) end |
#share_formula ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cells/shared/sharing_formula_cell.rb', line 17 def share_formula sharing_range.to_reference_enum.each do |shared_formula_reference| next if shared_formula_reference == reference.to_s share_formula_with_cell worksheet.cell(shared_formula_reference) end end |
#share_formula_with_cell(cell) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/cells/shared/sharing_formula_cell.rb', line 24 def share_formula_with_cell(cell) return unless cell return unless cell.is_a?(SharedFormulaCell) cell.original_formula = self.original_formula cell.shared_formula = self.ast cell.shared_formula_offset = offset_from(cell) cell.debug_after_sharing end |