Do not include hidden data in Export
Do not include hidden data in Export
I am using datatables buttons to allow export to PDF, CSV,EXCEL, print or copy, using the javascript at:
https://datatables.net/extensions/buttons/examples/initialisation/export.html
using Blfrtip
I am also using the code at https://datatables.net/examples/api/show_hide.html to Show/Hide columns
all works great, I can hide and show columns by clicking on the buttons.
But the export to Excel etc, exports ALL the columns even when I am hiding some columns.
My table has a number of rows for informative viewing, but for practical purposes for instance, I want to export only columns Hostname and IPaddress to CSV and feed that file into some other script.
As it is, I get all the columns and I have to delete all the stuff I don't want.
Is there a way to only export the data in the columns that are showing?
thanks
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This question has accepted answers - jump to:
Answers
You can use
buttons.exportData()
- the `columns' selector for that - see here,Colin
Thanks very much. I have this working now, https://datatables.net/extensions/buttons/examples/html5/columns.html
So this give me the options to export to COPY, EXCEL, PDF. How can I add CSV and Print?
The same principle would apply to those other export methods, you just need to add the same
exportOptions
for those other buttons,Colin
Excellent, ya I see it now thanks.
The print option prints all the columns, I tried to apply exportoptions to print,
But that didnt work. Other than that everything is awesome.
thanks very much
Glad almost there. For
print
, you would need,you missed the
extend:
Colin
That's it! Thanks again.