Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/simple_xlsx_reader/loader/shared_strings_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize

attr_reader :result

def start_element(name, _attrs = [])
def start_element_namespace(name, attrs = [], _prefix, _uri, _ns)
case name
when 'si' then @current_string = +"" # UTF-8 variant of String.new
when 't' then @extract = true
Expand All @@ -35,7 +35,7 @@ def characters(string)
@current_string << string
end

def end_element(name)
def end_element_namespace(name, _prefix, _uri)
case name
when 't' then @extract = false
when 'si' then @result << @current_string
Expand Down
1 change: 1 addition & 0 deletions test/shared_strings_namespaced.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><x:sst xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><x:si><x:t>Shared 1</x:t></x:si><x:si><x:t>Shared 2</x:t></x:si><x:si><x:t>Shared 3</x:t></x:si></x:sst>
12 changes: 12 additions & 0 deletions test/simple_xlsx_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,18 @@
end
end

describe 'namespaced shared_strings' do
let(:xml) do
File.open(File.join(File.dirname(__FILE__), 'shared_strings_namespaced.xml'))
end

let(:ss) { SimpleXlsxReader::Loader::SharedStringsParser.parse(xml) }

it 'parses strings into a list' do
_(ss).must_equal ['Shared 1', 'Shared 2', 'Shared 3']
end
end

describe 'style_types' do
let(:xml_file) do
File.open(File.join(File.dirname(__FILE__), 'styles.xml'))
Expand Down