-1

I am attempting to write a multi-dimensional array to an Excel file (extension .xls) using the WriteExcel Ruby gem on El Capitan.

My attempt:

# -*- coding:utf-8 -*-
require 'writeexcel'

# Create a new Excel workbook
workbook = WriteExcel.new('ruby.xls')

# Add a worksheet
worksheet = workbook.add_worksheet

eec =  [
  ['maggie', 'milly', 'molly', 'may'  ],
  [13,       14,      15,      16     ],
  ['shell',  'star',  'crab',  'stone']
  ]

worksheet.write_col('A1', \@eec)

workbook.close

The error I get:

iMac:scrapScripts guy$ ruby script.rb
script.rb:16: syntax error, unexpected $undefined, expecting ')'
worksheet.write_col('A1', \@eec)
                           ^

Using the gem documentation found here.

Can anyone explain why this syntax error is occurring, and how I can fix it?

Matt
  • 74,352
  • 26
  • 153
  • 180
Mike
  • 1,080
  • 1
  • 9
  • 25

1 Answers1

3

Remove garbage symbols from the call to write_col:

- worksheet.write_col('A1', \@eec)
+ worksheet.write_col('A1', eec)
Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160