Excel export : We found a problem with some content in 'filename.xlsx'. Do you want us to try to re

Excel export : We found a problem with some content in 'filename.xlsx'. Do you want us to try to re

Bhuvana_KBhuvana_K Posts: 2Questions: 1Answers: 0

When I tried to open an excel exported using datatable button, it gives me an error message "We found a problem with some content in 'filename.xlsx'. Do you want us to try to recover as much as we can?". I'm using Buttons for DataTables V 1.5.4. How can I resolve this issue?

Bhuvana

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @Bhuvana_K ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • Bhuvana_KBhuvana_K Posts: 2Questions: 1Answers: 0
    edited September 2019

    Hello Colin,
    I cannot add test link since is in the live site. Below is my code to export excel. Previously I have used datatable button version 1.5.2. which gave me an error then I found forum link . Based on the forum discussion I have changed my version to 1.5.4. But it is still not working
    and gives me the same error message. Please, let me know any idea about this issue even I used the version 1.5.4 .

    My code:

    (function ($) {
    
    
            $('#example').DataTable({
                pagingType: "full",
                paging: true,
                pageResize: true,
                scrollX: "100%",
                "aaSorting": [],
                dom: 'Bfrtip',
    lengthMenu: [
                [ 5, 10, 25, 50],
                [ '5 rows', '10 rows', '25 rows', '50 rows']
            ],          
        buttons: [{extend: 'excel',  
    title: 'Test' , 
          filename: 'Report',
           messageTop: 'Report generated',     
           customize: function( xlsx ) {
                    var sheet = xlsx.xl.worksheets['sheet1.xml'];   
                }
        },{
            extend:'pageLength'
        }],
    
                columnDefs: [
                    
        ]     });
        })(jQuery);
    

    Thanks for your help!

    Edited by Kevin:  Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 20,294Questions: 26Answers: 4,768

    You have a customize function but the function isn't doing anything. Try removing lines 19-21 from the above code snippet:

           customize: function( xlsx ) {
                    var sheet = xlsx.xl.worksheets['sheet1.xml'];  
                }
    

    If that doesn't help then we will need to see an example of the problem in order to help. The problem is specific to something in your environment. If you can't link to your page then please provide a test case that replicates an example of your data and the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.