summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/worksheet
diff options
context:
space:
mode:
authorSergey Ponomarev <[email protected]>2020-07-14 10:37:28 -0400
committerGitHub <[email protected]>2020-07-14 16:37:28 +0200
commit515177c03121b2ebb5920fd9b673d7da1ebe028d (patch)
treeef4bd6d438259d186d38c681e7f823eceaa04755 /test/workbook/worksheet
parent6639f3cd5d1f64c2e947bd4f39a62d2d1d21bd7b (diff)
downloadcaxlsx-515177c03121b2ebb5920fd9b673d7da1ebe028d.tar.gz
caxlsx-515177c03121b2ebb5920fd9b673d7da1ebe028d.zip
Set column width to the maximum allowed value (#53)
Maximum column width limit in MS Excel is 255 characters https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3 If this value is exceeded, MS Excel gets stuck and doesn't allow column resizing.
Diffstat (limited to 'test/workbook/worksheet')
-rw-r--r--test/workbook/worksheet/tc_col.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb
index 5b3dfa57..00c5f058 100644
--- a/test/workbook/worksheet/tc_col.rb
+++ b/test/workbook/worksheet/tc_col.rb
@@ -7,7 +7,7 @@ class TestCol < Test::Unit::TestCase
end
def test_initialize
- options = { :width => 12, :collapsed => true, :hidden => true, :outline_level => 1, :phonetic => true, :style => 1}
+ options = { :width => 12, :collapsed => true, :hidden => true, :outline_level => 1, :phonetic => true, :style => 1}
col = Axlsx::Col.new 0, 0, options
options.each{ |key, value| assert_equal(col.send(key.to_sym), value) }
@@ -39,6 +39,21 @@ class TestCol < Test::Unit::TestCase
assert_equal(@col.customWidth, true, 'customWidth is true when width is set')
end
+ def test_widthUnderLimit
+ @col.width = 3
+ assert_equal(@col.width, 3, 'width is set to exact value')
+ end
+
+ def test_widthOverLimit
+ @col.width = 31337
+ assert_equal(@col.width, 255, 'width is set to maximum allowed value')
+ end
+
+ def test_widthSetToNil
+ @col.width = nil
+ assert_equal(@col.width, nil, 'width is set to unspecified value')
+ end
+
def test_hidden
assert_equal(@col.hidden, nil)
assert_raise(ArgumentError, 'hidden must be boolean(ish)') { @col.hidden = 'bob' }