Export table to CSV (display data)

I had just the same question.
In my case I have a table with start and finish filters, and later a button for exporting displayed data from table to csv, but this script doesn't create any file and an error appears.

Any help, please.
Thanks