download in CSV and Excel format issue

download in CSV and Excel format issue

niralinirali Posts: 13Questions: 5Answers: 0

both CSV and Excel format in datatables, downloads data in same CSV format. How to download data in Excel format using datatables, SWF path?

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Sounds like you are using the legacy TableTools extension. Use Buttons which replaces TableTools last year and writes an XLSX file.

    Allan

  • niralinirali Posts: 13Questions: 5Answers: 0

    Thank Allan,

    for that I need to replace

    dom: 'Bfrtip',
    buttons: [
    'copy', 'excel', 'pdf'
    ]
    inplace of

    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sSwfPath": SiteUrl + "/scripts/swf/copy_csv_xls_pdf.swf"
    },

    Please let me know if anything wrong or any js needs to be update or add.
    Thanks..

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Looks fine to me. The way to test it is to try it out :-)

  • niralinirali Posts: 13Questions: 5Answers: 0

    Hi Allan,

    Thanks for your response.

    I tried with above code , but buttons are not displaying. I also tried to add other js files for buttons, still buttons are not displaying on page.

    My code looks like this,
    $('#container .table').DataTable({
    //"sDom": 'T<"clear">lfrtip',
    //"oTableTools": {
    // "sSwfPath": SiteUrl + "/scripts/swf/copy_csv_xls_pdf.swf"
    //}
    "buttons": [
    'copy', 'excel', 'pdf'
    ]
    });

    Also, I have added scripts under






    in my main .cshtml page.

    Thanks lot for your help. please suggest what can I do?

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    I'd be happy to help. Please link to a page showing the issue so I can debug it. Note also that your code above doesn't have a dom option like you suggested in your previous post.

    Allan

  • niralinirali Posts: 13Questions: 5Answers: 0

    Yes, Thanks a lot. I got it. Thanks for your quick support.
    resolved the issue.

  • niralinirali Posts: 13Questions: 5Answers: 0
    edited March 2016

    Hi Allan,

    while testing I found that, PDF option is not working in IE.
    I am getting " Object doesn't support property or method "'defineGetter'" in console.

    Any Idea or solution?

    Please help!!

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Sounds like you are using IE10 or earlier. The pdfmake library doesn't support IE10 or lower. That is something you would need to fix in the external library if you wanted that support. pdfmake is not part of the DataTables project.

    Allan

  • niralinirali Posts: 13Questions: 5Answers: 0

    No, I am using IE 11 windows 8.1. still PDF button is not working.

    $('#listmodel .modal-body .row .panel .list-group .table').dataTable({
    //"sDom": 'T<"clear">lfrtip',
    //"oTableTools": {
    // "sSwfPath": SiteUrl + "/scripts/swf/copy_csv_xls_pdf.swf"
    //}

                                            dom: '<"pull-right"B><"form-group">lfrtip',
                                            buttons: {
                                                name: 'primary',
                                                buttons: [
                                                  {
                                                      extend: 'print',
                                                      title: 'Data export'
                                                  },
                                                {
                                                    extend: 'pdfHtml5',
                                                    title: 'Data export'
                                                },
                                                {
                                                    extend: 'copyHtml5',
                                                    title: 'Data export'
                                                }, {
                                                    extend: 'csvHtml5',
                                                    title: 'Data export(csv)'
                                                },
                                                {
                                                    extend: 'excelHtml5',
                                                    title: 'Data export(excel)'
                                                }]
                                            },
    

    Please let me know if I done any mistake.
    Thanks a lot for reply..

  • niralinirali Posts: 13Questions: 5Answers: 0

    Hi Allan,

    even I took latest version of .js files which are mention in the example of http://datatables.net/extensions/buttons/examples/html5/pdfPage.html.

    Still I am not able to gererate PDF file in IE11.

    Please help!!

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    http://datatables.net/extensions/buttons/examples/html5/pdfPage.html

    That page is not working for you in IE11? It appears to work okay for me and I've not heard of any other users with that issue.

    Could you check your browser isn't in compatibility mode.

    Allan

This discussion has been closed.