Skip to content

Commit

Permalink
Fix invalid new lines.
Browse files Browse the repository at this point in the history
Fixes #223.
  • Loading branch information
stevendaniels committed Jun 26, 2015
1 parent c796bfc commit 9aca2ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/roo/excelx/shared_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ def to_a

private

def fix_invalid_shared_strings(doc)
invalid = { '_x000D_' => "\n" }
xml = doc.to_s

if xml[/#{invalid.keys.join('|')}/]
@doc = ::Nokogiri::XML(xml.gsub(/#{invalid.keys.join('|')}/, invalid))
end
end

def extract_shared_strings
return [] unless doc_exists?

fix_invalid_shared_strings(doc)
# read the shared strings xml document
doc.xpath('/sst/si').map do |si|
shared_string = ''
Expand Down

0 comments on commit 9aca2ca

Please sign in to comment.