Class: Spreadsheet::Excel::Workbook
- Inherits:
-
Workbook
- Object
- Workbook
- Spreadsheet::Excel::Workbook
- Includes:
- Spreadsheet::Encodings, Offset
- Defined in:
- lib/spreadsheet/excel/workbook.rb,
lib/spreadsheet/excel.rb
Overview
Excel-specific Workbook methods. These are mostly pertinent to the Excel reader. You should have no reason to use any of these.
Direct Known Subclasses
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
-
#bof ⇒ Object
Returns the value of attribute bof.
- #date_base ⇒ Object
-
#ole ⇒ Object
Returns the value of attribute ole.
Attributes included from Offset
Class Method Summary collapse
Instance Method Summary collapse
- #add_shared_string(str) ⇒ Object
- #add_worksheet(worksheet) ⇒ Object
- #biff_version ⇒ Object
-
#initialize(*args) ⇒ Workbook
constructor
A new instance of Workbook.
- #inspect ⇒ Object
- #shared_string(idx) ⇒ Object
- #sst_size ⇒ Object
- #uninspect_variables ⇒ Object
- #version_string ⇒ Object
Methods included from Offset
Methods included from Compatibility
Constructor Details
#initialize(*args) ⇒ Workbook
Returns a new instance of Workbook.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spreadsheet/excel/workbook.rb', line 35 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.
29 30 31 |
# File 'lib/spreadsheet/excel/workbook.rb', line 29 def bof @bof end |
#date_base ⇒ Object
68 69 70 |
# File 'lib/spreadsheet/excel/workbook.rb', line 68 def date_base @date_base ||= DateTime.new 1899, 12, 31 end |
#ole ⇒ Object
Returns the value of attribute ole.
29 30 31 |
# File 'lib/spreadsheet/excel/workbook.rb', line 29 def ole @ole end |
Class Method Details
Instance Method Details
#add_shared_string(str) ⇒ Object
46 47 48 |
# File 'lib/spreadsheet/excel/workbook.rb', line 46 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
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/spreadsheet/excel/workbook.rb', line 55 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
72 73 74 |
# File 'lib/spreadsheet/excel/workbook.rb', line 72 def inspect worksheets end |
#shared_string(idx) ⇒ Object
76 77 78 |
# File 'lib/spreadsheet/excel/workbook.rb', line 76 def shared_string idx @sst[idx.to_i].content end |
#sst_size ⇒ Object
80 81 82 |
# File 'lib/spreadsheet/excel/workbook.rb', line 80 def sst_size @sst.size end |
#uninspect_variables ⇒ Object
84 85 86 |
# File 'lib/spreadsheet/excel/workbook.rb', line 84 def uninspect_variables super.push "@sst", "@offsets", "@changes" end |
#version_string ⇒ Object
88 89 90 |
# File 'lib/spreadsheet/excel/workbook.rb', line 88 def version_string client VERSION_STRINGS.fetch(@version, "Unknown"), "UTF-8" end |