Export to Excel from html data using PHP

I have displayed a table of data from MYSQL DB. I have a button to export to excel. When I click on the button the excel file is created but it is empty or sometimes nothing is happening. What could be wrong here?

I have code like below:

view.php:

                <div id="div_users">
                        <table class="table table-striped">
                            <thead class="thead-dark">
                                <tr>
                                <th class="mn_th01">#</th>
                                <th class="mn_th02">Date</th>
                                <th class="mn_th03">Name</th>
                                <th class="mn_th04">Place</th>
                                <th class="mn_th05">Notes</th>
                                <th class="mn_th06">Sales Exec.</th>
                                <th class="mn_th07">Image</th>
                                </tr>
                            </thead>
                                <tbody>
                                <?php

                                    date_default_timezone_set('Asia/Kolkata');
                                    $date = date('d/m/Y', time());
                                    echo $date . "\n";                                                                      

                                    $count=1;

                                    $query = "SELECT * FROM ua_myadd_details WHERE STR_TO_DATE(notes_date,'%d/%m/%y') = STR_TO_DATE('$date', '%d/%m/%y') ORDER BY M.id DESC";

                                    $result = mysqli_query($bd,$query);
                                    if(mysqli_num_rows($result) > 0)
                                    {
                                        while($row = mysqli_fetch_assoc($result)) {

                                    ?>
                                    <tr>
                                            <td><?php echo $count; ?></td>
                                            <td><?php echo $row["notes_date"]; ?></td>
                                            <td><?php echo $row["firstname"] . " " . $row["lastname"]; ?></td>
                                            <td><?php echo $row["city"]; ?></td>
                                            <td><?php echo $row["notes"]; ?></td>
                                            <td><?php echo $row["executive"]; ?></td>
                                        </tr>
                                        <?php $count++; } 

                                    }
                                    else
                                    {?>
                                    <tr>
                                        <td colspan="7">
                                            <?php echo "No Data Found"; ?>
                                        </td>
                                    </tr>
                                    <?php } ?>
                                </tbody>
                        </table>
                </div>

I have a button like this:

<div class="col-md-3">

                           <button name="create_excel" id="create_excel" class="btn btn-success btn-block"><i class="fas fa-arrow-alt-circle-down"></i> Export to Excel</button>

                        </div>

In the script I have written:

  <script>  
     $(document).ready(function(){  

        $('#create_excel').click(function(){  
        var excel_data = $('#div_users').html();  
        var page = "export.php?data=" + excel_data;  
        window.location = page;  
     });  
  });

 </script>

export.php:

  <?php
     header('Content-Type: application/vnd.ms-excel');  
     header('Content-disposition: attachment; filename='.rand().'.xls');  
     echo $_GET["data"];
  ?>