From 4e3ce5786ed1fd6bba3fabb7dd16b0b2ad7577a7 Mon Sep 17 00:00:00 2001 From: Edgars Beigarts Date: Thu, 26 Mar 2015 12:50:38 +0200 Subject: [PATCH] Support inline strings --- lib/saxlsx/rows_collection_parser.rb | 14 +++++++------- spec/data/SpecInlineStrings.xlsx | Bin 0 -> 3499 bytes spec/sheet_spec.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 spec/data/SpecInlineStrings.xlsx 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 0000000000000000000000000000000000000000..a5091d5758d7f4443b9fedd82aad4e592ec2edf0 GIT binary patch literal 3499 zcmaJ^2{=@J7az-vLbe$Zp(z?mwi4Mx)@jCMOA1*gWSI%2!GtU^mh2Tm*<~6LG4fi9 z7EH(%O(;8+ExY=z_kEvN=Ka3!xzGRp?|q*8JJ0!@^FP0HE(XcM3Il;ayFeg8_>AeC z<6tlFc9Izc;sADgZ>)!pyxi8EoY;VVp}-koFELLC}VRrEEMohIeF#*v4gFt%#{?|R^eS8TX zSRc9To*sD?w$UFCz&2$*a~EFem-CGbG1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