Угловая таблица ленивая нагрузка
onFileSelected(files: FileList) {
console.log(files)
console.log(files[0])
this.csvIsParsing = true;
let file = files[0];
// xls is the same MIME type like csv
let csvType = "application/vnd.ms-excel";
let xlsxType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
if (file.type !== csvType && file.type !== xlsxType) {
this.wrongFileTypeError = true;
this.csvIsParsing = false;
return;
} else if (files.length > 1) {
this.tooManyFilesError = true;
this.csvIsParsing = false;
return;
}
this.fileName = file.name;
this.checkFileSize(file.size);
this.wrongFileTypeError = false;
this.tooManyFilesError = false;
if (files.length > 0 && file.type === csvType) { //temporarily
this.csvParser.parse(file, {
header: this.hasCsvHeader,
skipEmptyLines: true,
dynamicTyping: true,
// dynamicTyping: true, lässt 0 verschwinden vor 010000
encoding: "ISO-8859-1",
complete: (result) => {
console.log('Parsed: ', result.data);
this.csvData = result.data;
this.dataSource = new MatTableDataSource(result.data);
this.dataSource.sort = this.sort;
setTimeout(() => this.dataSource.paginator = this.paginator);
for (let col in this.csvData[0]) {
this.displayedColumns.push(col);
}
console.log(this.dataSource);
this.csvIsParsing = false;
}
});
}
}
Jittery Jellyfish