开发者

Problem in creating Excel Files with ruby

开发者 https://www.devze.com 2023-01-09 04:48 出处:网络
I am using Spreadsheet for ruby for creating excel files. Now I want that a excel must be created when it doesn开发者_如何学JAVAt exist. So I wrote this -:

I am using Spreadsheet for ruby for creating excel files. Now I want that a excel must be created when it doesn开发者_如何学JAVAt exist. So I wrote this -:

require 'rubygems'
require 'spreadsheet'
include Spreadsheet

workbook = Spreadsheet.open "data__#{$KEYWORD}.xlsx" rescue Excel.new("data__#{$KEYWORD}.xlsx")

But Always keeps throwing this error -

undefined method `new' for Spreadsheet::Excel:Module (NoMethodError)


Looks like you want to use Spreadsheet::Excel::Workbook.new. As the error you get points out, Spreadsheet::Excel is a module, and not instantiable.

Check the documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消