Specifically what I am trying to do is add new worksheets alongside ones already there. I\'ve tried to use book.create_worksheet :name => \'new_sheet\'
but it ov
I found out that you can create many sheets with the same variable, you just have to change the name you put on it. For example:
articles.each do |art| sheet1 = book.create_worksheet :name => art.code end
book.create_worksheet(:name => 'unique_name')
works for me!
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet(:name => 'AAA')
sheet2 = book.create_worksheet(:name => 'BBB')
sheet1.row(0).concat %w{Name Country Acknowlegement}
sheet1[1,0] = 'Japan'
row = sheet1.row(1)
row.push 'Creator of Ruby'
row.unshift 'Yukihiro Matsumoto'
sheet1.row(2).replace [ 'Daniel J. Berger', 'U.S.A.',
'Author of original code for Spreadsheet::Excel' ]
sheet1.row(3).push 'Charles Lowe', 'Author of the ruby-ole Library'
sheet1.row(3).insert 1, 'Unknown'
sheet1.update_row 4, 'Hannes Wyss', 'Switzerland', 'Author'
sheet2.row(0).concat %w{NAME COUNYRY ACK}
sheet2[1,0] = 'JAPAN'
row = sheet2.row(1)
row.push 'CREATOR OF RUBY'
row.unshift 'YUKIHIRO MATSUMOTO'
sheet2.row(2).replace [ 'DANIEL J. BERGER', 'U.S.A.',
'AUTHOR OF ORIGINAL CODE FOR Spreadsheet::Excel' ]
sheet2.row(3).push 'CHARLES LOWE', 'AUTHOR OF THE RUBY-OLE LIBRARY'
sheet2.row(3).insert 1, 'UNKNOWN'
sheet2.update_row 4, 'HANNES WYSS', 'SWITZERLAND', 'AUTHOR'
book.write '/Users/stephen/tmp/test2.xls'
The above, lifted pretty much verbatim from the documentation works a treat.