Sha256: 6abf149847f142859720851175c8ed191c3f80bd8e23dc0b31435e0390b2661d

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

module RubyFromExcel
  class SharingFormulaCell < FormulaCell
  
    attr_accessor :sharing_range
  
    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
  
    def alter_other_cells_if_required
      share_formula
    end
  
    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
  
    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
  
    def offset_from(cell)
      cell.reference - self.reference
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubyfromexcel-0.0.23 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.22 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.21 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.20 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.19 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.18 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.17 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.16 lib/cells/shared/sharing_formula_cell.rb
rubyfromexcel-0.0.13 lib/cells/shared/sharing_formula_cell.rb