mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-02 13:12:13 +08:00
Merge pull request #932 from okriuchykhin/ok_SCI_1915
Improve XLSX parsing with Roo [SCI-1915]
This commit is contained in:
commit
00927be287
3 changed files with 13 additions and 4 deletions
|
@ -132,8 +132,7 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
total_nr += 1
|
||||
|
||||
# Creek XLSX parser returns Hash of the row, Roo - Array
|
||||
row = row.is_a?(Hash) ? row.values.map(&:to_s) : row.map(&:to_s)
|
||||
row = SpreadsheetParser.parse_row(row, sheet)
|
||||
|
||||
record_row = RepositoryRow.new(name: row[name_index],
|
||||
repository: self,
|
||||
|
|
|
@ -80,8 +80,7 @@ class Team < ActiveRecord::Base
|
|||
next
|
||||
end
|
||||
total_nr += 1
|
||||
# Creek XLSX parser returns Hash of the row, Roo - Array
|
||||
row = row.is_a?(Hash) ? row.values.map(&:to_s) : row.map(&:to_s)
|
||||
row = SpreadsheetParser.parse_row(row, sheet)
|
||||
|
||||
sample = Sample.new(name: row[sname_index],
|
||||
team: self,
|
||||
|
|
|
@ -52,4 +52,15 @@ class SpreadsheetParser
|
|||
end
|
||||
return header, columns
|
||||
end
|
||||
|
||||
def self.parse_row(row, sheet)
|
||||
# Creek XLSX parser returns Hash of the row, Roo - Array
|
||||
if row.is_a?(Hash)
|
||||
row.values.map(&:to_s)
|
||||
elsif sheet.is_a?(Roo::Excelx)
|
||||
row.map { |cell| cell.value.to_s }
|
||||
else
|
||||
row.map(&:to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue