From 51f56037c2e637292c1dcedbf20aeac82b97e5bc Mon Sep 17 00:00:00 2001 From: yudingyi Date: Thu, 22 Jun 2023 16:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8A=E4=BC=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D=E4=B8=BA=E6=95=B0=E5=80=BC=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E8=A2=AB=E8=AF=95=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sof_eng/Controller/ExperimentController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sof_eng/Controller/ExperimentController.java b/src/main/java/com/sof_eng/Controller/ExperimentController.java index 732531c..a0c51b2 100644 --- a/src/main/java/com/sof_eng/Controller/ExperimentController.java +++ b/src/main/java/com/sof_eng/Controller/ExperimentController.java @@ -218,7 +218,7 @@ public class ExperimentController { */ @CrossOrigin @PostMapping("/uploadParticipant") - public CommonResult uploadParticipant(@RequestPart("expId") Long expId, @RequestPart("file") MultipartFile file,@RequestHeader("Authorization") String authHeader){ + public CommonResult uploadParticipant(@RequestParam("expId") Long expId, @RequestPart("file") MultipartFile file,@RequestHeader("Authorization") String authHeader){ //验证expId Experiment experiment = experimentService.getExperimentById(expId); if(experiment == null){ @@ -245,7 +245,13 @@ public class ExperimentController { for (Row row : sheet) { // 获取参与者信息,假设参与者信息在第一列(索引为0) Cell participantCell = row.getCell(0); - String participant = participantCell.getStringCellValue(); + + String participant; + try { + participant = participantCell.getStringCellValue(); + }catch(Exception e) { + participant = String.valueOf(participantCell.getNumericCellValue()); + } User user = userService.getUserByName(participant); if(user == null){ -- Gitee