lib/writeexcel/workbook.rb in writeexcel-1.0.5 vs lib/writeexcel/workbook.rb in writeexcel-1.0.6

- old
+ new

@@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- +# frozen_string_literal: true ############################################################################### # # Workbook - A writer class for Excel Workbooks. # # @@ -650,11 +651,10 @@ # Note: This currently a beta feature. More documentation and examples # will be added. # def define_name(name, formula, encoding = 0) sheet_index = 0 - full_name = name.downcase if name =~ /^(.*)!(.*)$/ sheetname = $1 name = $2 sheet_index = 1 + @parser.get_sheet_index(sheetname) @@ -1264,11 +1264,11 @@ offset += calculate_extern_sizes # Add the length of the MSODRAWINGGROUP records including an extra 4 bytes # for any CONTINUE headers. See add_mso_drawing_group_continue(). mso_size = @mso_size - mso_size += 4 * Integer((mso_size -1) / Float(@limit)) + mso_size += 4 * Integer((mso_size - 1) / Float(@limit)) offset += mso_size @worksheets.each do |sheet| offset += BOF + sheet.name.bytesize end @@ -1372,11 +1372,11 @@ images_seen[image.filename] = image_id image_id += 1 else # We've processed this file already. - index = images_seen[image.filename] -1 + index = images_seen[image.filename] - 1 # Increase image reference count. image_data[index].ref_count += 1 # Add previously calculated data back onto the Worksheet array. @@ -2051,11 +2051,10 @@ # occurs wherever the start of the bucket string is written out via append(). # def store_shared_strings #:nodoc: record = 0x00FC # Record identifier length = 0x0008 # Number of bytes to follow - total = 0x0000 # Iterate through the strings to calculate the CONTINUE block sizes continue_limit = 8208 block_length = 0 written = 0 @@ -2134,14 +2133,14 @@ end append(tmp) # The remainder will be written in the next block(s) - string = string[space_remaining .. string.length-1] + string = string[space_remaining .. string.length - 1] # Reduce the current block length by the amount written - block_length -= continue_limit -continue -align + block_length -= continue_limit - continue - align # If the current string was split then the next CONTINUE block # should have the string continue flag (grbit) set unless the # split string fits exactly into the remaining space. # @@ -2150,11 +2149,11 @@ else continue = 0 end else # Not enough space to start the string in the current block - block_length -= continue_limit -space_remaining -continue + block_length -= continue_limit - space_remaining - continue continue = 0 end # Write the CONTINUE block header if block_sizes.size != 0 @@ -2204,11 +2203,11 @@ bucket_size = 8 else bucket_size = 1 + Integer(unique_strings / 128.0) end - buckets = Integer((unique_strings + bucket_size -1) / Float(bucket_size)) + buckets = Integer((unique_strings + bucket_size - 1) / Float(bucket_size)) @extsst_buckets = buckets @extsst_bucket_size = bucket_size 6 + 8 * buckets @@ -2276,11 +2275,11 @@ # Case 1: <= 8224 bytes 1 MSODRAWINGGROUP # Case 2: <= 2*8224 bytes 1 MSODRAWINGGROUP + 1 CONTINUE # Case 3: > 2*8224 bytes 2 MSODRAWINGGROUP + n CONTINUE # def add_mso_drawing_group_continue(data) #:nodoc: - limit = 8228 -4 + limit = 8228 - 4 mso_group = 0x00EB # Record identifier continue = 0x003C # Record identifier block_count = 1 # Ignore the base class add_continue() method. @@ -2332,11 +2331,11 @@ def store_mso_dgg_container #:nodoc: type = 0xF000 version = 15 instance = 0 data = '' - length = @mso_size -12 # -4 (biff header) -8 (for this). + length = @mso_size - 12 # -4 (biff header) -8 (for this). add_mso_generic(type, version, instance, data, length) end # @@ -2370,11 +2369,11 @@ type = 0xF001 version = 15 instance = @images_data.size # Number of images. data = '' - length = @images_size +8 *instance + length = @images_size + 8 * instance add_mso_generic(type, version, instance, data, length) end # @@ -2397,16 +2396,16 @@ # def store_mso_blip_store_entry(ref_count, image_type, size, checksum1) #:nodoc: type = 0xF007 version = 2 instance = image_type - length = size +61 + length = size + 61 data = [image_type].pack('C') + # Win32 [image_type].pack('C') + # Mac [checksum1].pack('H*') + # Uid checksum [0xFF].pack('v') + # Tag - [size +25].pack('V') + # Next Blip size + [size + 25].pack('V') + # Next Blip size [ref_count].pack('V') + # Image ref count [0x00000000].pack('V') + # File offset [0x00].pack('C') + # Usage [0x00].pack('C') + # Name length [0x00].pack('C') + # Unused @@ -2428,10 +2427,10 @@ checksum1 = checksum2 + checksum1 end type = 0xF018 + image_type version = 0x0000 - length = size +17 + length = size + 17 data = [checksum1].pack('H*') + # Uid checksum [0xFF].pack('C') + # Tag image_data # Image add_mso_generic(type, version, instance, data, length)