lib/write_xlsx/workbook.rb in write_xlsx-1.10.2 vs lib/write_xlsx/workbook.rb in write_xlsx-1.11.0

- old
+ new

@@ -56,11 +56,11 @@ @drawings = [] @formats = Formats.new @xf_formats = [] @dxf_formats = [] @font_count = 0 - @num_format_count = 0 + @num_formats = [] @defined_names = [] @named_ranges = [] @custom_colors = [] @doc_properties = {} @custom_properties = [] @@ -558,11 +558,11 @@ def style_properties [ @xf_formats, @palette, @font_count, - @num_format_count, + @num_formats, @border_count, @fill_count, @custom_colors, @dxf_formats, @has_comments @@ -867,10 +867,13 @@ # Set the active sheet. @activesheet = @worksheets.visible_first.index if @activesheet == 0 @worksheets[@activesheet].activate + # Convert the SST strings data structure. + prepare_sst_string_data + # Prepare the worksheet VML elements such as comments and buttons. prepare_vml_objects # Set the defined names for the worksheets such as Print Titles. prepare_defined_names # Prepare the drawings, charts and images. @@ -916,10 +919,15 @@ def parts Dir.glob(File.join(tempdir, "**", "*"), File::FNM_DOTMATCH).select { |f| File.file?(f) } end # + # prepare_sst_string_data + # + def prepare_sst_string_data; end + + # # Prepare all of the format properties prior to passing them to Styles.rb. # def prepare_format_properties # :nodoc: # Separate format objects into XF and DXF formats. prepare_formats @@ -975,13 +983,14 @@ # number format elements. # # User defined records start from index 0xA4. # def prepare_num_formats # :nodoc: - num_formats = {} - index = 164 - num_format_count = 0 + num_formats = [] + unique_num_formats = {} + index = 164 + num_format_count = 0 (@xf_formats + @dxf_formats).each do |format| num_format = format.num_format # Check if num_format is an index to a built-in number format. @@ -998,24 +1007,25 @@ # The 'General' format has an number format index of 0. format.num_format_index = 0 next end - if num_formats[num_format] + if unique_num_formats[num_format] # Number format has already been used. - format.num_format_index = num_formats[num_format] + format.num_format_index = unique_num_formats[num_format] else # Add a new number format. - num_formats[num_format] = index + unique_num_formats[num_format] = index format.num_format_index = index index += 1 - # Only increase font count for XF formats (not for DXF formats). - num_format_count += 1 if ptrue?(format.xf_index) + # Only store/increase number format count for XF formats + # (not for DXF formats). + num_formats << num_format if ptrue?(format.xf_index) end end - @num_format_count = num_format_count + @num_formats = num_formats end # # Iterate through the XF Format objects and give them an index to non-default # border elements.