Class: BxBuilderChain::Processors::Xlsx
- Defined in:
- lib/bx_builder_chain/processors/xlsx.rb
Constant Summary collapse
- EXTENSIONS =
[".xlsx", ".xlsm"].freeze
- CONTENT_TYPES =
["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].freeze
Instance Method Summary collapse
-
#initialize ⇒ Xlsx
constructor
A new instance of Xlsx.
-
#parse(data) ⇒ Array<Array<String>>
Parse the document and return the text.
Methods included from DependencyHelper
Constructor Details
#initialize ⇒ Xlsx
Returns a new instance of Xlsx.
9 10 11 12 |
# File 'lib/bx_builder_chain/processors/xlsx.rb', line 9 def initialize(*) depends_on "roo" require "roo" end |
Instance Method Details
#parse(data) ⇒ Array<Array<String>>
Parse the document and return the text
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bx_builder_chain/processors/xlsx.rb', line 17 def parse(data) output = [] xlsx_file = Roo::Spreadsheet.open(data) xlsx_file.each_with_pagename do |sheet, rows| output << rows.map do |row| row.map { |i| i.to_s.strip } end end output end |