2

I have this code to enable the excel export button:

self.dtOptions = DTOptionsBuilder.newOptions()
    .withButtons([
        {
            extend: 'excel',
            text: 'Export to Excel',
            title: 'banana report'
        }]);

Previously I have used this code to hide the column in the datatable but have it show up in the excel:

self.dtColumnDefs = [
    DTColumnDefBuilder.newColumnDef(11).notVisible()
];

But how can I do the opposite? How can I hide in excel but not the datatable?

1 Answer 1

2

Use exportOptions. For example

.withButtons([
   {
    extend: 'excel',
    text: 'Export to Excel',
    title: 'banana report',
    exportOptions: {
      columns: [ 0, 1, 6, 7 ]
    }
   }])

Will only export the specifed column indexes. See

https://datatables.net/extensions/buttons/examples/html5/columns.html https://datatables.net/extensions/buttons/examples/print/columns.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.