title: how to read and validate the excel file in angular
body: <p>Current i am able to read the excel but not able to validate and if user select other file instead of excel file then need to get a popup that "Please select excel file only" </p>
  
  <p>Component.html</p>
  
  <pre><code>&lt;input type="file" accept=".xlsx" class="btn btn-success" (change)="onFileChange($event)"&gt;
  
  &lt;button type="file" class="btn dark btn-outline" 
    (click)="uploadfile()"&gt;Upload&lt;/button&gt;
  </code></pre>
  
  <p>Component.ts</p>
  
  <pre><code> data=[];
   onFileChange(evt: any) {
      debugger
      /* wire up file reader */
      const target: DataTransfer = &lt;DataTransfer&gt;(evt.target);
      if (target.files.length == 1 &amp;&amp; evt.target.accept === ".xlsx" ){
      const reader: FileReader = new FileReader();
      reader.onload = (e: any) =&gt; {
        /* read workbook */
        const bstr: string = e.target.result;
        const wb: XLSX.WorkBook = XLSX.read(bstr, {type: 'binary'});
        console.log(wb);
        /* grab first sheet */
        const wsname: string = wb.SheetNames[0];
        const ws: XLSX.WorkSheet = wb.Sheets[wsname];
        /* save data */
        this.data = &lt;any&gt;(XLSX.utils.sheet_to_json(ws, {header: 1}));
      };
      reader.readAsBinaryString(target.files[0]);
  
     }
    }
  ------
  uploadfile() {
      let keys = this.data.shift();
      let resArr = this.data.map((e) =&gt; {
          let obj = {};
          keys.forEach((key, i) =&gt; {
              obj[key] = e[i];
          });
          return obj;
      });
      console.log(resArr);
      const _data = {
          data: resArr
      }
      this.cinemaService.newoperater(_data).subscribe();
    }
  </code></pre>
  
  <p><code>onFileChange()</code> this method will read the data &amp; <code>uploadfile()</code> this method will convert array of array into object and send it to API</p>
  
  <p>please help me with the validation of excel file </p>