From: Aldric Giacomoni Date: 2008-11-18T02:06:39+09:00 Subject: Re: Tread on eggs.. Using metaprogramming to set a variable name? Thanks for doing the checking I should have done :( I got so caught up in my code that I forgot to extract and test it myself. I had tested, but via irb, when you ask for the spreadsheet, it gives you a very detailed Object, including name of the spreadsheet and I wasn't seeing it - so I assumed incorrectly that there was a problem there. When you gave me a kick, I had no choice but to go and check somewhere else. Turns out the problem was, guess what, later in the code I was working with unsupported data. :) Thanks again! Chris Lowis wrote: >> Is this possible? I can't wrap my head around it.. But I feel like it >> must be possible. > > This works fine for me : > > require 'rubygems' > require 'spreadsheet' > > book = Spreadsheet::Workbook.new > > loc = ['USA','Europe','Rest_of_world'] > loc.each do |name| > book.create_worksheet(:name => name) > end > > book.write './excel-file.xls' > > > Your version with a hash for loc also worked for me, but I think the > above code is a little cleaner. What problems were you having exactly ? > > Chris