summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-02-16 18:23:21 +0900
committerRandy Morgan <[email protected]>2012-02-16 18:23:21 +0900
commitfb198aaef459ebad45f8deed84efbb3e92c340ce (patch)
tree4565dce37f9381f98dc1331d03e7140c1e9ceb9d
parent0c9615a7d5e936e0927452dbb6a46e414dc3675b (diff)
parent3eded043ca584914c575dde362d7fecccf905cc7 (diff)
downloadcaxlsx-fb198aaef459ebad45f8deed84efbb3e92c340ce.tar.gz
caxlsx-fb198aaef459ebad45f8deed84efbb3e92c340ce.zip
Merge https://github.com/randym/axlsx
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb4
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index 211d1c88..f84e9b92 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -351,7 +351,8 @@ module Axlsx
cells.each_with_index do |item, index|
col = @auto_fit_data[index] ||= {:longest=>"", :sz=>sz, :fixed=>nil}
width = widths[index]
- col[:fixed] = width if [Integer, Float, Fixnum, NilClass].include? width.class
+ # set fixed width and skip if numeric width is given
+ col[:fixed] = width and next if [Integer, Float, Fixnum].include?(width.class)
# ignore default column widths and formula
next if width == :ignore || (item.value.is_a?(String) && item.value.start_with?('='))
@@ -362,7 +363,6 @@ module Axlsx
col[:sz] = sz
col[:longest] = item.value.to_s
end
- @auto_fit_data[index] = col
end
cells
end
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index f6180691..f2c0ae9e 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -146,7 +146,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_set_fixed_width_column
@ws.add_row ["mule", "donkey", "horse"], :widths => [20, :ignore, nil]
assert(@ws.auto_fit_data.size == 3, "a data item for each column")
- assert_equal({:sz=>11, :fixed=>20, :longest=>"mule" }, @ws.auto_fit_data[0], "adding a row with fixed width updates :fixed attribute")
+ assert_equal({:sz=>11, :longest=>"", :fixed=>20 }, @ws.auto_fit_data[0], "adding a row with fixed width updates :fixed attribute")
assert_equal({:sz=>11, :longest=>"", :fixed=>nil}, @ws.auto_fit_data[1], ":ignore does not set any data")
assert_equal({:sz=>11, :longest=>"horse", :fixed=>nil}, @ws.auto_fit_data[2], "nil, well really anything else just works as normal")
@ws.add_row ["mule", "donkey", "horse"]