I am writing a script that uses Spreadsheet because I need to output data in an excel document. More specifically, I want to create one workbook with multiple worksheets within it. So, I used this approach:
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet::Workbook.new
book.worksheets.each do |sheet|
sheet.each do |row|
# data to be written
end
end
Unfortunately, this didn't work. Alternatively, I tried this to test it out:
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet::Workbook.new
for i in 0..2
sheet= book.create_worksheet :name => i
sheet.row(0).push "data"
end
This didn't work either. So, my question is how do you suggest I do this? As I said before what I'm trying to do is to create one excel document with a fixed and predetermined number of sheets.
Please let me know if you have any advice on how I can achieve this.
Thank you