<table id="example4" class="table table-striped table-bordered dt-responsive nowrap" style="width:100%">
        <thead>
            <tr>
            <th>Bill.No</th>
           <th>Mrd. No</th>
           <th>Name</th>
           <th>Bill Date</th>
           <th>Paid Amount</th>
           <th>Payment Mode</th>
            </tr>
        </thead>
        <tbody>
        @php $i=1;@endphp
        @foreach($data as $result)
        <tr>
        <td>{{$result->BillNo}}</td>
            <td>{{$result->MrdNo}}</td>
            <td>{{$result->PatientName}}</td>
            <td>{{date("d/m/Y", strtotime(str_replace('-', '/',$result->BillDate)))}}</td>          
            <td>{{$result->PaidAmt}}</td>
            <td>{{$result->PayMode}}</td>
        </tr>
        @endforeach

        <tr>
           
             <td></td>
             <td></td>
             <td></td>
             <th>Total </th>
             <th>{{number_format($sum,2)}}</th>
             <td></td>
             
          
            
         
           
            
        </tr>
        </tbody>
    </table>
    <script type="text/javascript">
$(document).ready(function() {
    $('#example4').DataTable({
        "scrollX": true,
        dom: 'Bfrtip',
        "pageLength": 200,
        "order": [[ 0, "desc" ]],
        buttons: [

            'excelHtml5'

        ]
    });
});
</script>