Parcourir la source

fix(excel): 修复工作表保护和单元格锁定问题

- 在ExcelController中添加worksheet.protect()调用以保护工作表
- 移除重复的worksheet.protect()调用避免冲突
- 为表格范围添加setLocked(false)确保可编辑性
- 注释掉GrapeCityController中的调试日志输出
xuzhancheng il y a 11 heures
Parent
commit
f53a2aa5bd

+ 5 - 1
src/main/java/com/grapecity/controller/ExcelController.java

@@ -123,6 +123,8 @@ public class ExcelController {
             handleCheckboxCells(worksheet);
 
             highlightEditableCells(worksheet, editCols);
+
+            worksheet.protect();
         }
 
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -323,7 +325,7 @@ public class ExcelController {
 
         IRange usedRange = worksheet.getUsedRange();
         if (usedRange == null) return;
-        worksheet.protect();
+
         // ① 全部单元格设为不可编辑(对齐前端 cellRange.allowEditInCell(false))
         usedRange.setLocked(true);
 
@@ -417,6 +419,8 @@ public class ExcelController {
             }
 
             tableRange.setWrapText(true);
+
+            tableRange.setLocked(false);
         }
     }
 

+ 1 - 1
src/main/java/com/grapecity/controller/GrapeCityController.java

@@ -43,7 +43,7 @@ public class GrapeCityController {
             throw new IllegalArgumentException("请求参数不能为空");
         }
 
-        logger.debug("收到 filePath 请求:{}", request);
+//        logger.debug("收到 filePath 请求:{}", request);
 
         // 从 JSON 中获取 templateBytes,避免反序列化为 ArrayList
         byte[] templateBytesArray = convertToByteArray(request.get("templateBytes"), "templateBytes");