title: Decode base64 encoded string into xls
body: <p>I have linked a JSON response on user's request to fetch an excel document, the response is in the manner </p>
  
  <pre><code>  {
    "format": // file extn ----only xls
    "docTitle": //file name
    "document" :// base 64 encoded data
    }
  </code></pre>
  
  <p>I tried to handle the API on Frontend by decoding the document key using atob() function.</p>
  
  <pre><code>  downloadTemplate() {
    this.fetchData.fetchDownloadTemplate().subscribe(
    res =&gt; {
      let docString = atob(res.document);
      let format = res.format;
      let fileName = res.docTitle;
  
      let file = new Blob([docString], {type: "text/xls"});
  
      let url = URL.createObjectURL(file);
      let dwldLink = document.getElementById('template_link');
      dwldLink.setAttribute("href", url);
      dwldLink.setAttribute("download", fileName);
      document.body.appendChild(dwldLink);
      dwldLink.click();
    },
    err =&gt; {
      console.log(err.responseJSON.message);
    })
    }
  </code></pre>
  
  <p>But the data gets corrupted, On doing some research I got to know that atob() decodes using ASCII charset, while I have done the encoding using charset UTF-8.</p>
  
  <p>Can you suggest any alternative method for decoding the data with UTF-8 charset in typescript, as the angular(v4+) project I am working throws error on using JS validators.</p>