Browse Source

analyzePasteData容错,复制粘贴包含行头的时候

zhongzewei 6 years ago
parent
commit
b7bddda544
1 changed files with 5 additions and 3 deletions
  1. 5 3
      public/web/sheet/sheet_common.js

+ 5 - 3
public/web/sheet/sheet_common.js

@@ -239,15 +239,17 @@ var sheetCommonObj = {
                     itemObj = {};
                 }
             } else if (pastedInfo.pasteData.text[i] === "\t" || pastedInfo.pasteData.text[i] === "\r") {
-                itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
+                if (setting.header[propId]) {
+                    itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
+                }
                 propId++;
                 preStrIdx = i + 1;
                 //if the last copied-cell were empty, should check whether the end of text
-                if (i == pastedInfo.pasteData.text.length - 1) {
+                if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
                     itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                     rst.push(itemObj);
                 }
-            } else if (i == pastedInfo.pasteData.text.length - 1) {
+            } else if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
                 itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                 rst.push(itemObj);
             }