diff options
| -rw-r--r-- | lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_pivot_table_cache_definition.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb index f136b663..969b0bf2 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb @@ -53,7 +53,7 @@ module Axlsx str << '</cacheSource>' str << ( '<cacheFields count="' << pivot_table.header_cells_count.to_s << '">') pivot_table.header_cells.each do |cell| - str << ( '<cacheField name="' << cell.value << '" numFmtId="0">') + str << ( '<cacheField name="' << cell.clean_value << '" numFmtId="0">') str << '<sharedItems count="0">' str << '</sharedItems>' str << '</cacheField>' diff --git a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb index 282078b0..37d7e485 100644 --- a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +++ b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb @@ -51,4 +51,12 @@ class TestPivotTableCacheDefinition < Test::Unit::TestCase assert(errors.empty?, "error free validation") end + def test_to_xml_string_for_special_characters + cell = @ws.rows.first.cells.first + cell.value = "&><'\"" + + doc = Nokogiri::XML(@cache_definition.to_xml_string) + errors = doc.errors + assert(errors.empty?, "invalid xml: #{errors.map(&:to_s).join(', ')}") + end end |
