title: Angular / Typescript Reading Excel File from url
body: <p>I need my app to able to read a prepared excel file (located in my domain (<code>www.***.com/data.xlsx</code>)) into an array. The followings code works like charm for the purpose but its client based where user browse and input for the <code>xlsx</code> file.</p>
  <pre class="lang-ts prettyprint-override"><code>import {
    Component,
    OnInit
  } from '@angular/core';
  import * as XLSX from 'xlsx';
  
  @Component({
    selector: 'app-excelsheet',
    templateUrl: './excelsheet.component.html',
    styleUrls: ['./excelsheet.component.css']
  })
  export class ExcelsheetComponent implements OnInit {
  
    data: [][];
    constructor() {}
  
    ngOnInit(): void {}
    onFileChange(evt: any) {
      const target: DataTransfer = &lt;DataTransfer&gt;(evt.target);
  
      if (target.files.length !== 1) throw new Error('Cannot use multiple files');
  
      const reader: FileReader = new FileReader();
  
      reader.onload = (e: any) =&gt; {
        const bstr: string = e.target.result;
        const wb: XLSX.WorkBook = XLSX.read(bstr, {
          type: 'binary'
        });
        const wsname: string = wb.SheetNames[0];
        const ws: XLSX.WorkSheet = wb.Sheets[wsname];
  
        console.log(ws);
  
        this.data = (XLSX.utils.sheet_to_json(ws, {
          header: 1
        }));
  
        console.log(this.data);
  
        let x = this.data.slice(1);
        console.log(x);
      };
  
      reader.readAsBinaryString(target.files[0]);
    }
  }
  </code></pre>
  <p>I tried various ways through trial and errors, testing the functions and variables, other libraries, read about client/server based but still now I'm kinda in dead end, maybe because I have less experience into JavaScript.</p>
  <p>For Short, <strong>How can my app read the excel file(from a URL) to an array everytime the app started?</strong></p>
  <p>For extra, I also tried inserting the excel file inside the app directory, but still...</p>
  <p>I know I should have put my code attempt for you guys to troubleshoot but I will just think its just a weird attempts as I'm really new. I hope you guys can briefly list what I should use and do, thanks in advance, I appreciate it.</p>