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.81.0 examples/array_formula.rb
write_xlsx-0.80.0 examples/array_formula.rb
write_xlsx-0.79.0 examples/array_formula.rb
write_xlsx-0.78.0 examples/array_formula.rb
write_xlsx-0.77.2 examples/array_formula.rb
write_xlsx-0.77.1 examples/array_formula.rb
write_xlsx-0.77.0 examples/array_formula.rb
write_xlsx-0.76.3 examples/array_formula.rb
write_xlsx-0.76.2 examples/array_formula.rb
write_xlsx-0.76.1 examples/array_formula.rb
write_xlsx-0.76.0 examples/array_formula.rb
write_xlsx-0.75.0 examples/array_formula.rb
write_xlsx-0.74.0 examples/array_formula.rb
write_xlsx-0.73.0 examples/array_formula.rb
write_xlsx-0.72.3.beta1 examples/array_formula.rb
write_xlsx-0.72.2 examples/array_formula.rb
write_xlsx-0.72.1 examples/array_formula.rb
write_xlsx-0.72.0 examples/array_formula.rb
write_xlsx-0.71.0 examples/array_formula.rb
write_xlsx-0.70.0 examples/array_formula.rb