excel export option not working properly

excel export option not working properly

soumicksoumick Posts: 4Questions: 2Answers: 0
edited June 2016 in Free community support

Hi,
In datatables I have included the excel export option...

  $('#example').dataTable({
 dom: 'lBfrtip',
            buttons: [
                'excel'
            ]
         
       
        });

When the button is clicked it is saving an excel sheet but when I am trying to open the excel sheet it is giving an error that there is some problem with the content.
My datatables contain the expand/collapse option for rows.
Please provide a solution or alternative for this

Answers

  • Tom (DataTables)Tom (DataTables) Posts: 139Questions: 0Answers: 26
    edited April 2016

    Hi, thanks for your post.

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    It sounds like the .XLSX data isn't valid. Which program are you trying to open the file with?

    Thanks,

    Tom

  • soumicksoumick Posts: 4Questions: 2Answers: 0

    Hi,
    I have a datatable which is showing the values from a database and I want to export the data to excel. The excel button saves the excel sheet but when I am trying to open it error is showing as mentioned above and it is asking if I want to restore it. If I am restoring it only blank excel sheet is shown.

  • Tom (DataTables)Tom (DataTables) Posts: 139Questions: 0Answers: 26

    If you could post a test case that would be great. I need to be able to reproduce the error so I can help you.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks

    Tom

  • soumicksoumick Posts: 4Questions: 2Answers: 0

    Hi,
    I figured out why it was giving a problem in the excel sheet because i had used @Html.Raw(HttpUtility.HtmlEncode(row[2]).Replace("\n", "<br />")) in some 'td' of the datatable to maintain the formatting of the content entered by the user.

    Can you please provide an alternative for maintaining the formatting without using Html.Raw?

  • Tom (DataTables)Tom (DataTables) Posts: 139Questions: 0Answers: 26

    Hi Soumick

    Would you be able to link me the raw HTML output (ie view source). You can save it in pastebin.com and give me a link, then I'll be able to run the example and see why it's not working.

    Thanks

    Tom

This discussion has been closed.