Skip to content

Commit

Permalink
Support inline strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ebeigarts committed Mar 26, 2015
1 parent 79e8369 commit 4e3ce57
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/saxlsx/rows_collection_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
Binary file added spec/data/SpecInlineStrings.xlsx
Binary file not shown.
14 changes: 14 additions & 0 deletions spec/sheet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4e3ce57

Please sign in to comment.