Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/writeexcel/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'writeexcel'

class WriteExcel < Workbook
VERSION = "1.0.5"
VERSION = "1.0.6"
end
7 changes: 7 additions & 0 deletions lib/writeexcel/workbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def initialize(file, default_formats = {})

# Set colour palette.
set_palette_xl97

return unless block_given?
begin
yield self
ensure
close
end
end

#
Expand Down
10 changes: 10 additions & 0 deletions test/test_workbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ def test_new
assert_kind_of(Workbook, @workbook)
end

def test_new_with_block
test_file = StringIO.new
workbook = Workbook.new(test_file) do |book|
book.add_worksheet('test_block')
end

assert_kind_of(Workbook, workbook)
assert_true(test_file.closed?)
end

def test_add_worksheet
sheetnames = ['sheet1', 'sheet2']
(0 .. sheetnames.size-1).each do |i|
Expand Down