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