Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.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 on rails 将电子表格单元格值与ruby中的字符串进行比较_Ruby On Rails_Ruby_Parseexcel - Fatal编程技术网

Ruby on rails 将电子表格单元格值与ruby中的字符串进行比较

Ruby on rails 将电子表格单元格值与ruby中的字符串进行比较,ruby-on-rails,ruby,parseexcel,Ruby On Rails,Ruby,Parseexcel,您好,我正在尝试将spreadhseet中的单元格值与下面给出的字符串进行比较 workbook = Spreadsheet::ParseExcel.parse(name) #Get the first worksheet worksheet = workbook.worksheet(0) puts worksheet.cell(4,0).to_s puts "SecurityKey".to_s puts "SecurityKey".to_s.eql? worksheet.cell(4,0)

您好,我正在尝试将spreadhseet中的单元格值与下面给出的字符串进行比较

workbook = Spreadsheet::ParseExcel.parse(name)

#Get the first worksheet
worksheet = workbook.worksheet(0)
puts worksheet.cell(4,0).to_s 
puts "SecurityKey".to_s
puts "SecurityKey".to_s.eql? worksheet.cell(4,0).to_s
我尝试了
=
.eq?
和所有其他可能的字符串比较技术,但即使两个字符串相同,结果也总是为false。你能帮我吗

提前谢谢

单元对象有许多子对象和方法。价值 (读/写)方法返回存储在内部的单元格值。 单元格的Text(只读)方法返回当前的值 显示。例如,如果单元格的值“1234.56789”已格式化 作为货币,Value和Text方法返回不同的值

尝试使用值或文本

worksheet.Cells(4, 0).Value == "SecurityKey"
worksheet.Cells(4, 0).Text == "SecurityKey"
编辑

避免使用Excel。试试像这样的东西

require 'spreadsheet'

Spreadsheet.client_encoding = 'UTF-8'
workbook = Spreadsheet.open '/path/to/file.xls'
first_sheet = workbook.worksheet 0 # or name
cell = first_sheet.row(1).at(4)
我也尝试了同样的方法,但是当我尝试使用sheet.cell(x,y)时,我得到了“undefined method`Text'(nomethoderor)”,如果我尝试使用sheet.Cells(x,y)或sheet.cell(x,y),它就会挂起。你能帮我吗???