add: download and import user template xlsx

This commit is contained in:
2022-05-16 16:59:25 +08:00
parent 50dc5cce5d
commit 77620f7735
5 changed files with 90 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
class Admins::NewImportUserFromExcel < BaseImportXlsx
UserData = Struct.new(:login, :email, :password, :nickname)
def read_each(&block)
sheet.each_row_streaming(pad_cells: true, offset: 1) do |row|
data = row.map(&method(:cell_value))[0..3]
block.call UserData.new(*data)
end
end
private
def cell_value(obj)
obj&.cell_value
end
end