Speadsheet not works under ocra

89 views
Skip to first unread message

Антон Буков

unread,
Feb 20, 2012, 3:12:43 AM2/20/12
to ruby...@googlegroups.com
Hello, i have a problem...
My ruby app works nice, but after packing by ocra i have following error, while opening ANY xls file:

undefined method `read_string' for #<Spreadsheet::Excel::Reader:0x2097288>
C:/Users/Admin/AppData/Local/Temp/ocr368C.tmp/lib/ruby/gems/1.9.1/gems/spreadsheet-0.6.8/lib/spreadsheet/excel/reader.rb:288:in `read_font'
C:/Users/Admin/AppData/Local/Temp/ocr368C.tmp/lib/ruby/gems/1.9.1/gems/spreadsheet-0.6.8/lib/spreadsheet/excel/reader.rb:826:in `read_workbook'
C:/Users/Admin/AppData/Local/Temp/ocr368C.tmp/lib/ruby/gems/1.9.1/gems/spreadsheet-0.6.8/lib/spreadsheet/excel/reader.rb:122:in `read'
C:/Users/Admin/AppData/Local/Temp/ocr368C.tmp/lib/ruby/gems/1.9.1/gems/spreadsheet-0.6.8/lib/spreadsheet/excel/workbook.rb:32:in `open'
C:/Users/Admin/AppData/Local/Temp/ocr368C.tmp/lib/ruby/gems/1.9.1/gems/spreadsheet-0.6.8/lib/spreadsheet.rb:62:in `open'
C:/Users/Admin/AppData/Local/Temp/ocr368C.tmp/lib/ruby/gems/1.9.1/gems/spreadsheet-0.6.8/lib/spreadsheet.rb:68:in `open' 

I have asked the same question in Spreadsheet group here: https://groups.google.com/d/topic/rubyspreadsheet/IQVpW8ulbyI/discussion

Антон Буков

unread,
Feb 20, 2012, 3:14:04 AM2/20/12
to ruby...@googlegroups.com
My specs:

Windows 7 Pro x86
Ruby 1.9.3p0 (by RubyInstaller)
spreadsheet-0.6.8 (by gem)
ocra-1.3.0 (by gem)

Антон Буков

unread,
Feb 21, 2012, 7:13:54 AM2/21/12
to ruby...@googlegroups.com
I've solved a problem. 

While packing my script into EXE, ocra runs it. 
But my script without arguments does nothing...
I just wrote: Spreadsheet.open('MyDoc.xls')

clayton cottingham

unread,
Dec 2, 2012, 2:02:39 AM12/2/12
to ruby...@googlegroups.com, k06...@gmail.com
I dont quite understand this solution
can you elaborate or provide an example?

i have a method that starts like this 
if run as script fine. but as an ocra exe it errors out w same undef method read_string

def import(file)
  xls = Spreadsheet.open(file)
 # errors out at this point

end










 

Антон Буков

unread,
Dec 2, 2012, 2:16:22 AM12/2/12
to ruby...@googlegroups.com
While OCRA packs script into EXE, it runs it and remember all script dependencies. OCRA runs your script without any arguments and your script does nothing (i think). Your script should open any local XLS when OCRA runs in. So OCRA will recognize all dependencies correctly.

clayton cottingham

unread,
Dec 2, 2012, 3:04:09 AM12/2/12
to ruby...@googlegroups.com
awesome that totally worked!
at start of my script i just Spreadsheet.open('local.xls') and if found everything correctly

as a side note i had to run ocra with --no-autoload as activerecord modules in my script were failing without it due to the RbConfig issue.

here is how i got active_record running w no autoload. this order is required{heh} in order for it to work. you may have to adjust the adapter line to set to your db adapter if not using sql server

require 'ODBC'
require 'active_support/notifications/instrumenter'
require 'active_record'
require 'active_record/dynamic_finder_match'
require 'active_record/dynamic_scope_match'
require 'active_record/connection_adapters/sqlserver/core_ext/odbc'
require 'activerecord-sqlserver-adapter'
require 'active_record/result'



On Sat, Dec 1, 2012 at 11:16 PM, Антон Буков <k06...@gmail.com> wrote:
While OCRA packs script into EXE, it runs it and remember all script dependencies. OCRA runs your script without any arguments and your script does nothing (i think). Your script should open any local XLS when OCRA runs in. So OCRA will recognize all dependencies correctly.



--
Clayton Cottingham - WinterMarket Networks
Phone: (604) 417-3254 (702) 426-4465
http://www.wintermarket.net
aim: drfrogrx msn: drfr...@hotmail.com
gmail: drfr...@gmail.com

clayton cottingham

unread,
Dec 2, 2012, 3:16:36 AM12/2/12
to ruby...@googlegroups.com
upon further investigation i figured out a bit more

my app is a ruby-gtk app.

so when ocra loads the script to check for dependencies if i use all functionality in the app ocra detects my call to spreadsheet and includes the gem!

no need for extraneous first call to Spreadsheet

thanks again for your help

clayton cottingham

unread,
Dec 2, 2012, 3:23:32 AM12/2/12
to ruby...@googlegroups.com
sorry for further email but this may be useful to others

all the extra active record requires  were unnecessary if i used all the functionality in my app so ocra could find their deps too
Reply all
Reply to author
Forward
0 new messages