-1

I want to import an excel with this code but I get this error

Angular Ag Grid Excel Import

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'
    };


2
  • What are the expected file types? If its only CSV, you do not need any other library. You can just parse the file as text like shown here Commented Sep 19, 2022 at 6:29
  • How to Ask -> Add a minimal reproducible example in the question itself Commented Sep 19, 2022 at 6:34

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

2 Comments

This is a comment and not an answer.
I would argue it justifies an answer since it seems to find the problem and work toward an answer. More detail would definitely make it better

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.