Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught Cannot extend unknown button type: excelHtml5

Trying to create an excel export button using the same code I used in another application.

Unfortunately, I am receiving the following error:

Uncaught Cannot extend unknown button type: excelHtml5

Here is the portion of code that produces the buttons above the datatable:

"dom": 'Bfrtip',
"buttons": [
    {
        text: '<i class="fa fa-search"></i> Search All',
        className: 'searchAll btn btn-success btn-sm',
        action: function (e, dt, node, config)
        {
            $('#searchAllModal').modal('show'); 
        }                       
    },                  
    {
        extend: 'excelHtml5',  /*** here is the problem ***/
        title: 'Matchback Rail Export Results',
        text: '<i class="fa fa-download"></i> Export Results',
        className: 'btn btn-secondary btn-sm',
        customize: function( xlsx ) 
        {
            var sheet = xlsx.xl.worksheets['sheet1.xml'];

            $('row c[r^="A"]', sheet).attr( 's', '2' );
        },
        exportOptions: 
        {
            columns: [1,2,3,4,5,6,7,8,9,10]
        }
    },
    {
        extend: 'colvis',
        text: '<i class="fa fa-toggle-on"></i> Toggle Columns',
        className: 'btn btn-secondary btn-sm'
    }
]

The page does not like the "extend: 'excelHtml5'" portion of the code. There's no problem with the "extend: 'colvis'" portion.

I checked to see what libraries I am using:

<script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.colVis.min.js" type="text/javascript"></script>

Upon creating the question, the first suggestion I was given was this:

"Uncaught Cannot extend unknown button type: copyHtml5" - How to use `datatables.net-buttons-bs4`

But that question seems to refer to the .net platform.

What am I missing that will help remove this error?

* UPDATE *

I updated the datatables buttons library from 1.5.2 to 1.5.1. In addition, I was missing the following requirements:

<script src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>

<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>

<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>

<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>

This solved my problem.

like image 753
John Beasley Avatar asked Oct 19 '25 01:10

John Beasley


1 Answers

In this documentation says that it requires the Buttons extension and other requirements, do you meet all the requirements?

like image 181
Franchy Avatar answered Oct 20 '25 15:10

Franchy