php – Datatable remove specific div from row during export to csv-ThrowExceptions

Exception or error:

Please check below table for what I want in export to csv.
I have used Datatable. I want to remove / hide removeit class and its content during export to csv.

        <th>First Name</th>
        <td>John doe <div class="removeit">Remove this content</div></td>
How to solve:
Here, I found solution by myself.    
buttons: [ 
                    extend: 'csvHtml5', 
                    text: 'Export to Csv',
                    exportOptions: {
                      format: {
                            body: function ( data, row, column, node, type ) {
                                   var lines = data.split('<div');
                                  var count_d = 0;
                                   jQuery.each(lines, function() {
                                            data = this;
                                   data = data;
                              return data; 


Leave a Reply

Your email address will not be published. Required fields are marked *