Class: OLEStorageLite
- Inherits:
-
Object
- Object
- OLEStorageLite
- Defined in:
- lib/WriteExcel/storage_lite.rb
Overview
require ‘tempfile’ require ‘stringio’
Direct Known Subclasses
Constant Summary collapse
- PPS_TYPE_ROOT =
5
- PPS_TYPE_DIR =
1
- PPS_TYPE_FILE =
2
- DATA_SIZE_SMALL =
0x1000
- LONG_INT_SIZE =
4
- PPS_SIZE =
0x80
Instance Method Summary collapse
Instance Method Details
#asc2ucs(str) ⇒ Object
12 13 14 |
# File 'lib/WriteExcel/storage_lite.rb', line 12 def asc2ucs(str) str.split(//).join("\0") + "\0" end |
#localDate2OLE(localtime) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/WriteExcel/storage_lite.rb', line 21 def localDate2OLE(localtime) return "\x00" * 8 unless localtime # Convert from localtime (actually gmtime) to seconds. args = localtime.reverse args[0] += 1900 # year args[1] += 1 # month time = Time.gm(*args) # Add the number of seconds between the 1601 and 1970 epochs. time = time.to_i + 11644473600 # The FILETIME seconds are in units of 100 nanoseconds. nanoseconds = time * 1E7 # Pack the total nanoseconds into 64 bits... hi, lo = nanoseconds.divmod 1 << 32 oletime = [lo, hi].pack("VV") return oletime end |
#ucs2asc(str) ⇒ Object
16 17 18 19 |
# File 'lib/WriteExcel/storage_lite.rb', line 16 def ucs2asc(str) ary = str.unpack('v*').map { |s| [s].pack('c')} ary.join('') end |