5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/merge_excel/spreadsheet_parser.rb', line 5
def self.open(filepath)
extname = detect_format(filepath)
case extname
when :xls
book = Spreadsheet.open(filepath)
when :xlsx
book = RubyXL::Parser.parse(filepath)
end
book.instance_variable_set(:@extname, extname)
book.instance_variable_set(:@filename, File.basename(filepath))
def book.xls?
@extname==:xls ? true : false
end
def book.xlsx?
!book.xls?
end
def book.filename
@filename
end
book
end
|