Class: BIFFWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/spreadsheet/biffwriter.rb

Direct Known Subclasses

Workbook, Worksheet

Constant Summary collapse

BIFF_Version =
0x0500
BigEndian =
[1].pack("I") == [1].pack("N")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ BIFFWriter

The args here aren’t used by BIFFWriter, but they are needed by its subclasses. I don’t feel like creating multiple constructors.



12
13
14
15
# File 'lib/spreadsheet/biffwriter.rb', line 12

def initialize(*args)
   @data       = ""
   @datasize   = 0
end

Instance Attribute Details

#byte_orderObject (readonly)

Returns the value of attribute byte_order.



6
7
8
# File 'lib/spreadsheet/biffwriter.rb', line 6

def byte_order
  @byte_order
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/spreadsheet/biffwriter.rb', line 6

def data
  @data
end

#datasizeObject (readonly)

Returns the value of attribute datasize.



6
7
8
# File 'lib/spreadsheet/biffwriter.rb', line 6

def datasize
  @datasize
end

Instance Method Details

#append(*args) ⇒ Object



22
23
24
25
# File 'lib/spreadsheet/biffwriter.rb', line 22

def append(*args)
   @data << args.join
   @datasize += args.join.length
end

#prepend(*args) ⇒ Object



17
18
19
20
# File 'lib/spreadsheet/biffwriter.rb', line 17

def prepend(*args)
   @data = args.join << @data
   @datasize += args.join.length
end

#store_bof(type = 0x0005) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/spreadsheet/biffwriter.rb', line 27

def store_bof(type = 0x0005)
   record  = 0x0809
   length  = 0x0008
   build   = 0x096C
   year    = 0x07C9

   header  = [record,length].pack("vv")
   data    = [BIFF_Version,type,build,year].pack("vvvv") 

   prepend(header, data)
end

#store_eofObject



39
40
41
42
43
44
45
# File 'lib/spreadsheet/biffwriter.rb', line 39

def store_eof
   record = 0x000A
   length = 0x0000
   header = [record,length].pack("vv")
 
   append(header)
end