Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 无法使用Roo或电子表格Gems打开excel_Ruby_Excel_Spreadsheet - Fatal编程技术网

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