summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/axlsx/stylesheet/styles.rb3
-rw-r--r--test/stylesheet/tc_styles.rb8
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index e8bcdbfb..633fbcad 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -199,6 +199,7 @@ module Axlsx
end
borderId = options[:border] || 0
+
raise ArgumentError, "Invalid borderId" unless borderId < borders.size
fill = if options[:bg_color]
@@ -223,8 +224,8 @@ module Axlsx
xf = Xf.new(:fillId => fill, :fontId=>fontId, :applyFill=>1, :applyFont=>1, :numFmtId=>numFmtId, :borderId=>borderId, :applyProtection=>applyProtection)
- xf.applyBorder = true if borderId > 0
xf.applyNumberFormat = true if xf.numFmtId > 0
+ xf.applyBorder = true if borderId > 0
if options[:alignment]
xf.alignment = CellAlignment.new(options[:alignment])
diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb
index 15020608..df180b61 100644
--- a/test/stylesheet/tc_styles.rb
+++ b/test/stylesheet/tc_styles.rb
@@ -42,10 +42,14 @@ class TestStyles < Test::Unit::TestCase
assert(xf.alignment.is_a?(Axlsx::CellAlignment), "alignment was created")
assert_equal(xf.alignment.horizontal, :left, "horizontal alignment applied")
- assert_equal(xf.applyProtection, 1, "protection applied")
assert_equal(xf.protection.hidden, true, "hidden protection set")
assert_equal(xf.protection.locked, true, "cell locking set")
- assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 }
+ assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 }
+
+
+ assert_equal(xf.applyProtection, 1, "protection applied")
+ assert_equal(xf.applyBorder, true, "border applied")
+ assert_equal(xf.applyNumberFormat, true, "border applied")
end