简体   繁体   中英

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');

}

i am exporting the json object using angular 4 like this, its giving me expected results.

But when i am trying to hide a particular column

/* hide column*/
if (this.column === 'No') {
ws.set_column('A1', None, None, {'hidden': True});

}

Here in this code it is giving me error for None , true that can not find name none and true.

In sheetJs there is no such set_column() function.

If someone really delete some columns or rows can delete by map

ex:=

suppose you have your response in some variable called resultResposne

this.resultResponse.map((obj) =>{



 if(){ 

    // your condition goes here
       delete obj.`your column`;

    }

})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM