class SimpleTextExtract::FormatExtractor::XlsX

Public Instance Methods

extract() click to toggle source
# File lib/simple_text_extract/format_extractor/xls_x.rb, line 6
def extract
  require "roo"

  spreadsheet = Roo::Spreadsheet.open(file, only_visible_sheets: true)

  text = []

  spreadsheet.each_with_pagename do |name, sheet|
    text << name
    1.upto(sheet.last_row.to_i) { |row| text << sheet.row(row) }
  end

  text.flatten.join(" ")
end