summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb5
-rw-r--r--test/workbook/worksheet/tc_cell.rb13
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index f0345705..39452c47 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -174,7 +174,8 @@ module Axlsx
!is_text_run? && # No inline styles
[email protected]? && # Not nil
[email protected]? && # Not empty
- [email protected]_with?(*FORMULA_PREFIXES) # Not a formula
+ !is_formula? && # Not a formula
+ !is_array_formula? # Not an array formula
end
# The inline font_name property for the cell
@@ -376,6 +377,8 @@ module Axlsx
end
def is_array_formula?
+ return false if escape_formulas
+
type == :string && @value.to_s.start_with?('{=') && @value.to_s.end_with?('}')
end
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index b8e16404..29f42c4f 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -318,6 +318,8 @@ class TestCell < Test::Unit::TestCase
end
def test_plain_string
+ @c.escape_formulas = false
+
@c.type = :integer
assert_equal(@c.plain_string?, false)
@@ -334,6 +336,17 @@ class TestCell < Test::Unit::TestCase
@c.value = '=sum'
assert_equal(@c.plain_string?, false)
+ @c.value = '{=sum}'
+ assert_equal(@c.plain_string?, false)
+
+ @c.escape_formulas = true
+
+ @c.value = '=sum'
+ assert_equal(@c.plain_string?, true)
+
+ @c.value = '{=sum}'
+ assert_equal(@c.plain_string?, true)
+
@c.value = 'plain string'
@c.font_name = 'Arial'
assert_equal(@c.plain_string?, false)