angular - 使用 Angular2Csv 插件导出到 xls
问题描述
我正在尝试将来自 api 的数据对象数组导出到 xls。我可以使用插件将数据导出到 xls 。但这里的技巧是只将选定的列导出到 xls。我有一个来自 api 的 5 个对象的数组。我只需要将其中的 2 个导出到 xls。我怎样才能做到这一点?我附上了 [![在此处输入图像描述][1]][1] 生成的报告的快照,其中包含 5 列,但我只需要其中的 2 列。请建议。
解决方案
您可以导出选定的列。有可能的。首先你声明一个数组。比从来自 api 的列表中提取要显示的所需列,然后将它们存储到变量中。之后,您使用 for 循环并将它们推入 arry `this.lstEmployees = this.employee; // 显示活跃员工 //excelSheet 开始
for (var i = 0; i < this.lstEmployees.length; i++) {
this.data.push(
{
Item_Description: this.lstEmployees[i].ITM_DES,
Unit_Of_Measurement: this.lstEmployees[i].UOM_ABR,
Item_Rate: this.lstEmployees[i].QTD_RTE,
Item_Price: this.lstEmployees[i].QTY_PRC,
Item_Quotation: this.lstEmployees[i].QTN_NUM,
Paymen_type: this.lstEmployees[i].PMT_FLG,
Tax_Type: this.lstEmployees[i].TAX_FLG,
Delivery_Type: this.lstEmployees[i].DLV_FLG,
})
}`
这里 lstEmployee 是来自数据库的列表,数据是数组。希望你明白了
推荐阅读
- javascript - 显示分数的提交按钮
- java - 让 AlertDialog 等待用户输入?
- python - Windows 10,RTX 2070]:无法获得卷积算法
- vue.js - 延迟加载组件不适用于 Vue 路由器
- javascript - CSS / 边框图像 / 边框图像切片 / 导致非常小的间隙,如分割线
- ios - 如何在 swift 4、usrlsession 中解决 rest api 调用的性能问题
- haskell - 递归选择排序的正确性证明
- video - 如何在任何浏览器中播放系统中安装了编解码器的任何视频格式?
- python - 如何重命名 FacetGrid (Seaborn) 中的 x-labels?
- javascript - jQuery Masonry 未正确对齐或填充网格中的图像