Sha256: fef1867a5f2090ad93d2e628bd95938724df7f3b3b9946cbb67ee639b894ac90

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

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

#######################################################################
#
# A simple example of how to use the Excel::Writer::XLSX module to
# write text and numbers to an Excel xlsx file.
#
# reverse(c), March 2001, John McNamara, jmcnamara@cpan.org
# convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
#

require 'write_xlsx'

# Create a new workbook called simple.xls and add a worksheet
workbook  = WriteXLSX.new('a_simple.xlsx')
worksheet = workbook.add_worksheet

# The general syntax is write(row, column, token). Note that row and
# column are zero indexed
#

# Write some text
worksheet.write(0, 0, "Hi Excel!")

# Write some numbers
worksheet.write(2, 0, 3)          # Writes 3
worksheet.write(3, 0, 3.00000)    # Writes 3
worksheet.write(4, 0, 3.00001)    # Writes 3.00001
worksheet.write(5, 0, 3.14159)    # TeX revision no.?

# Write some formulas
worksheet.write(7, 0, '=A3 + A6')
worksheet.write(8, 0, '=IF(A5>3,"Yes", "No")')

# Write a hyperlink
worksheet.write(10, 0, 'http://www.ruby-lang.org/')

workbook.close

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
write_xlsx-1.00.0 examples/a_simple.rb
write_xlsx-0.99.0 examples/a_simple.rb
write_xlsx-0.97.0 examples/a_simple.rb