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


Fanny Zhingre
  • 183
  • 1
  • 1
  • 10
  • 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](https://stackoverflow.com/questions/61473549/how-to-convert-csv-to-an-array-of-js-objetcs) – Obie Sep 19 '22 at 06:29
  • [ask] -> Add a [mcve] _in the question itself_ – Andreas Sep 19 '22 at 06:34

1 Answers1

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

VerZsuT
  • 51
  • 2