diff options
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell_serializer.rb | 10 | ||||
| -rw-r--r-- | test/benchmark.rb | 16 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_cell.rb | 13 |
3 files changed, 3 insertions, 36 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb index b054316b..e4c35c3a 100644 --- a/lib/axlsx/workbook/worksheet/cell_serializer.rb +++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb @@ -23,12 +23,6 @@ module Axlsx # @param [String] str The string instance this run will be concated to. # @return [String] def run_xml_string(cell, str = '') - t = cell.value.to_s - if t[0, 1] == ' ' || t[-1, 1] == ' ' - t = '<t xml:space="preserve">' << t << '</t>' - else - t = '<t>' << t << '</t>' - end if cell.is_text_run? data = cell.instance_values.reject{|key, value| value == nil || key == 'value' || key == 'type' } keys = data.keys & Cell::INLINE_STYLES @@ -43,9 +37,9 @@ module Axlsx str << "<" << key.to_s << " val='" << data[key].to_s << "'/>" end end - str << "</rPr>" << t << "</r>" + str << "</rPr>" << "<t>" << cell.value.to_s << "</t></r>" else - str << t + str << "<t>" << cell.value.to_s << "</t>" end str end diff --git a/test/benchmark.rb b/test/benchmark.rb index 3f017874..2ef82eaf 100644 --- a/test/benchmark.rb +++ b/test/benchmark.rb @@ -8,7 +8,6 @@ Axlsx::trust_input = true row = [] input = (32..126).to_a.pack('U*').chars.to_a 20.times { row << input.shuffle.join} -row_with_spaces = row.map{ |v| " #{v}" } times = 3000 Benchmark.bmbm(30) do |x| @@ -70,18 +69,5 @@ Benchmark.bmbm(30) do |x| end end } - - x.report('preserve-spaces') { - p = Axlsx::Package.new - p.workbook do |wb| - wb.add_worksheet do |sheet| - times.times do - sheet << row_with_spaces - end - end - end - s = p.to_stream() - File.open('example_preserve_spaces.xlsx', 'w') { |f| f.write(s.read) } - } end -File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx", "example_preserve_spaces.xlsx") +File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx") diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 9b8cd769..208b15e0 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -275,20 +275,7 @@ class TestCell < Test::Unit::TestCase end doc = Nokogiri::XML(ws.to_xml_string) assert(doc.xpath("//f[@text()='IF(2+2=4,4,5)']")) - end - def test_to_xml_string_with_leading_or_trailing_spaces - # Check that xml:space="preserve" has been added when cell contains leading or trailing spaces - @c.type = :string - @c.value = " a" - c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) - assert(c_xml.xpath("//t/@xml:space='preserve'")) - @c.value = "a " - c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) - assert(c_xml.xpath("//t/@xml:space='preserve'")) - @c.value = "a" - c_xml = Nokogiri::XML(@c.to_xml_string(1,1)) - assert(!c_xml.xpath("//t/@xml:space='preserve'")) end def test_font_size_with_custom_style_and_no_sz |
