title: Using xlsx in Angular - How to make excel identify the dates as actual dates in column automatically?
body: <p>I have an angular service that creates excel files:</p>
  <pre><code>import { Injectable } from '@angular/core';
  import * as FileSaver from 'file-saver';
  import * as XLSX from 'xlsx';
  
  const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
  const EXCEL_EXTENSION = '.xlsx';
  
  @Injectable()
  export class ExcelService {
  
    constructor() { }
  
    public exportAsExcelFile(json: any[], excelFileName: string): void {
      const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json);
      console.log('worksheet',worksheet);
      const wb: XLSX.WorkBook = { Sheets: { data: worksheet }, SheetNames: ['data'] };
      if(!wb.Workbook) wb.Workbook = {};
      if(!wb.Workbook.Views) wb.Workbook.Views = [];
      if(!wb.Workbook.Views[0]) wb.Workbook.Views[0] = {};
      wb.Workbook.Views[0].RTL = true;
      const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
      this.saveAsExcelFile(excelBuffer, excelFileName);
    }
  
    private saveAsExcelFile(buffer: any, fileName: string): void {
      const data: Blob = new Blob([buffer], {
        type: EXCEL_TYPE
      });
      FileSaver.saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION);
    }
  
  }
  </code></pre>
  <p><strong>The service works</strong> and it creates the file with dates which are <strong>well formatted</strong>, but Excel would only recognize them if I touch them one by one or edit the settings of the entire column.</p>
  <p>That's how I activate the service:</p>
  <pre><code>const temp = this.dataSource.data.map(e =&gt; {
    return {
      'id': controlValueIfNull(e.Id),
      'date': '30/06/2020',
      'time': seperateDateFromHour(e.DonationHour, 'GET_HOUR_ONLY'),
    }
  });
  this.excelService.exportAsExcelFile(temp,&quot;Donations&quot;);
  </code></pre>
  <p>The dates are formatted like that: <em><strong>'01/12/2020'</strong></em> - they are identified automatically if I just take an excel file and write it down, but when I export it, it doesn't recognize them automatically.</p>
  <p>Any thoughts? I would love for some help :)</p>