Exporting specific columns

In a project I am working on I had a ng-table where the user could choose which column he wanted to see dynamically, much like this example: http://bazalt-cms.com/ng-table/example/20
When I wanted to export the data to csv however it would take the whole table instead of the columns I had selected, so I added a little code that would check if any of the headers in the table had a class called 'no-export', which indicated that those columns should not be exported. So the data to be exported would only be the columns he had selected.
It works for any number of columns and I hope it can be of any help.