<button (click)="exportExcel()">
导出
</button>
// 导出
exportExcel(){
if(this.data === undefined) {
this.data = []
this.data.push(['ID','名称','地址','流水线起始端','流水线起始端'])
}
console.log(this.data)
this.utilsService.$http.post<GetDevicesResponse>(this.utilsService.$server + '/api/devices',{
"entriesPerPage": 20,
"pageNumber": 0
}
).subscribe((datas) => {
datas.devicesList.forEach(item=>{
let array=[];
array.push(item._id)
array.push(item.alias)
array.push(item.ipAddr)
array.push(item.first)
array.push(item.last)
this.data.push(array)
})
/* generate worksheet */
const ws: XLSX.WorkSheet = XLSX.utils.aoa_to_sheet(this.data);
/* generate workbook and add the worksheet */
const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// /* save to file */
XLSX.writeFile(wb, 'Sheet2.xlsx');
});
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。