I am using https://github.com/zdavatz/spreadsheet version 0.8.3
I have code that iterates through a collection and creates a worksheet in the same workbook for each item. When the collection is empty, the code that runs looks like this:
io = StringIO.new
book = Spreadsheet::Workbook.new
book.write(io)
The last line goes up:
TypeError: can't convert nil into Integer
spreadsheet/excel/writer/workbook.rb:636:in `pack'
spreadsheet/excel/writer/workbook.rb:636:in `write_window1'
spreadsheet/excel/writer/workbook.rb:419:in `write_from_scratch'
spreadsheet/excel/writer/workbook.rb:644:in `write_workbook'
spreadsheet/writer.rb:12:in `write'
spreadsheet/workbook.rb:124:in `write'
Changing my code to this fixes:
io = StringIO.new
book = Spreadsheet::Workbook.new
book.create_worksheet if book.worksheets.empty?
book.write(io)
But I do not want to include a call create_worksheet. My questions:
a) Am I doing something wrong in my code?
b) is it a stone error or an expected failure?
source
share