mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
add: download and import user template xlsx
This commit is contained in:
15
app/imports/admins/new_import_user_from_excel.rb
Normal file
15
app/imports/admins/new_import_user_from_excel.rb
Normal 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
|
||||
Reference in New Issue
Block a user