lib/axlsx/workbook/worksheet/col.rb in axlsx-1.1.8 vs lib/axlsx/workbook/worksheet/col.rb in axlsx-1.2.0

- old
+ new

@@ -100,9 +100,24 @@ @max = max options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end + + # updates the width for this col based on the cells autowidth and + # an optionally specified fixed width + # @param [Cell] cell The cell to use in updating this col's width + # @param [Integer] fixed_width If this is specified the width is set + # to this value and the cell's attributes are ignored. + # @param [Boolean] use_autowidth If this is false, the cell's + # 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 + end + end # Serialize this columns data to an xml string # @param [String] str # @return [String] def to_xml_string(str = '')