lib/writeexcel/olewriter.rb in writeexcel-0.3.5 vs lib/writeexcel/olewriter.rb in writeexcel-0.4.0

- old
+ new

@@ -1,5 +1,6 @@ +# -*- coding: utf-8 -*- ############################################################################### # # BIFFwriter - An abstract base class for Excel workbooks and worksheets. # # @@ -29,11 +30,11 @@ if arg.kind_of?(String) @io = File.open(arg, "w") else @io = arg end - @io.binmode + @io.binmode if @io.respond_to?(:binmode) @filehandle = "" @fileclosed = false @internal_fh = 0 @biff_only = 0 @@ -90,17 +91,12 @@ # write($data) # # Write BIFF data to OLE file. # def write(data) -#print "ole write\n" -#print data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ') + "\n\n" @io.write(data) end -# def print(data) -# @io.print(data) -# end ############################################################################### # # set_size($biffsize) # @@ -146,15 +142,12 @@ # This routine is used to explicitly close the open filehandle without # having to wait for DESTROY. # def close if @size_allowed == true -#print "write_padding" write_padding if @biff_only == 0 -#print "write_property_storage" write_property_storage if @biff_only == 0 -#print "write_big_block_depot" write_big_block_depot if @biff_only == 0 end @io.close end @@ -260,11 +253,11 @@ length = 0 ord_name = [] unless name.empty? name = name + "\0" ord_name = name.unpack("c*") - length = name.length * 2 + length = name.bytesize * 2 end rawname = ord_name.pack("v*") zero = [0].pack("C") @@ -282,20 +275,16 @@ pps_ts2d = [0].pack("V") #0x70 pps_sb = [start].pack("V") #0x74 pps_size = [size].pack("V") #0x78 write(rawname) - for n in 1..64-length - write(zero) - end + write(zero * (64 - length)) if 64 - length >= 1 write(pps_sizeofname) write(pps_type) write(pps_prev) write(pps_next) write(pps_dir) - for n in 1..5 - write(unknown) - end + write(unknown * 5) write(pps_ts1s) write(pps_ts1d) write(pps_ts2s) write(pps_ts2d) write(pps_sb)