Issue
This Content is from Stack Overflow. Question asked by Happy
I want to import an excel with this code but I get this error
Cannot read properties of undefined (reading '0')
This File import
Can this type of file be imported?
Book.csv
1,chocolate,brown,10
2,gum,red,11
3,juice,yellow,5
I read the app.component.ts file it says that I can import 4 columns.
app.component.ts
var columns = {
'A': '',
'B': 'Make',
'C': 'Model',
'D': 'Price'
};
Solution
The error occurs in this section of the App component code
populateGrid(file: any) {
// our data is in the first sheet
var firstSheetName = file.SheetNames[0];
The SheetNames
field is missing in the file
argument (=undefined).
Check the type of the accepted object
This Question was asked in StackOverflow by Happy and Answered by VerZsuT It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.