Export to excel
Export to excel

This is two part question. I have a datatable that I want to export to excel, which works with using the default button, however:
Is there a way to call that same function from my own button on the button click event? I have a row of buttons and don't want a random button over the datatable
Is there a way to give the export file a name? Right now, it's naming it "home page", I want to specify the name. [ update, just found the answer to this one, so, just the first one ]
Is there a way to just open the excel file instead of saving of option 2 isn't possible?
This question has an accepted answers - jump to answer
Answers
Are you saying you have a row of buttons in the -tag tbody` that you don't want to export?
Possibly you can use the
excelHtml5
button's exportOptions to select the rows to export. Maybe add a class to the rows you don't want to export and use therow-selector
as a string to select the rows to export.Can you provide a simple example showing what you have with a description of what you don't want exported so we can provide more specific suggestions?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I show a modal with the datatable, I have several buttons on the modal that do things, instead of using the default datatable buttons, I want my button to call the export to excel function instead of the default DT buttons in datatable toolbar. I'm able to export the datatable, but I want to show my buttons instead.
Sorry misunderstood where the buttons were located. I think the easiest option is to create the standard Excel button and use
buttons.buttons.className
to set a class that hides the button. Then in the event handler for your button usebutton().trigger()
to click the hidden Excel button.Kevin
Do you have example of that? The documentation is kind of vague on it.
never mind, I got it working, thanks
Thanks for posting back - good to hear you've got it working.
Allan