如何使用 angular 4 从某些条件下从 sheetjs 中删除列?
How to delete a column from sheetjs with some condition using angular 4?
var ws = XLSX.utils.json_to_sheet(data);
ws.set_column('Y1', None, None, {'hidden': True});
/* add to workbook */
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'content');
/* generate an XLSX file */
XLSX.writeFile(wb, 'test.xlsx');
}
我正在使用 angular 4 导出 json 对象,它给了我预期的结果。
但是当我试图隐藏特定列时
/* hide column*/
if (this.column === 'No') {
ws.set_column('A1', None, None, {'hidden': True});
}
在此代码中,None
、true
找不到名称 none 和 true。
在 sheetJs 中没有这样的 set_column() 函数。
如果有人真的删除了一些列或行可以通过map
删除
例如:=
假设您的 response
存在于某个名为 resultResposne
的变量中
this.resultResponse.map((obj) =>{
if(){
// your condition goes here
delete obj.`your column`;
}
})
var ws = XLSX.utils.json_to_sheet(data);
ws.set_column('Y1', None, None, {'hidden': True});
/* add to workbook */
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'content');
/* generate an XLSX file */
XLSX.writeFile(wb, 'test.xlsx');
}
我正在使用 angular 4 导出 json 对象,它给了我预期的结果。
但是当我试图隐藏特定列时
/* hide column*/
if (this.column === 'No') {
ws.set_column('A1', None, None, {'hidden': True});
}
在此代码中,None
、true
找不到名称 none 和 true。
在 sheetJs 中没有这样的 set_column() 函数。
如果有人真的删除了一些列或行可以通过map
例如:=
假设您的 response
存在于某个名为 resultResposne
this.resultResponse.map((obj) =>{
if(){
// your condition goes here
delete obj.`your column`;
}
})