summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Gardiner <[email protected]>2013-04-27 16:33:35 +0100
committerAdam Gardiner <[email protected]>2013-04-27 16:33:35 +0100
commite76c93bcbf842f01a02a2485873c5eeed3838bf4 (patch)
tree0d1bdf6ee3e263b0c170dd1bd3a3cf7b4ad95f70
parentbd6a3ebf91fd0677f3d31ecba4a22b9edb812406 (diff)
downloadcaxlsx-e76c93bcbf842f01a02a2485873c5eeed3838bf4.tar.gz
caxlsx-e76c93bcbf842f01a02a2485873c5eeed3838bf4.zip
Revert changes to cell serialization
-rw-r--r--lib/axlsx/workbook/worksheet/cell_serializer.rb10
-rw-r--r--test/benchmark.rb16
-rw-r--r--test/workbook/worksheet/tc_cell.rb13
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