Export to Excel button not showing

My export to excel button keep not showing even after i used those code above. I don't have any idea with what's happening with those code. Someone with greater experience please help me. I got my reference from https://datatables.net/extensions/buttons/examples/initialisation/export.html

        <table id="example" class="display nowrap" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Tiger Nixon</td>
                <td>System Architect</td>
                <td>Edinburgh</td>
                <td>61</td>
                <td>2011/04/25</td>
                <td>$320,800</td>
            </tr>
            <tr>
                <td>Garrett Winters</td>
                <td>Accountant</td>
                <td>Tokyo</td>
                <td>63</td>
                <td>2011/07/25</td>
                <td>$170,750</td>
            </tr>
            <tr>
                <td>Ashton Cox</td>
                <td>Junior Technical Author</td>
                <td>San Francisco</td>
                <td>66</td>
                <td>2009/01/12</td>
                <td>$86,000</td>
            </tr>
        </tbody>
    </table>

<script>
    $(document).ready(function () {
        $('#example').DataTable({
            dom: 'Bfrtip',
            buttons: [
                'excel'
            ]
        });
    });
</script>

Here's the console output:

enter image description here

Answers 1

  • In order to you use the export plugin you also need to include the following scripts:

    //code.jquery.com/jquery-1.12.4.js https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js //cdn.datatables.net/buttons/1.2.4/js/buttons.flash.min.js //cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js //cdn.rawgit.com/bpampuch/pdfmake/0.1.24/build/pdfmake.min.js //cdn.rawgit.com/bpampuch/pdfmake/0.1.24/build/vfs_fonts.js //cdn.datatables.net/buttons/1.2.4/js/buttons.html5.min.js //cdn.datatables.net/buttons/1.2.4/js/buttons.print.min.js

    This is detailed in the link you provided. View the source of that page to see how they've included them.


Related Articles