Sha256: 49b5396a406f05716d7502f409e179272b9d2592f77767859649fe0e9e8d28bf

Contents?: true

Size: 967 Bytes

Versions: 38

Compression:

Stored size: 967 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

#######################################################################
#
# Example of how to use the WriteXLSX gem to write simple
# array formulas.
#
# reverse(c), August 2004, John McNamara, jmcnamara@cpan.org
# convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
#

require 'rubygems'
require 'write_xlsx'

# Create a new workbook and add a worksheet
workbook  = WriteXLSX.new('array_formula.xlsx')
worksheet = workbook.add_worksheet

# Write some test data.
worksheet.write('B1', [ [ 500, 10 ], [ 300, 15 ] ])
worksheet.write('B5', [ [ 1, 2, 3 ], [ 20234, 21003, 10000 ] ])

# Write an array formula that returns a single value
worksheet.write('A1', '{=SUM(B1:C1*B2:C2)}')

# Same as above but more verbose.
worksheet.write_array_formula('A2:A2', '{=SUM(B1:C1*B2:C2)}')

# Write an array formula that returns a range of values
worksheet.write_array_formula('A5:A7', '{=TREND(C5:C7,B5:B7)}')

workbook.close

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
write_xlsx-0.69.0 examples/array_formula.rb
write_xlsx-0.65.1 examples/array_formula.rb
write_xlsx-0.65.0 examples/array_formula.rb
write_xlsx-0.64.1 examples/array_formula.rb
write_xlsx-0.64.0 examples/array_formula.rb
write_xlsx-0.62.0 examples/array_formula.rb
write_xlsx-0.61.0 examples/array_formula.rb
write_xlsx-0.60.0 examples/array_formula.rb
write_xlsx-0.59.0 examples/array_formula.rb
write_xlsx-0.58.0 examples/array_formula.rb
write_xlsx-0.57.0 examples/array_formula.rb
write_xlsx-0.56.0 examples/array_formula.rb
write_xlsx-0.55.0 examples/array_formula.rb
write_xlsx-0.54.0 examples/array_formula.rb
write_xlsx-0.51.0 examples/array_formula.rb
write_xlsx-0.0.4 examples/array_formula.rb
write_xlsx-0.0.3 examples/array_formula.rb
write_xlsx-0.0.2 examples/array_formula.rb