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.
精彩评论