1
在电子表格中创建多个选项卡时,我收到未定义的方法send_data
。我无法理解使用这种方法应该发送什么数据。未定义的方法send_data
这是我的错误:
NoMethodError (undefined method `send_data' for #<Class:0x007f911933cc58>):
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => 'Sheet1'
sheet2 = book.create_worksheet :name => 'Sheet2'
sheet1.row(0).push "some content in Column1"
spreadsheet = StringIO.new
book.write spreadsheet
file = "#{Rails.root}/public/brand_store/Excelsheet"
send_data spreadsheet.string, :filename => "#{file}", :type => "application/vnd.ms-excel"
也许有没有'send_data'方法? –
是的,我没有创建send_data方法实际上不知道send_data方法发送什么..我需要一个示例如何使用send_data方法发送数据 – Nishtha
send_data是一个Rails [helper方法](http://api.rubyonrails.org/类/ ActionController的/ DataStreaming.html)。您似乎试图在浏览器中显示Excel电子表格,但您的代码位于模型中,不允许使用帮助器方法。 – MarsAtomic