Ruby 无法使用Roo或电子表格Gems打开excel
当我尝试使用Ruby 无法使用Roo或电子表格Gems打开excel,ruby,excel,spreadsheet,Ruby,Excel,Spreadsheet,当我尝试使用roo gem时: irb(main):001:0> require 'roo' => true irb(main):002:0> oo = Excel.new("C:/Users/Abash/Desktop/test1.xls") **NameError: uninitialized constant Excel** from (irb):2 from C:/Ruby193/bin/irb:12:in `<main>' irb(main):
roo gem
时:
irb(main):001:0> require 'roo'
=> true
irb(main):002:0> oo = Excel.new("C:/Users/Abash/Desktop/test1.xls")
**NameError: uninitialized constant Excel** from (irb):2
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):001:0> require 'spreadsheet'
=> true
irb(main):002:0>Spreadsheet.client_encoding = 'UTF-8'
=> "UTF-8"
irb(main):003:0> book = Spreadsheet.open 'C:/Users/Abash/Desktop/test1.xls'
**Errno::EACCES: Permission denied** - C:/Users/Abash/Desktop/test1.xls
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/spreadsheet-0.8.2/lib/spreadsheet.rb:69:in `initialize'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/spreadsheet-0.8.2/lib/spreadsheet.rb:69:in `open'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/spreadsheet-0.8.2/lib/spreadsheet.rb:69:in `open'
from (irb):3
from C:/Ruby193/bin/irb:12:in `<main>'
有人能告诉我这些错误的解决方法吗?我相信您使用的是ruby 1.9或更高版本。在这种情况下,您需要在创建新实例时指定gem
require 'roo'
s =Roo::Excel.new("myspreadsheet.xls")
s =Roo::Excelx.new("myspreadsheet.xlsx")
我相信您使用的是ruby 1.9或更高版本。在这种情况下,您需要在创建新实例时指定gem
require 'roo'
s =Roo::Excel.new("myspreadsheet.xls")
s =Roo::Excelx.new("myspreadsheet.xlsx")
运行脚本时,不应在MS Excel中打开此文件。这就是为什么在
电子表格
案例中显示权限被拒绝
。在第一种情况下,请使用Roo::Excel.new
。运行脚本时,不应在MS Excel中打开此文件。这就是为什么在电子表格
案例中显示权限被拒绝
。在第一种情况下,使用Roo::Excel.new
。