Class: Saxlsx::RowsCollectionParser
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- Saxlsx::RowsCollectionParser
- Defined in:
- lib/saxlsx/rows_collection_parser.rb
Constant Summary collapse
- SECONDS_IN_DAY =
86400
- NUM_FORMATS =
{ 0 => :string, # General 1 => :fixnum, # 0 2 => :float, # 0.00 3 => :fixnum, # #,##0 4 => :float, # #,##0.00 5 => :unsupported, # $#,##0_);($#,##0) 6 => :unsupported, # $#,##0_);[Red]($#,##0) 7 => :unsupported, # $#,##0.00_);($#,##0.00) 8 => :unsupported, # $#,##0.00_);[Red]($#,##0.00) 9 => :percentage, # 0% 10 => :percentage, # 0.00% 11 => :bignum, # 0.00E+00 12 => :rational, # # ?/? 13 => :rational, # # ??/?? 14 => :date, # mm-dd-yy 15 => :date, # d-mmm-yy 16 => :date, # d-mmm 17 => :date, # mmm-yy 18 => :time, # h:mm AM/PM 19 => :time, # h:mm:ss AM/PM 20 => :time, # h:mm 21 => :time, # h:mm:ss 22 => :date_time, # m/d/yy h:mm 37 => :unsupported, # #,##0 ;(#,##0) 38 => :unsupported, # #,##0 ;[Red](#,##0) 39 => :unsupported, # #,##0.00;(#,##0.00) 40 => :unsupported, # #,##0.00;[Red](#,##0.00) 45 => :time, # mm:ss 46 => :time, # [h]:mm:ss 47 => :time, # mmss.0 48 => :bignum, # ##0.0E+0 49 => :unsupported # @ }
Class Method Summary collapse
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(workbook, &block) ⇒ RowsCollectionParser
constructor
A new instance of RowsCollectionParser.
- #start_element(name) ⇒ Object
- #text(value) ⇒ Object
Constructor Details
#initialize(workbook, &block) ⇒ RowsCollectionParser
Returns a new instance of RowsCollectionParser.
44 45 46 47 48 49 50 |
# File 'lib/saxlsx/rows_collection_parser.rb', line 44 def initialize(workbook, &block) @base_date = workbook.base_date @auto_format = workbook.auto_format @shared_strings = workbook.shared_strings @number_formats = workbook.number_formats @block = block end |
Class Method Details
Instance Method Details
#attr(name, value) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/saxlsx/rows_collection_parser.rb', line 71 def attr(name, value) if @current_element == :c case name when :t @current_type = value when :r @current_column = value.gsub(/\d/, '') when :s @current_number_format = detect_format_type(value.to_i) end end end |
#end_element(name) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/saxlsx/rows_collection_parser.rb', line 64 def end_element(name) if name == :row @block.call @current_row @current_row = nil end end |
#start_element(name) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/saxlsx/rows_collection_parser.rb', line 52 def start_element(name) @current_element = name case name when :row @current_row = [] @next_column = 'A' when :c @current_type = nil @current_number_format = nil end end |
#text(value) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/saxlsx/rows_collection_parser.rb', line 84 def text(value) if @current_row && (@current_element == :v || @current_element == :t) while @next_column != @current_column @current_row << nil @next_column = ColumnNameGenerator.next_to(@next_column) end @current_row << value_of(value) @next_column = ColumnNameGenerator.next_to(@next_column) end end |