https://github.com/weshatheleopard/rubyXL
def self.GetValueFromId(key, sheet, excelfile) if (@@WORKSHEETS_ID.eql? nil) @@WORKSHEETS_ID = Hash.new end workbook = nil if (@@WORKSHEETS_ID.has_key? sheet+excelfile) workbook = @@WORKSHEETS_ID.fetch(sheet+excelfile) else workbook = RubyXL::Parser.parse(excelfile) @@WORKSHEETS_ID.store(sheet+excelfile, workbook) end worksheet = workbook[sheet] first_row = 0 worksheet.each do |row| break if row[0].nil? strTempValue = worksheet.sheet_data[first_row][0].value if strTempValue == key strDataValue = worksheet.sheet_data[first_row][1].value return strDataValue end first_row +=1 endend
No comments:
Post a Comment