Skip to content

Commit

Permalink
Fix Excel2003: set namespace if not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoid committed Sep 16, 2019
1 parent 561e295 commit e1f509c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/roo/xls/excel_2003_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def initialize(filename, options = {})
@doc = ::Roo::Utils.load_xml(@filename)
end
namespace = @doc.namespaces.select { |_, urn| urn == 'urn:schemas-microsoft-com:office:spreadsheet' }.keys.last
@namespace = (namespace.nil? || namespace.empty?) ? 'ss' : namespace.split(':').last
if namespace.to_s.empty? || namespace.split(':').size == 1
namespace = 'xmlns:ss'
workbook = @doc.at('Workbook')
workbook.add_namespace_definition('ss', 'urn:schemas-microsoft-com:office:spreadsheet')
end
@namespace = namespace.split(':').last || 'ss'
super(filename, options)
@formula = {}
@style = {}
Expand Down

0 comments on commit e1f509c

Please sign in to comment.