Class: Spreadsheet::Excel::Workbook
Overview
reader. You should have no reason to use any of these.
Constant Summary
collapse
- BIFF_VERSIONS =
{
0x000 => 2,
0x007 => 2,
0x200 => 2,
0x300 => 3,
0x400 => 4,
0x500 => 5,
0x600 => 8,
}
- VERSION_STRINGS =
{
0x600 => 'Microsoft Excel 97/2000/XP',
0x500 => 'Microsoft Excel 95',
}
Instance Attribute Summary collapse
Attributes included from Offset
#changes, #offsets
Attributes inherited from Workbook
#active_worksheet, #default_format, #encoding, #fonts, #formats, #io, #version, #worksheets
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Offset
append_features
#ivar_name, #method_name
Methods inherited from Workbook
#add_font, #add_format, #create_worksheet, #font, #format, #inspect, #worksheet, #write, #writer
Constructor Details
#initialize(*args) ⇒ Workbook
Returns a new instance of Workbook.
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/spreadsheet/excel/workbook.rb', line 34
def initialize *args
super
enc = 'UTF-16LE'
if RUBY_VERSION >= '1.9'
enc = Encoding.find enc
end
@encoding = enc
@version = 0x600
@sst = []
end
|
Instance Attribute Details
#bof ⇒ Object
Returns the value of attribute bof.
28
29
30
|
# File 'lib/spreadsheet/excel/workbook.rb', line 28
def bof
@bof
end
|
#date_base ⇒ Object
63
64
65
|
# File 'lib/spreadsheet/excel/workbook.rb', line 63
def date_base
@date_base ||= DateTime.new 1899, 12, 31
end
|
#ole ⇒ Object
Returns the value of attribute ole.
28
29
30
|
# File 'lib/spreadsheet/excel/workbook.rb', line 28
def ole
@ole
end
|
Class Method Details
.open(io, opts = {}) ⇒ Object
30
31
32
33
|
# File 'lib/spreadsheet/excel/workbook.rb', line 30
def Workbook.open io, opts = {}
@reader = Reader.new opts
@reader.read io
end
|
Instance Method Details
#add_shared_string(str) ⇒ Object
44
45
46
|
# File 'lib/spreadsheet/excel/workbook.rb', line 44
def add_shared_string str
@sst.push str
end
|
#add_worksheet(worksheet) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/spreadsheet/excel.rb', line 27
def add_worksheet name
if name.is_a? String
create_worksheet :name => name
else
super
end
end
|
#biff_version ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/spreadsheet/excel/workbook.rb', line 51
def biff_version
case @bof
when 0x009
2
when 0x209
3
when 0x409
4
else
BIFF_VERSIONS.fetch(@version) { raise "Unkown BIFF_VERSION '#@version'" }
end
end
|
#shared_string(idx) ⇒ Object
66
67
68
|
# File 'lib/spreadsheet/excel/workbook.rb', line 66
def shared_string idx
@sst[idx.to_i].content
end
|
#sst_size ⇒ Object
69
70
71
|
# File 'lib/spreadsheet/excel/workbook.rb', line 69
def sst_size
@sst.size
end
|
#uninspect_variables ⇒ Object
72
73
74
|
# File 'lib/spreadsheet/excel/workbook.rb', line 72
def uninspect_variables
super.push '@sst', '@offsets', '@changes'
end
|
#version_string ⇒ Object
75
76
77
|
# File 'lib/spreadsheet/excel/workbook.rb', line 75
def version_string
client VERSION_STRINGS.fetch(@version, "Unknown"), 'UTF-8'
end
|