7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/squib/import/xlsx_importer.rb', line 7
def import_to_dataframe(import, &block)
s = Roo::Excelx.new(import.file)
s.default_sheet = s.sheets[import.sheet]
data = Squib::DataFrame.new
s.first_column.upto(s.last_column) do |col|
= s.cell(s.first_row, col).to_s
.strip! if import.strip?
data[] = []
(s.first_row + 1).upto(s.last_row) do |row|
cell = s.cell(row, col)
cell = s.excelx_value(row, col) if s.excelx_type(row, col) == [:numeric_or_formula, 'General']
cell.strip! if cell.respond_to?(:strip) && import.strip?
cell = block.yield(, cell) unless block.nil?
data[] << cell
end
end
explode_quantities(data, import.explode)
end
|