lib/axlsx/workbook/worksheet/col.rb in axlsx-1.3.4 vs lib/axlsx/workbook/worksheet/col.rb in axlsx-1.3.5
- old
+ new
@@ -102,11 +102,16 @@
@style = v
end
# @see Col#width
def width=(v)
- Axlsx.validate_unsigned_numeric(v) unless v == nil
+ # Removing this validation make a 10% difference in performance
+ # as it is called EVERY TIME A CELL IS ADDED - the proper solution
+ # is to only set this if a calculated value is greated than the
+ # current @width value.
+ # TODO!!!
+ #Axlsx.validate_unsigned_numeric(v) unless v == nil
@custom_width = @best_fit = v != nil
@width = v
end
# updates the width for this col based on the cells autowidth and
@@ -118,10 +123,12 @@
# autowidth value will be ignored.
def update_width(cell, fixed_width=nil, use_autowidth=true)
if fixed_width.is_a? Numeric
self.width = fixed_width
elsif use_autowidth
- self.width = [width || 0, cell.autowidth || 0].max
+ cell_width = cell.autowidth
+ self.width = cell_width unless (width || 0) > (cell_width || 0)
+ #self.width = [width || 0, cell.autowidth || 0].max
end
end
# Serialize this columns data to an xml string
# @param [String] str