Permalink
Browse files

StringIO gave several UTF-encoding errors; use a tempfile instead

  • Loading branch information...
1 parent 44615e6 commit e2da09a775c4f766652dcbda515fa5acb27f73f8 @gwolf committed Mar 28, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/simplexls.rb
View
@@ -1,9 +1,11 @@
+# -*- coding: utf-8 -*-
### SimpleXLS - A simplistic wrapper for Spreadsheet
#
# Copyright © 2009 Gunnar Wolf <gwolf@gwolf.org>
# Instituto de Investigaciones Económicas, UNAM
#
require 'spreadsheet'
+require 'tempfile'
class SimpleXLS
# Creates a new, empty spreadsheet consisting of a single workbook
@@ -32,9 +34,10 @@ def add_row(*row)
# Gets the spreadsheet (in binary, XLS format) as a string
def to_s
- io = StringIO.new
+ io = Tempfile.new('simplexls')
@xls.write(io)
io.rewind
io.read
+ io.unlink
end
end

0 comments on commit e2da09a

Please sign in to comment.