summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/tc_workbook.rb
diff options
context:
space:
mode:
authorjohnnyshields <[email protected]>2023-03-31 04:40:41 +0900
committerjohnnyshields <[email protected]>2023-03-31 04:40:41 +0900
commit0746815b75296bcf65d49a66f0dca1427ac65f3e (patch)
treedb99ace871993f5fa1bd80821527ab252a277d53 /test/workbook/tc_workbook.rb
parentc5ddbe7cd9bb15e8b247e6b5a5e359d02dd5b9fe (diff)
downloadcaxlsx-0746815b75296bcf65d49a66f0dca1427ac65f3e.tar.gz
caxlsx-0746815b75296bcf65d49a66f0dca1427ac65f3e.zip
Add settings for escape_formulas at global, workbook, worksheet, row and cell levels.
Diffstat (limited to 'test/workbook/tc_workbook.rb')
-rw-r--r--test/workbook/tc_workbook.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index f8d0b1f7..a9bd339c 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -162,4 +162,40 @@ class TestWorkbook < Test::Unit::TestCase
wb_xml = Nokogiri::XML(@wb.to_xml_string)
assert_equal sheet.name, wb_xml.xpath('//xmlns:workbook/xmlns:sheets/*[1]/@name').to_s
end
+
+ def test_escape_formulas
+ old = Axlsx::escape_formulas
+
+ Axlsx::escape_formulas = false
+ p = Axlsx::Package.new
+ @wb = p.workbook
+ assert_false @wb.escape_formulas
+ assert_false @wb.add_worksheet.escape_formulas
+ assert_false @wb.add_worksheet(escape_formulas: false).escape_formulas
+ assert @wb.add_worksheet(escape_formulas: true).escape_formulas
+
+ Axlsx::escape_formulas = true
+ p = Axlsx::Package.new
+ @wb = p.workbook
+ assert @wb.escape_formulas
+ assert @wb.add_worksheet.escape_formulas
+ assert_false @wb.add_worksheet(escape_formulas: false).escape_formulas
+ assert @wb.add_worksheet(escape_formulas: true).escape_formulas
+
+ @wb.escape_formulas = false
+ assert_false @wb.escape_formulas
+ assert_false @wb.add_worksheet.escape_formulas
+ assert_false @wb.add_worksheet(escape_formulas: false).escape_formulas
+ assert @wb.add_worksheet(escape_formulas: true).escape_formulas
+
+ @wb.escape_formulas = true
+ p = Axlsx::Package.new
+ @wb = p.workbook
+ assert @wb.escape_formulas
+ assert @wb.add_worksheet.escape_formulas
+ assert_false @wb.add_worksheet(escape_formulas: false).escape_formulas
+ assert @wb.add_worksheet(escape_formulas: true).escape_formulas
+
+ Axlsx::escape_formulas = old
+ end
end