Class: Roo::Excelx::Workbook
Defined Under Namespace
Classes: Label
Constant Summary
Constants inherited
from Extractor
Extractor::COMMON_STRINGS
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Workbook
21
22
23
24
|
# File 'lib/roo/excelx/workbook.rb', line 21
def initialize(path)
super
fail ArgumentError, 'missing required workbook file' unless doc_exists?
end
|
Instance Method Details
#base_date ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/roo/excelx/workbook.rb', line 45
def base_date
@base_date ||=
begin
result = Date.new(1899, 12, 30) doc.css('workbookPr[date1904]').each do |workbookPr|
if workbookPr['date1904'] =~ /true|1/i
result = Date.new(1904, 01, 01)
break
end
end
result
end
end
|
#base_timestamp ⇒ Object
41
42
43
|
# File 'lib/roo/excelx/workbook.rb', line 41
def base_timestamp
@base_timestamp ||= base_date.to_datetime.to_time.to_i
end
|
#defined_names ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/roo/excelx/workbook.rb', line 31
def defined_names
doc.xpath('//definedName').each_with_object({}) do |defined_name, hash|
sheet, coordinates = defined_name.text.split('!$', 2)
col, row = coordinates.split('$')
name = defined_name['name']
hash[name] = Label.new(name, sheet, row, col)
end
end
|
#sheets ⇒ Object
26
27
28
|
# File 'lib/roo/excelx/workbook.rb', line 26
def sheets
doc.xpath('//sheet')
end
|