I want to add excel button in my data table for excel export

by farhantechno   Last Updated September 11, 2019 10:26 AM

I am trying to add excel button by

 buttons: [
        'excel'
    ]

But it is not working

My code:

   <div class="row">
      <div class="col-9">
         <div class="card">
            <div class="card-body">
               <h4 class="mt-0 mb-3 header-title">Subscribers</h4>
               <div class="row">
                  <div class="col-sm-12">
                     <div class="table-responsive">
                        <table id="all_sub" class="table">
                           <thead class="thead-light">
                              <tr>
                                 <th>Subscriber Name</th>
                                 <th>Course Name</th>
                              </tr>
                           </thead>
                         <tbody>
                         <?php foreach($allsubscriber as $allsub):?>
                           <tr>
                           <td><?php echo $allsub->user_firstname;?></td>
                           <td><?php echo $allsub->course_title;?></td>
                         </tr>
                       <?php endforeach; ?>              
                        </tbody>
                        </table>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
    </div>
<script>
  $(document).ready( function () {
    $('#all_sub').DataTable();
    buttons: [
        'excel'
    ]
});
</script>

In the above code, I am trying to add excel but it not working. I do not know where I am wrong in my code.



Related Questions




fire a modal and populate it (datatable)

Updated November 27, 2017 07:26 AM


Codeigniter and Datatable Search Filter Column problem

Updated September 21, 2018 22:26 PM