cscan / vue-excel-editor

Vue2 plugin for displaying and editing the array-of-object in Excel style
MIT License
557 stars 108 forks source link

Copy paste should create new rows and columns #120

Closed agentaswin closed 2 years ago

agentaswin commented 2 years ago

Hi,

Following is my requirement, if i copy rows from excel and paste it inside the table it should create new rows and copy the contents. With current framework i am not able to do so(upto my knowledge). Is there any hack or someway i can override this copy and paste behaviour?

Thanks upfront

cscan commented 2 years ago

Not an easy tasks, you may interest in the following codes in VueExcelEditor.vue that handling the paste content. You could clone the project and revised this part to achieve your function.

    winPaste (e) {
      if (e.target.tagName !== 'TEXTAREA') return
      if (!this.mousein && !this.focused) return
      if (!this.currentField || this.currentField.readonly) return
      if (this.inputBoxShow) {
        this.inputBoxChanged = true
        return
      }
      const text = (e.originalEvent || e).clipboardData.getData('text/plain')
      this.inputCellWrite(text)
      e.preventDefault()
    },
agentaswin commented 2 years ago

ah, thank you.