Skip to content

Commit

Permalink
Demo update
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed May 18, 2021
1 parent 529bc7a commit 9540343
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions src/app/showcase/components/table/tableexportdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ <h1>Table <span>Export</span></h1>
import &#123; Component, OnInit &#125; from '@angular/core';
import &#123; Product &#125; from '../../domain/product';
import &#123; ProductService &#125; from '../../service/productservice';
import * as FileSaver from 'file-saver';

@Component(&#123;
templateUrl: './tableexportdemo.html'
Expand Down Expand Up @@ -125,14 +126,12 @@ <h1>Table <span>Export</span></h1>
&#125;

saveAsExcelFile(buffer: any, fileName: string): void &#123;
import("file-saver").then(FileSaver =&gt; &#123;
let EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
let EXCEL_EXTENSION = '.xlsx';
const data: Blob = new Blob([buffer], &#123;
type: EXCEL_TYPE
&#125;);
FileSaver.saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION);
let EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
let EXCEL_EXTENSION = '.xlsx';
const data: Blob = new Blob([buffer], &#123;
type: EXCEL_TYPE
&#125;);
FileSaver.saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION);
&#125;
&#125;
</app-code>
Expand Down
13 changes: 6 additions & 7 deletions src/app/showcase/components/table/tableexportdemo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Product } from '../../domain/product';
import { ProductService } from '../../service/productservice';
import * as FileSaver from 'file-saver';

@Component({
templateUrl: './tableexportdemo.html'
Expand Down Expand Up @@ -50,13 +51,11 @@ export class TableExportDemo implements OnInit {
}

saveAsExcelFile(buffer: any, fileName: string): void {
import("file-saver").then(FileSaver => {
let EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
let EXCEL_EXTENSION = '.xlsx';
const data: Blob = new Blob([buffer], {
type: EXCEL_TYPE
});
FileSaver.saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION);
let EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
let EXCEL_EXTENSION = '.xlsx';
const data: Blob = new Blob([buffer], {
type: EXCEL_TYPE
});
FileSaver.saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION);
}
}

0 comments on commit 9540343

Please sign in to comment.