Sha256: cb1b4758de573ea357779334e7d5172db1557098aa955228d7e362b4d7659a21

Contents?: true

Size: 1.73 KB

Versions: 51

Compression:

Stored size: 1.73 KB

Contents

# -*- coding: utf-8 -*-
require 'helper'
require 'write_xlsx'
require 'stringio'

class TestRepeatFormula < Test::Unit::TestCase
  def setup
    @workbook = WriteXLSX.new(StringIO.new)
    @worksheet = @workbook.add_worksheet('')
  end

  def test_repeat_formula
    format = nil

    expected = 'SUM(A1:A10)'
    row = 1
    col = 0
    formula = @worksheet.store_formula('=SUM(A1:A10)')
    @worksheet.repeat_formula(row, col, formula, format)
    result = @worksheet.instance_variable_get(:@cell_data_table)[row][col].token
    assert_equal(expected, result)

    expected = 'SUM(A2:A10)'
    row = 2
    col = 0
    formula = @worksheet.store_formula('=SUM(A1:A10)')
    @worksheet.repeat_formula(row, col, formula, format, 'A1', 'A2')
    result = @worksheet.instance_variable_get(:@cell_data_table)[row][col].token
    assert_equal(expected, result)

    expected = 'SUM(A2:A10)'
    row = 3
    col = 0
    formula = @worksheet.store_formula('=SUM(A1:A10)')
    @worksheet.repeat_formula(row, col, formula, format, /^A1$/, 'A2')
    result = @worksheet.instance_variable_get(:@cell_data_table)[row][col].token
    assert_equal(expected, result)

    expected = 'A2+A2'
    row = 4
    col = 0
    formula = @worksheet.store_formula('A1+A1')
    @worksheet.repeat_formula(row, col, formula, format, 'A1', 'A2', 'A1', 'A2')
    result = @worksheet.instance_variable_get(:@cell_data_table)[row][col].token
    assert_equal(expected, result)

    expected = 'A10 + SIN(A10)'
    row = 5
    col = 0
    formula = @worksheet.store_formula('A1 + SIN(A1)')
    @worksheet.repeat_formula(row, col, formula, format, /^A1$/, 'A10', /^A1$/, 'A10')
    result = @worksheet.instance_variable_get(:@cell_data_table)[row][col].token
    assert_equal(expected, result)
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
write_xlsx-0.86.0 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.11 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.10 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.9 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.8 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.7 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.6 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.5 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.4 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.3 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.2 test/worksheet/test_repeat_formula.rb
write_xlsx-0.85.1 test/worksheet/test_repeat_formula.rb
write_xlsx-0.83.0 test/worksheet/test_repeat_formula.rb
write_xlsx-0.81.1 test/worksheet/test_repeat_formula.rb
write_xlsx-0.81.0 test/worksheet/test_repeat_formula.rb
write_xlsx-0.80.0 test/worksheet/test_repeat_formula.rb
write_xlsx-0.79.0 test/worksheet/test_repeat_formula.rb
write_xlsx-0.78.0 test/worksheet/test_repeat_formula.rb
write_xlsx-0.77.2 test/worksheet/test_repeat_formula.rb
write_xlsx-0.77.1 test/worksheet/test_repeat_formula.rb