Sha256: a0efac6dbf937af057a980f9f74dffd3c2d03c9bb04d2a4704a788e35dd98991

Contents?: true

Size: 827 Bytes

Versions: 9

Compression:

Stored size: 827 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

9 entries across 9 versions & 1 rubygems

Version Path
write_xlsx-1.12.1 examples/defined_name.rb
write_xlsx-1.12.0 examples/defined_name.rb
write_xlsx-1.11.2 examples/defined_name.rb
write_xlsx-1.11.1 examples/defined_name.rb
write_xlsx-1.11.0 examples/defined_name.rb
write_xlsx-1.10.2 examples/defined_name.rb
write_xlsx-1.10.1 examples/defined_name.rb
write_xlsx-1.10.0 examples/defined_name.rb
write_xlsx-1.09.5 examples/defined_name.rb