diff options
| author | johnnyshields <[email protected]> | 2023-03-31 04:40:41 +0900 |
|---|---|---|
| committer | johnnyshields <[email protected]> | 2023-03-31 04:40:41 +0900 |
| commit | 0746815b75296bcf65d49a66f0dca1427ac65f3e (patch) | |
| tree | db99ace871993f5fa1bd80821527ab252a277d53 /test/workbook/worksheet/tc_worksheet.rb | |
| parent | c5ddbe7cd9bb15e8b247e6b5a5e359d02dd5b9fe (diff) | |
| download | caxlsx-0746815b75296bcf65d49a66f0dca1427ac65f3e.tar.gz caxlsx-0746815b75296bcf65d49a66f0dca1427ac65f3e.zip | |
Add settings for escape_formulas at global, workbook, worksheet, row and cell levels.
Diffstat (limited to 'test/workbook/worksheet/tc_worksheet.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_worksheet.rb | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index 8e0c5696..d535e4f7 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -7,7 +7,6 @@ class TestWorksheet < Test::Unit::TestCase @ws = @wb.add_worksheet end - def test_pn assert_equal(@ws.pn, "worksheets/sheet1.xml") ws = @ws.workbook.add_worksheet @@ -131,10 +130,8 @@ class TestWorksheet < Test::Unit::TestCase assert_equal(header_footer[key], optioned.header_footer.send(key)) end assert_equal(optioned.name, 'bob') - end - # def test_use_gridlines # assert_raise(ArgumentError) { @ws.show_gridlines = -1.1 } # assert_nothing_raised { @ws.show_gridlines = false } @@ -210,7 +207,6 @@ class TestWorksheet < Test::Unit::TestCase @ws.add_row [1, 2, 3, 4] @ws.add_row [1, 2, 3, 4] - assert(@ws.row_breaks.empty?) assert(@ws.col_breaks.empty?) @ws.add_page_break(@ws.rows.last.cells[1]) @@ -218,7 +214,6 @@ class TestWorksheet < Test::Unit::TestCase assert_equal(1, @ws.col_breaks.size) end - def test_drawing assert @ws.drawing == nil @ws.add_chart(Axlsx::Pie3DChart) @@ -442,6 +437,7 @@ class TestWorksheet < Test::Unit::TestCase assert_equal("foo\n\r\nbar", @ws.rows.last.cells.last.value) assert_not_nil(@ws.to_xml_string.index("foo\n\r\nbar")) end + # Make sure the XML for all optional elements (like pageMargins, autoFilter, ...) # is generated in correct order. def test_valid_with_optional_elements @@ -589,7 +585,6 @@ class TestWorksheet < Test::Unit::TestCase assert_equal(other_ws.index, filter_database[1].local_sheet_id) end - def test_sheet_pr_for_auto_filter @ws.auto_filter.range = 'A1:D9' @ws.auto_filter.add_column 0, :filters, :filter_items => [1] @@ -838,7 +833,7 @@ class TestWorksheet < Test::Unit::TestCase sheet.add_border 'B2:D4', style: :medium sheet.add_style 'D2:D4', border: { style: :thin, color: '000000' } end - + wb.apply_styles assert_equal 8, wb.styled_cells.count @@ -884,17 +879,54 @@ class TestWorksheet < Test::Unit::TestCase wb.apply_styles assert_equal 1, wb.styles.style_index.size - + assert_equal( { - type: :xf, - name: "Times New Roman", - sz: 12, - family: 1, + type: :xf, + name: "Times New Roman", + sz: 12, + family: 1, color: "FFFFFF", - }, + }, wb.styles.style_index.values.first ) end + def test_escape_formulas + @wb.escape_formulas = false + @ws = @wb.add_worksheet + assert_false @ws.escape_formulas + assert_false @ws.add_row(['']).cells.first.escape_formulas + assert_false @ws.add_row([''], escape_formulas: false).cells.first.escape_formulas + assert @ws.add_row([''], escape_formulas: true).cells.first.escape_formulas + assert_equal [true, false], @ws.add_row(['', ''], escape_formulas: [true, false]).cells.map(&:escape_formulas) + + @ws = Axlsx::Worksheet.new(@wb) + assert_false @ws.escape_formulas + + @wb.escape_formulas = true + @ws = @wb.add_worksheet + assert @ws.escape_formulas + assert @ws.add_row(['']).cells.first.escape_formulas + assert_false @ws.add_row([''], escape_formulas: false).cells.first.escape_formulas + assert @ws.add_row([''], escape_formulas: true).cells.first.escape_formulas + assert_equal [true, false], @ws.add_row(['', ''], escape_formulas: [true, false]).cells.map(&:escape_formulas) + + @ws = Axlsx::Worksheet.new(@wb) + assert @ws.escape_formulas + + @ws.escape_formulas = false + assert_false @ws.escape_formulas + assert_false @ws.add_row(['']).cells.first.escape_formulas + assert_false @ws.add_row([''], escape_formulas: false).cells.first.escape_formulas + assert @ws.add_row([''], escape_formulas: true).cells.first.escape_formulas + assert_equal [true, false], @ws.add_row(['', ''], escape_formulas: [true, false]).cells.map(&:escape_formulas) + + @ws.escape_formulas = true + assert @ws.escape_formulas + assert @ws.add_row(['']).cells.first.escape_formulas + assert_false @ws.add_row([''], escape_formulas: false).cells.first.escape_formulas + assert @ws.add_row([''], escape_formulas: true).cells.first.escape_formulas + assert_equal [true, false], @ws.add_row(['', ''], escape_formulas: [true, false]).cells.map(&:escape_formulas) + end end |
