VUE 에서 엑셀 파일 을 업로드 하고 내용 을 분석 합 니 다.
import XLSX from 'xlsx' // XLSX
importExcel (content) {
const file = content.file
// let file = file.files[0] // input
const types = file.name.split('.')[1]
const fileType = ['xlsx', 'xlc', 'xlm', 'xls', 'xlt', 'xlw', 'csv'].some(item => item === types)
if (!fileType) {
this.$message(' ! ')
return
}
this.file2Xce(file).then(tabJson => {
if (tabJson && tabJson.length > 0) {
this.xlsxJson = tabJson
this.fileList = this.xlsxJson[0].sheet
let n = ' '
this.fileList.forEach((item, index, arr) => {
if (item[n] === this.name) {
this.dataForm.projectno = item['XXXX'] //
}
})
}
})
},
file2Xce (file) {
return new Promise(function (resolve, reject) {
const reader = new FileReader()
reader.onload = function (e) {
const data = e.target.result
this.wb = XLSX.read(data, {
type: 'binary'
})
const result = []
this.wb.SheetNames.forEach((sheetName) => {
result.push({
sheetName: sheetName,
sheet: XLSX.utils.sheet_to_json(this.wb.Sheets[sheetName])
})
})
resolve(result)
}
// reader.readAsBinaryString(file.raw)
reader.readAsBinaryString(file) // input
})
},
남 의 것 을 거울 로 삼 았 다
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[2022.04.19] 자바스크립트 this - 생성자 함수와 이벤트리스너에서의 this18일에 this에 대해 공부하면서 적었던 일반적인 함수나 객체에서의 this가 아닌 오늘은 이벤트리스너와 생성자 함수 안에서의 this를 살펴보기로 했다. new 키워드를 붙여 함수를 생성자로 사용할 때 this는...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.