Ver código fonte

在线excel换行文本的分段复制

Karsa 10 meses atrás
pai
commit
3cd02c8b86
1 arquivos alterados com 14 adições e 2 exclusões
  1. 14 2
      src/views/datasheet_manage/components/SheetExcel.vue

+ 14 - 2
src/views/datasheet_manage/components/SheetExcel.vue

@@ -54,12 +54,13 @@ export default {
     },
 
     copyData() {
-      let rangeArr = luckysheet.getRangeArray('twoDimensional');
+      let rangeArr = luckysheet.getRangeValue();
+      console.log(rangeArr)
       let str = ''
       rangeArr.forEach((item,r_index) => {
         let row = ''
         item.forEach((cell,index) => {
-          row+= `${index!==0?'\t':''}${cell||''}`
+          row+= `${index!==0?'\t':''}${cell?(cell.m||this.getCellContent(cell.ct.s)):''}`
         })
         str+= r_index===rangeArr.length-1 ? row : `${row}\n`
       });
@@ -67,6 +68,17 @@ export default {
       copyFit(str)
     },
 
+    // 单元格内的文字分段
+    getCellContent(arr) {
+      if(!arr||!arr.length) return ''
+      let cellStr = ''
+      arr.forEach(_ => {
+        cellStr+=_.v.replace(/\r/,'').replace(/\n/,'')
+      })
+
+      return cellStr;
+    },
+
     updateEmit(){
       this.$emit("updated")
     }