在Excel工作表上执行某些操作时遇到问题

时间:2019-06-17 11:32:00

标签: ruby-on-rails excel

  1. 打开电子表格
  2. 对其执行一些操作,例如将值添加到某些行和列中
  3. 执行写操作

面对问题-打开文件时发生错误

  workbook = Spreadsheet::Workbook.new    
  sheet = workbook.create_worksheet
  sheet.name = "Report"
  sheet = workbook.worksheet 0
  sheet[0,0] = 'Feature : '+ data[0]['name']
  sheet[1,0] = 'keyword '
  sheet[2,0] = 'Scenario Details'
  sheet[3,0] = 'Status '
  workbook.write()//provide file name with path
  In this way it is working fine as i am creating a new spreadsheet
  workbook = Spreadsheet.open ''//provide file name with path
  sheet = workbook.worksheet 0
  sheet[0,0] = 'Feature : '+ data[0]['name']    
  sheet[1,0] = 'keyword '   
  sheet[2,0] = 'Scenario Details'   
  sheet[3,0] = 'Status '   
  workbook.write()//provide file name with path   

  i expect file should open with proper values but actual it shows 'Error 
   occurs while opening the file'

0 个答案:

没有答案