Sha256: 04939203b5ce91396b983d8c85db703250dcc324336793f4822dad4630108e6b

Contents?: true

Size: 1.34 KB

Versions: 15

Compression:

Stored size: 1.34 KB

Contents

module RubyFromExcel

  class SharedFormulaDependencyBuilder < DependencyBuilder
    attr_accessor :shared_formula_offset
  
    def initialize(formula_cell = nil, shared_formula_offset = nil)
      super formula_cell
      self.shared_formula_offset = shared_formula_offset
    end
  
    def cell(reference)
      self.dependencies << Reference.new(reference,worksheet).shift!(shared_formula_offset).to_ruby(true)
      Reference.new(reference).to_ruby
    end
  
    def function(name,*args)
      if name == "INDIRECT"
        args.first.visit(self)
        dependencies_for SharedFormulaBuilder.new(formula_cell,shared_formula_offset).indirect_function(args.first)
      else
        args.each { |a| a.visit(self) }
      end
    end
  
    alias area_without_offset area
  
    def area(start_area,end_area)
      self.dependencies.concat Area.new(worksheet,Reference.new(start_area).shift!(shared_formula_offset).to_ruby,Reference.new(end_area).shift!(shared_formula_offset).to_ruby).dependencies
    end
  
    def dependencies_for(full_reference)
      return [] unless full_reference  =~ /(sheet\d+)\.(.*)/
      sheet_name, reference = $1, $2
      using_worksheet(sheet_name) do
        case reference
        when /a\('(.*?)','(.*?)'\)/; area_without_offset($1,$2)
        else; self.dependencies << full_reference
        end
      end    
    end
  
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rubyfromexcel-0.0.23 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.22 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.21 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.20 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.19 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.18 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.17 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.16 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.13 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.10 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.9 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.7 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.6 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.5 lib/optimiser/shared_formula_dependency_builder.rb
rubyfromexcel-0.0.4 lib/optimiser/shared_formula_dependency_builder.rb