Sha256: 20eacefc643e4eccc03c033ae775a02a5a1ed92bfbd0b5947fd3403eb381dd0f

Contents?: true

Size: 837 Bytes

Versions: 33

Compression:

Stored size: 837 Bytes

Contents

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

require 'write_xlsx'

workbook   = WriteXLSX.new('defined_name.xlsx')
worksheet1 = workbook.add_worksheet
worksheet2 = workbook.add_worksheet

# Define some global/workbook names.
workbook.define_name('Exchange_rate', '=0.96')
workbook.define_name('Sales',         '=Sheet1!$G$1:$H$10')

# Define a local/worksheet name.
workbook.define_name('Sheet2!Sales', '=Sheet2!$G$1:$G$10')

# Write some text in the file and one of the defined names in a formula.
workbook.worksheets.each do |worksheet|
    worksheet.set_column('A:A', 45)
    worksheet.write('A1', 'This worksheet contains some defined names.')
    worksheet.write('A2', 'See Formulas -> Name Manager above.')
    worksheet.write('A3', 'Example formula in cell B3 ->')

    worksheet.write('B3', '=Exchange_rate')
end

workbook.close

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
write_xlsx-1.09.4 examples/defined_name.rb
write_xlsx-1.09.3 examples/defined_name.rb
write_xlsx-1.09.2 examples/defined_name.rb
write_xlsx-1.09.1 examples/defined_name.rb
write_xlsx-1.09.0 examples/defined_name.rb
write_xlsx-1.08.2 examples/defined_name.rb
write_xlsx-1.08.1 examples/defined_name.rb
write_xlsx-1.08.0 examples/defined_name.rb
write_xlsx-1.07.0 examples/defined_name.rb
write_xlsx-1.04.0 examples/defined_name.rb
write_xlsx-1.02.0 examples/defined_name.rb
write_xlsx-1.01.0 examples/defined_name.rb
write_xlsx-1.00.0 examples/defined_name.rb
write_xlsx-0.99.0 examples/defined_name.rb
write_xlsx-0.97.0 examples/defined_name.rb
write_xlsx-0.90.0 examples/defined_name.rb
write_xlsx-0.89.0 examples/defined_name.rb
write_xlsx-0.88.0 examples/defined_name.rb
write_xlsx-0.87.0 examples/defined_name.rb
write_xlsx-0.86.0 examples/defined_name.rb