import XLSX from 'xlsx'
import papa from 'papaparse'
papa.parse(this.textarea, {
skipEmptyLines: true,
encoding: 'gbk',
delimiter: ' ',
complete: (results, file) => {
for (let index = 0; index < results.data.length; index++) {
const element = results.data[index]
this.params.relationSkus.push({localSku: element[0], thirdPartySku: element[1]})//转换数据结构
}
}
})
let reader = new FileReader();
let zzexcel
reader.readAsBinaryString(this.file);
reader.onload = (e) => {
let data = e.target.result;
zzexcel = XLSX.read(data, {
type: 'binary'
})
console.log(JSON.stringify(XLSX.utils.sheet_to_json(zzexcel.Sheets[zzexcel.SheetNames])), 299)//转化后的数据
this.params.relationSkus = JSON.stringify(XLSX.utils.sheet_to_json(zzexcel.Sheets[zzexcel.SheetNames]))
// console.log(zzexcel, 300)
}