diff --git a/lib/saxlsx/rows_collection_parser.rb b/lib/saxlsx/rows_collection_parser.rb index 7fb6372..5c3a4e6 100644 --- a/lib/saxlsx/rows_collection_parser.rb +++ b/lib/saxlsx/rows_collection_parser.rb @@ -48,13 +48,11 @@ def initialize(workbook, &block) def start_element(name) @current_element = name - - if name == :row + case name + when :row @current_row = [] @next_column = 'A' - end - - if name == :c + when :c @current_type = nil @current_number_format = nil end @@ -81,7 +79,7 @@ def attr(name, value) end def text(value) - if @current_row && @current_element == :v + if @current_row && (@current_element == :v || @current_element == :t) while @next_column != @current_column @current_row << nil @next_column = ColumnNameGenerator.next_to(@next_column) @@ -96,7 +94,9 @@ def text(value) def value_of(text) case @current_type when 's' - @shared_strings[text.to_i] || text + @shared_strings[text.to_i] + when 'inlineStr' + text when 'b' BooleanParser.parse text else diff --git a/spec/data/SpecInlineStrings.xlsx b/spec/data/SpecInlineStrings.xlsx new file mode 100644 index 0000000..a5091d5 Binary files /dev/null and b/spec/data/SpecInlineStrings.xlsx differ diff --git a/spec/sheet_spec.rb b/spec/sheet_spec.rb index f89cbb3..f5a9826 100644 --- a/spec/sheet_spec.rb +++ b/spec/sheet_spec.rb @@ -104,4 +104,18 @@ end end end + + context 'with inline strings' do + let(:filename) { "#{File.dirname(__FILE__)}/data/SpecInlineStrings.xlsx" } + + it 'should read inline strings' do + Workbook.open filename do |w| + w.sheets[0].tap do |s| + s.rows[0].should eq [ + 'Test' + ] + end + end + end + end end \ No newline at end of file