Class: Spreadsheet::Excel::Workbook
Overview
Excel-specific Workbook methods. These are mostly pertinent to the Excel 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, #palette, #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, #delete_worksheet, #font, #format, #set_custom_color, #sheet_count, #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
67
68
69
|
# File 'lib/spreadsheet/excel/workbook.rb', line 67
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
|
# File 'lib/spreadsheet/excel/workbook.rb', line 30
def self.open io, opts = {}
Reader.new(opts).read(io)
end
|
Instance Method Details
#add_shared_string(str) ⇒ Object
45
46
47
|
# File 'lib/spreadsheet/excel/workbook.rb', line 45
def add_shared_string str
@sst.push str
end
|
#add_worksheet(worksheet) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/spreadsheet/excel.rb', line 24
def add_worksheet name
if name.is_a? String
create_worksheet name: name
else
super
end
end
|
#biff_version ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/spreadsheet/excel/workbook.rb', line 54
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
|
#inspect ⇒ Object
71
72
73
|
# File 'lib/spreadsheet/excel/workbook.rb', line 71
def inspect
worksheets
end
|
#shared_string(idx) ⇒ Object
75
76
77
|
# File 'lib/spreadsheet/excel/workbook.rb', line 75
def shared_string idx
@sst[idx.to_i].content
end
|
#sst_size ⇒ Object
79
80
81
|
# File 'lib/spreadsheet/excel/workbook.rb', line 79
def sst_size
@sst.size
end
|
#uninspect_variables ⇒ Object
83
84
85
|
# File 'lib/spreadsheet/excel/workbook.rb', line 83
def uninspect_variables
super.push "@sst", "@offsets", "@changes"
end
|
#version_string ⇒ Object
87
88
89
|
# File 'lib/spreadsheet/excel/workbook.rb', line 87
def version_string
client VERSION_STRINGS.fetch(@version, "Unknown"), "UTF-8"
end
|