|
@@ -38,6 +38,7 @@ import org.jeecg.modules.system.model.DepartIdModel;
|
|
|
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
|
|
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
|
|
import org.jeecg.modules.system.service.*;
|
|
|
+import org.jeecg.modules.system.util.ExcelImportHandleUtil;
|
|
|
import org.jeecg.modules.system.vo.SysDepartUsersVO;
|
|
|
import org.jeecg.modules.system.vo.SysUserRoleVO;
|
|
|
import org.jeecg.modules.system.vo.lowapp.DepartAndUserInfo;
|
|
@@ -625,58 +626,8 @@ public class SysUserController {
|
|
|
String[] expectedHeaders = {"登录账号", "真实姓名", "性别", "电话", "工号", "所属部门"};
|
|
|
boolean isHeaderValid = checkHeader(headerRow, expectedHeaders);
|
|
|
|
|
|
- Workbook book = WorkbookFactory.create(file.getInputStream());
|
|
|
- Sheet tempSheet = book.getSheetAt(0);
|
|
|
- int lastRowNum = tempSheet.getLastRowNum();
|
|
|
- int startRowNum = 3;
|
|
|
-
|
|
|
- // 创建一个新的Workbook和Sheet
|
|
|
- Workbook newBook = new XSSFWorkbook();
|
|
|
- Sheet newSheet = newBook.createSheet("Filtered Data");
|
|
|
-
|
|
|
- int newRowNum = 0; // 新Sheet的行号
|
|
|
-
|
|
|
- // 复制前三行
|
|
|
- for (int i = 0; i < startRowNum; i++) {
|
|
|
- Row row = tempSheet.getRow(i);
|
|
|
- if (row != null) {
|
|
|
- Row newRow = newSheet.createRow(newRowNum++);
|
|
|
- for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
|
|
|
- Cell cell = row.getCell(j);
|
|
|
- if (cell != null) {
|
|
|
- Cell newCell = newRow.createCell(j);
|
|
|
- copyCell(cell, newCell);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = startRowNum; i <= lastRowNum; i++) {
|
|
|
- Row row = tempSheet.getRow(i);
|
|
|
- if (row != null) {
|
|
|
- short firstCellNum = row.getFirstCellNum();
|
|
|
- if (firstCellNum != -1) {
|
|
|
- // 复制行到新的Sheet
|
|
|
- Row newRow = newSheet.createRow(newRowNum++);
|
|
|
- for (int j = firstCellNum; j <= row.getLastCellNum(); j++) {
|
|
|
- Cell cell = row.getCell(j);
|
|
|
- if (cell != null) {
|
|
|
- Cell newCell = newRow.createCell(j);
|
|
|
- copyCell(cell, newCell);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 将新的Workbook写入ByteArrayOutputStream
|
|
|
- ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
|
|
- newBook.write(byteArrayOut);
|
|
|
- newBook.close();
|
|
|
- book.close();
|
|
|
+ InputStream inputStream = ExcelImportHandleUtil.fileStreamProcessing(file, 3, 0);
|
|
|
|
|
|
- // 获取InputStream
|
|
|
- InputStream inputStream = new ByteArrayInputStream(byteArrayOut.toByteArray());
|
|
|
- byteArrayOut.close();
|
|
|
|
|
|
List<SysUser> listSysUsers = ExcelImportUtil.importExcel(inputStream, SysUser.class, params);
|
|
|
|
|
@@ -2208,24 +2159,4 @@ public class SysUserController {
|
|
|
// 如果没有找到匹配的节点,返回null
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
- private void copyCell(Cell oldCell, Cell newCell) {
|
|
|
- switch (oldCell.getCellType()) {
|
|
|
- case STRING:
|
|
|
- newCell.setCellValue(oldCell.getStringCellValue());
|
|
|
- break;
|
|
|
- case NUMERIC:
|
|
|
- newCell.setCellValue(oldCell.getNumericCellValue());
|
|
|
- break;
|
|
|
- case BOOLEAN:
|
|
|
- newCell.setCellValue(oldCell.getBooleanCellValue());
|
|
|
- break;
|
|
|
- case FORMULA:
|
|
|
- newCell.setCellFormula(oldCell.getCellFormula());
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|