0

I got problem about my button, which allows to export data to .xlsx file. It works good for Edge, Mozilla and Chrome, but if I try Safari on iphone or Macbook it seems that button is just missing and invisible.

I really need help with this, because can't find a proper solution. Data export should fully work on Safari, Mozilla, Edge, Chrome.

Maybe someone faced similar problem? My code:

$(document).ready(function() {
var table = $('#tableOrders').DataTable( {
    "bFilter" : true,               
    "bLengthChange": true,
    "paging":   true,
    "ordering": true,
    "order": [[ @if ($user->role=='super_admin') 7 @else 6 @endif, "desc" ]],
    "info":true,
    dom: 'lBfrtip',
    lengthMenu: [
        [ 10, 25, 50, -1 ],
        [ '10', '25', '50', 'Show all' ]
    ],
    buttons: [
        {
            extend: 'copyHtml5',
            text: '<b>Copy all</b>',
            exportOptions: {
                columns: [@if($user->role=='super_admin') 0, 1, 2, 3, 4, 5, 6 @else 0, 1, 2, 3, 4 @endif]
            }
        },
        {
            extend: 'excelHtml5',
            text: 'Export all to <b>Excel</b>',
            exportOptions: {
                columns: [@if($user->role=='super_admin') 0, 1, 2, 3, 4, 5, 6 @else 0, 1, 2, 3, 4 @endif]
            }
        },
    ]
} );

} );

3 Answers 3

1

excelHtml5 button does not supported in Safari. There is a note in documentation about it (https://datatables.net/reference/button/excelHtml5):

Safari: No

Safari does not currently support the ability to download generated files (see WebKit bug 156056). As soon as this has been addressed in Safari it will be released here.

Try open their demo in Safari: https://datatables.net/extensions/buttons/examples/initialisation/export.html you won't see Excel button in Safari.

Furthermore based on forum discussion (https://datatables.net/forums/discussion/30444/datatables-built-in-buttons-not-working-with-safari-browser) csv button has limited support in Safari. New tab with generated csv is opened. Try it on demo page.

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

Comments

0

faced the same problem, as stated above it is not supported. But if you want to maintain integrity between browsers you can validad via user-agent for safari and pass the string to a variable. since CSV works on Safari.

 var xls; // variable csv ó excel
    (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) ? xls = 'csv' : xls = 'excel'; //verify

then you extend:

  extend: xls, title: 'yourtitle', className: "btn-sm"

Comments

0

The latest version of Datatables.Buttons works in Safari.

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.