From 26ae4f5fac95f21a039103bde6d0c9eb91308dd6 Mon Sep 17 00:00:00 2001 From: lxn <964491948@qq.com> Date: Tue, 5 Dec 2023 21:06:52 +0800 Subject: [PATCH] fix issue 46 51 --- src/main/kotlin/SpellLog.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/SpellLog.kt b/src/main/kotlin/SpellLog.kt index 832f98f..ac16328 100644 --- a/src/main/kotlin/SpellLog.kt +++ b/src/main/kotlin/SpellLog.kt @@ -60,7 +60,7 @@ object SpellLog { val file = File("log.xlsx") if (!file.exists()) file.createNewFile() val os = ByteArrayOutputStream() - XSSFWorkbook(OPCPackage.open(file, PackageAccess.READ)).use { wb -> + XSSFWorkbook(OPCPackage.open(file, PackageAccess.READ_WRITE)).use { wb -> for (i in 0 until logList.size) { val sheet = wb.getSheetAt(i) for (model in logList[i]) { @@ -158,8 +158,15 @@ object SpellLog { val sheet = wb.getSheetAt(0) val logSheet = logWB.getSheetAt(j) for (i in 1..sheet.lastRowNum) { - logSheet.createRow(i).createCell(0) - .setCellValue(sheet.getRow(i).getCell(3).stringCellValue.trim()) + sheet.getRow(i).getCell(3).stringCellValue.trim().let { + logSheet.createRow(i).createCell(0) + .setCellValue(it) + // 新增的符卡需要增加到现有列表中 + if (logList.isNotEmpty() && logList[j][it] == null) { + logList[j][it] = + LogModel(sheet.getRow(i).getCell(1).numericCellValue.toInt(), 0, 0, 0, 0) + } + } } } }