summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-13 09:12:50 +0900
committerRandy Morgan <[email protected]>2012-04-13 09:12:50 +0900
commitaf788ce86ebcc06086218d91494242021fbade6d (patch)
tree0dcb4c1625ecc82e91175c5fc5ea96d227a12641
parent928cf9251e4aa49694866cbfa3fe3a0f26a5b363 (diff)
downloadcaxlsx-af788ce86ebcc06086218d91494242021fbade6d.tar.gz
caxlsx-af788ce86ebcc06086218d91494242021fbade6d.zip
fix both autowidth calculations and column_widths assignation.
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index cf3334ca..d52ec1da 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -340,10 +340,11 @@ module Axlsx
# Setting a fixed column width to nil will revert the behaviour back to calculating the width for you.
# @example This would set the first and third column widhts but leave the second column in autofit state.
# ws.column_widths 7.2, nil, 3
- # @note For updating only a single column it is probably easier to just set ws.auto_fit_data[col_index][:fixed] directly
+ # @note For updating only a single column it is probably easier to just set the width of the ws.column_info[col_index].width directly
# @param [Integer|Float|Fixnum|nil] values
def column_widths(*args)
args.each_with_index do |value, index|
+ next if value == nil
Axlsx::validate_unsigned_numeric(value) unless value == nil
@column_info[index] ||= Col.new index+1, index+1
@column_info[index].width = value
@@ -466,7 +467,7 @@ module Axlsx
col.width = width if [Integer, Float, Fixnum].include?(width.class)
c_style = style[index] if [Integer, Fixnum].include?(style[index].class)
#BUG - col.width wil only be nil the first time the column object is created. Subsequent row adds will not update the width of the column! col.width ||
- next if width == :ignore || col.width || (cell.value.is_a?(String) && cell.value.start_with?('=') || cell.value == nil)
+ next if width == :ignore || (cell.value.is_a?(String) && cell.value.start_with?('=') || cell.value == nil)
if self.workbook.use_autowidth
cell_xf = cellXfs[(c_style || 0)]
font = fonts[(cell_xf.fontId || 0)]