Browse Source

修复复制有问题

xjj 2 years ago
parent
commit
90c008f20c
2 changed files with 40 additions and 36 deletions
  1. 3 1
      src/controllers/selection.js
  2. 37 35
      src/core.js

+ 3 - 1
src/controllers/selection.js

@@ -62,7 +62,9 @@ const selection = {
             "12": "SlantedDashDot",
             "12": "SlantedDashDot",
             "13": "Thick"
             "13": "Thick"
         };
         };
-        type = borderType[type.toString()];
+        type = borderType[type + ""];
+
+        if(!type) type = "none";
 
 
         if(type.indexOf("Medium") > -1){
         if(type.indexOf("Medium") > -1){
             style += "1pt ";
             style += "1pt ";

+ 37 - 35
src/core.js

@@ -321,42 +321,44 @@ function initSheet(sheet, cellAuthority, authority) {
     sheet.config.authority = newAuthority;
     sheet.config.authority = newAuthority;
   } else {
   } else {
     let lastCell = sheet.celldata[sheet.celldata.length - 1];
     let lastCell = sheet.celldata[sheet.celldata.length - 1];
-    let lastCol = String.fromCharCode(lastCell.c);
-    // 第一列禁止编辑但是可以增加
-    let canEditCell = sheet.celldata.filter((item) => {
-      if (item.r == 0) {
-        // 判断是否为空
-        if ((item?.v?.v ?? "") === "" && !item?.v?.ct?.s) return true;
-      }
-    });
-    let canEditRangeList = canEditCell.map((item) => {
-      let col = String.fromCharCode(item.c + 65);
-      return {
-        hintText: "",
-        sqref: `$${col}$1:$${col}$1`,
-      };
-    });
-    // 设置保护区域,lucksheet不能直接设置不允许编辑的区域
-    // 只能禁止整体编辑,设置例外区域
-    sheet.config.authority = {
-      sheet: 1,
-      hintText: "表头只能新增,禁止编辑!",
-      // insertColumns: 0,
-      allowRangeList: [
-        // 第一行以外都能编辑
-        {
-          hintText: "",
-          sqref: `$a$2:$z$99999`,
-        },
-        
-        // 第一列未加载出来的row也允许编辑
-        {
+    if (lastCell) {
+      let lastCol = String.fromCharCode(lastCell.c);
+      // 第一列禁止编辑但是可以增加
+      let canEditCell = sheet.celldata.filter((item) => {
+        if (item.r == 0) {
+          // 判断是否为空
+          if ((item?.v?.v ?? "") === "" && !item?.v?.ct?.s) return true;
+        }
+      });
+      let canEditRangeList = canEditCell.map((item) => {
+        let col = String.fromCharCode(item.c + 65);
+        return {
           hintText: "",
           hintText: "",
-          sqref: `$${lastCol}$1:$${lastCol}$1`,
-        },
-        ...canEditRangeList
-      ],
-    };
+          sqref: `$${col}$1:$${col}$1`,
+        };
+      });
+      // 设置保护区域,lucksheet不能直接设置不允许编辑的区域
+      // 只能禁止整体编辑,设置例外区域
+      sheet.config.authority = {
+        sheet: 1,
+        hintText: "表头只能新增,禁止编辑!",
+        // insertColumns: 0,
+        allowRangeList: [
+          // 第一行以外都能编辑
+          {
+            hintText: "",
+            sqref: `$a$2:$z$99999`,
+          },
+
+          // 第一列未加载出来的row也允许编辑
+          {
+            hintText: "",
+            sqref: `$${lastCol}$1:$${lastCol}$1`,
+          },
+          ...canEditRangeList,
+        ],
+      };
+    }
   }
   }
 
 
   sheet.config.colhidden = colhidden;
   sheet.config.colhidden = colhidden;