Skip to content
Advertisement

How to drop a column when exporting data from html table to csv file?

Assume, Im having a table like below:MyTable

I need to drop the “Contact” column and export the remaining column to the CSV file.

HTML:

JavaScript

On click of the download button, js function will get called.

JavaScript

JavaScript

Error:

JavaScript

How to export table data to CSV by excluding a specific column?.Any way to achieve this.

Thanks.

Advertisement

Answer

If you find a collection of table headers and from that find the cell that contains the exclusion term ( Contact ) in it’s textContent you can use that index later to exclude table cells ( per row ) of the same index.

JavaScript
Advertisement