Sha256: d5b8022061cf39a9d44b2848c46c248fc6a6412668da87890f41681ce98b9033

Contents?: true

Size: 1020 Bytes

Versions: 33

Compression:

Stored size: 1020 Bytes

Contents

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

######################################################################
#
# Example of writing repeated formulas.
#
# reverse('©'), August 2002, John McNamara, jmcnamara@cpan.org
#
# original written in Perl by John McNamara
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
#

require 'rubygems'
require 'writeexcel'

workbook  = WriteExcel.new("repeat.xls")
worksheet = workbook.add_worksheet

limit = 1000

# Write a column of numbers
0.upto(limit) do |row|
  worksheet.write(row, 0,  row)
end

# Store a formula
formula = worksheet.store_formula('=A1*5+4')

# Write a column of formulas based on the stored formula
0.upto(limit) do |row|
  worksheet.repeat_formula(row, 1, formula, nil,
                                      /A1/, 'A'+(row+1).to_s)
end

# Direct formula writing. As a speed comparison uncomment the
# following and run the program again

#for row (0..limit) {
#    worksheet.write_formula(row, 2, '=A'.(row+1).'*5+4')
#}

workbook.close

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
writeexcel-1.0.4 examples/repeat.rb
writeexcel-1.0.3 examples/repeat.rb
writeexcel-1.0.2 examples/repeat.rb
writeexcel-1.0.1 examples/repeat.rb
writeexcel-1.0.0 examples/repeat.rb
writeexcel-0.6.19 examples/repeat.rb
writeexcel-0.6.18 examples/repeat.rb
writeexcel-0.6.17 examples/repeat.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.16/examples/repeat.rb
writeexcel-0.6.16 examples/repeat.rb
writeexcel-0.6.15 examples/repeat.rb
writeexcel-0.6.14 examples/repeat.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/repeat.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/repeat.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/repeat.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/repeat.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/repeat.rb
writeexcel-0.6.13 examples/repeat.rb
ricardoo27-writeexcel-0.6.12.2 examples/repeat.rb
ricardoo27-writeexcel-0.6.12.1 examples/repeat.rb