Skip to content

Commit

Permalink
chore: only accept CSV files
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jan 13, 2025
1 parent bd2f77d commit 2ad27c3
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ export class Example43 {
}

handleFileImport(event: any) {
const file = event.target.files[0];
if (file) {
const file: File = event.target.files[0];
if (file.name.endsWith('.csv')) {
const reader = new FileReader();
reader.onload = (e: any) => {
const content = e.target.result;
this.dynamicallyCreateGrid(content);
};
reader.readAsText(file);
} else {
alert('File must be a CSV file');
}
}

Expand Down

0 comments on commit 2ad27c3

Please sign in to comment.