Error when trying to remove title from Excel Export

Error when trying to remove title from Excel Export

alan.okellyalan.okelly Posts: 2Questions: 1Answers: 0

I'm having some issues trying to remove the title form an Excel export. Right now I'm extending the buttons to set the filename, but when I export the file the first row is the page title that's set in my HTML page. I saw that this can be removed from the file by setting the title to an empty string. This works for CSV and PDF files, but when I open the Excel file I get a message from Excel that there was a problem with the content in the file being generated (This happens if I set the title to null as well). I get a modal popup from Excel asking if I want to continue. When the load is complete the file appears to be correct, but I need to be able export the excel file without a huge error message appearing every time. Anyone have any experience with this? Below is the code:

    $(document).ready(function () {
        $('#<%= gvReport.ClientID %>').DataTable({
            dom: 'Bfrtip',
            buttons: [
                {
                    extend: 'excel',
                    filename: 'MostRecentVideoCreatedByDealer',
                    title: ''
                },
                {
                    extend: 'csv',
                    filename: 'MostRecentVideoCreatedByDealer',
                    title: ''
                },
                {
                    extend: 'pdf',
                    filename: 'MostRecentVideoCreatedByDealer',
                    title: ''
                }
            ],
            paging: false,
            searching: false,
            order: [[1, 'desc']]
        });
    })

Thanks!

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,147Questions: 26Answers: 4,918
    Answer ✓

    You likely need to upgrade Buttons. A forum search brings up this recent post:
    https://datatables.net/forums/discussion/44759

    Kevin

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

    Yup - the nightly has the fix. I plan to tag a new release fairly soon (if not this week, then next).

    Allan

  • alan.okellyalan.okelly Posts: 2Questions: 1Answers: 0

    Thank you so much for the quick reply. This is very helpful.

    Also great job on this software! I absolutely love DataTables!

  • aviennasaviennas Posts: 5Questions: 2Answers: 0

    Hello, has there been any change in allowing the naming of the file with specified title but removing the title showing up as header in excel doc?

  • kthorngrenkthorngren Posts: 21,147Questions: 26Answers: 4,918
    edited June 2019

    Since this thread is over a year old I decided to try the latest Buttons version and it works :smile: Used the above example here with the latest code versions from the Download Builder:
    http://live.datatables.net/taxaweyu/1/edit

    Kevin

  • aviennasaviennas Posts: 5Questions: 2Answers: 0

    Thank you very much, I will try it out! Greetings!

This discussion has been closed.