diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx.rb | 8 | ||||
| -rw-r--r-- | lib/axlsx/workbook/shared_strings_table.rb | 1 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 10 |
3 files changed, 10 insertions, 9 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb index 8cecf47a..ffebc7ac 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -127,6 +127,14 @@ module Axlsx s.gsub(/_(.)/){ $1.upcase } end + # returns the provided string with all invalid control charaters + # removed. + # @param [String] str The sting to process + # @return [String] + def self.sanitize(str) + str.gsub(CONTROL_CHAR_REGEX, '') + end + # Instructs the serializer to not try to escape cell value input. # This will give you a huge speed bonus, but if you content has <, > or other xml character data diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index 7c08205e..ed6643f2 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -50,6 +50,7 @@ module Axlsx str << '<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"' str << ' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"' str << ' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>' + str = Axlsx::sanitize(str) end private diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index ecba9254..df755abf 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -552,15 +552,7 @@ module Axlsx item.to_xml_string(str) if item end str << '</worksheet>' - sanitize(str) - end - - # returns the provided string with all invalid control charaters - # removed. - # @param [String] str The sting to process - # @return [String] - def sanitize(str) - str.gsub(CONTROL_CHAR_REGEX, '') + Axlsx::sanitize(str) end # The worksheet relationships. This is managed automatically by the worksheet |
