Problem writing file for Excel with spreadsheet

I am trying to write an excel file using Ruby 1.6 version 1.9 for Windows. Everything is going well until I get the book.write statement when I write book.write "c:/spreadsheet/excel-file.xls

I keep getting the following error No such file or directory - c: /spreadsheet/excel-file.xls when I run it from ruby ​​console I get errono :: EINVAL Invalid argument. when i check the path i can see that the file was created but although i write it empty

Can anyone tell me what to do?

thanks

+2


a source to share


3 answers


Don't use windows!

According to http://pullmonkey.com/2008/02/19/errno-einval-invalid-argument/



STDOUT doesn't exist if you run mongrel as a service under windows and the result is errono :: EINVAL.

+1


a source


We had the same problem.



require 'rubygems'
require 'logger'
require 'spreadsheet'
require 'stringio'

workbook = Spreadsheet::Workbook.new
worksheet = workbook.create_worksheet
worksheet[0, 0] = "Hello, World!"

ostream = StringIO.new    

workbook.write (ostream)

ostream.rewind

File.open("aFile.xls","wb") do |f|
  f.write(ostream.read)
end

puts "Done!"

      

+1


a source


We decided that using libraries for excel is fragile. We are using CSV with ".xls" extension. What for? Because Excel doesn't show this nasty import area. It just opens it like a regular file. Users won't notice the difference.

0


a source







All Articles