From 12b04f145bae740e1971036b1e2dfc1bc224d17b Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Wed, 11 Jul 2018 14:38:47 +0800 Subject: [PATCH] Revert "框架调整" --- src/app/routes/delon/xlsx/xlsx.component.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) diff --git a/src/app/routes/delon/xlsx/xlsx.component.ts b/src/app/routes/delon/xlsx/xlsx.component.ts new file mode 100644 index 0000000..c67a0bf --- /dev/null +++ b/src/app/routes/delon/xlsx/xlsx.component.ts @@ -0,0 +1,50 @@ +import { Component, OnInit } from '@angular/core'; +import { XlsxService, SimpleTableColumn } from '@delon/abc'; + +@Component({ + selector: 'app-xlsx', + templateUrl: './xlsx.component.html', +}) +export class XlsxComponent { + constructor(private xlsx: XlsxService) {} + data: any; + url() { + this.xlsx.import(`./assets/tmp/demo.xlsx`).then(res => (this.data = res)); + } + + change(e: Event) { + const file = (e.target as HTMLInputElement).files[0]; + this.xlsx.import(file).then(res => (this.data = res)); + } + + users: any[] = Array(100) + .fill({}) + .map((item: any, idx: number) => { + return { + id: idx + 1, + name: `name ${idx + 1}`, + age: Math.ceil(Math.random() * 10) + 20, + }; + }); + + columns: SimpleTableColumn[] = [ + { title: '������', index: 'id', type: 'checkbox' }, + { title: '������', index: 'name' }, + { title: '������', index: 'age' }, + ]; + + download() { + const data = [this.columns.map(i => i.title)]; + this.users.forEach(i => + data.push(this.columns.map(c => i[c.index as string])), + ); + this.xlsx.export({ + sheets: [ + { + data: data, + name: 'sheet name', + }, + ], + }); + } +} -- Gitblit v1.8.0