Buttons Extension (excel download)
Buttons Extension (excel download)
dm2000t
Posts: 2Questions: 1Answers: 0
Very new to this, but love the results if I can get it to work.
I have the tables working, just can't get the download/excel buttons to work.
I'm sure I'm missing something simple. Thanks in Advance.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.2.5/css/select.dataTables.min.css"/>
<style type="text/css" class="init">
</style>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>
<script type="text/javascript" class="init">
$(document).ready(function() {
$('#example').DataTable({
buttons: [
'copy', 'excel', 'pdf'
]});
} );
</script>
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</tbody>
</table>
</body>
</html>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I'm guessing by " can't get the download/excel buttons to work." you mean they aren't showing?
If so then you probably need to add the
B
option to thedom
option. Take a look here:https://datatables.net/reference/option/dom#Plug-ins
and here:
https://datatables.net/extensions/buttons/examples/initialisation/simple.html
If that's not the problem then please be more specific with whats not working and any alert or browser console messages you are getting.
Kevin
I have same problem with 'excel'
I was use bellow code
buttons: [
'copy', 'excel', 'pdf'
]
But, only Copy and Pdf button display, Excel button cannot display
Hi @toson1003 ,
As Kevin said above, you need to specify the
B
option in thedom
settings to show buttons. But as you're seeing some, your problem is different, for you it's probably because you're missing some of the sources. See the example on this page - if you check the 'JavaScript' and 'CSS' tabs, you'll see the files you need to include.Cheers,
Colin
Hi @colin ,
Thanks for your reply
I found cause is missing file jszip.min.js
Thanks !
Thank You Kevin that worked.
I knew it had to be something easy. Thank you so much for your help.
For reference for those that might be seeing the same issue:
This is the working code: