2024年5月6日发(作者:)

handleDrop(e) {

opagation()

tDefault()

if (g) return

const files =

if ( !== 1) {

this.$('Only support uploading one file!')

return

}

const rawFile = files[0] // only use files[0]

if (!l(rawFile)) {

this.$('Only supports upload .xlsx, .xls, .csv suffix files')

return false

}

(rawFile)

opagation()

tDefault()

},

handleDragover(e) {

opagation()

tDefault()

fect = 'copy'

},

handleUpload() {

this.$refs['excel-upload-input'].click()

},

handleClick(e) {

const files =

const rawFile = files[0] // only use files[0]

if (!rawFile) return

(rawFile)

},

upload(rawFile) {

this.$refs['excel-upload-input'].value = null // fix can't select the same excel

if (!Upload) {

Data(rawFile)

return

}

const before = Upload(rawFile)

if (before) {

Data(rawFile)

}

},

readerData(rawFile) {

g = true

return new Promise((resolve, reject) => {

const reader = new FileReader()

= e => {

const data =

const workbook = (data, { type: 'array' })

const firstSheetName = ames[0]

const worksheet = [firstSheetName]

const header = derRow(worksheet)

const results = _to_json(worksheet)

teData({ header, results })

g = false

resolve()

}

ArrayBuffer(rawFile)

})

},

getHeaderRow(sheet) {

const headers = []

const range = _range(sheet['!ref'])

let C

const R = range.s.r

/* start in the first row */

for (C = range.s.c; C <= ; ++C) { /* walk every column in the range */

const cell = sheet[_cell({ c: C, r: R })]

/* find the cell in the first row */

let hdr = 'UNKNOWN ' + C // <-- replace with your desired default

if (cell && cell.t) hdr = _cell(cell)

(hdr)

}

return headers

},

isExcel(file) {

return /.(xlsx|xls|csv)$/.test()

}

}