HEX
Server: Apache
System: Linux srv4.garantili.com.tr 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: ekspardev (1006)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/ekspardev/.trash/table.php
<? include 'header.php'; ?> 

                   <button onclick="exportTableToExcel('tblData', 'members-data')">Export Table Data To Excel File</button>  
             
               
                    <div class="input-group">
                                <button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                  Action
                                </button>
                                <div class="dropdown-menu" style="">
                                  <a class="dropdown-item" href="#">
                                    Action
                                  </a>
                                  <a class="dropdown-item" href="#">
                                    Another action
                                  </a>
                                </div> 
                              </div>          
                              
                <div id="table-default" class="table-responsive"> 
                  <table class="table"  id="tblData">
                    <thead>
                      <tr>
                        <th><button class="table-sort" data-sort="td1">Name</button></th>
                        <th><button class="table-sort" data-sort="td2">City</button></th>
                        <th><button class="table-sort" data-sort="td3">Type</button></th>
                        <th><button class="table-sort" data-sort="td4">Score</button></th>
                        <th><button class="table-sort" data-sort="td5">Date</button></th>
                        <th><button class="table-sort" data-sort="td6">Quantity</button></th>
                        <th><button class="table-sort" data-sort="td7">Progress</button></th>
                      </tr>
                    </thead>
                    <tbody class="table-tbody">
                        
                    <? for($i=1;$i<=15;$i++){?>
                      <tr>
                        <td class="td1">Steel Vengeance<?=$i?></td>
                        <td class="td2">Cedar Point, United States<?=$i?></td>
                        <td class="td3">RMC Hybrid<?=$i?></td>
                        <td class="td4">100,0%</td>
                        <td class="td5" data-date="1628071164">August 04, 2021</td>
                        <td class="td6">74<?=$i?></td>
                        <td class="td7" data-progress="<?=$i?>">
                          <div class="row align-items-center">
                            <div class="col-12 col-lg-auto"><?=$i?></div>
                            <div class="col">
                              <div class="progress" style="width: 5rem">
                                <div class="progress-bar" style="width: 30%" role="progressbar" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" aria-label="30% Complete">
                                  <span class="visually-hidden">30% Complete</span>
                                </div>
                              </div>
                            </div>
                          </div>
                        </td>
                      </tr>
                     <?}?>
                    </tbody>
                  </table>
                </div>
             
             
             
<script>
            function exportTableToExcel(tableID, filename = ''){
    var downloadLink;
    var dataType = 'application/vnd.ms-excel';
    var tableSelect = document.getElementById(tableID);
    var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');
    
    // Specify file name
    filename = filename?filename+'.xls':'excel_data.xls';
    
    // Create download link element
    downloadLink = document.createElement("a");
    
    document.body.appendChild(downloadLink);
    
    if(navigator.msSaveOrOpenBlob){
        var blob = new Blob(['\ufeff', tableHTML], {
            type: dataType
        });
        navigator.msSaveOrOpenBlob( blob, filename);
    }else{
        // Create a link to the file
        downloadLink.href = 'data:' + dataType + ', ' + tableHTML;
    
        // Setting the file name
        downloadLink.download = filename;
        
        //triggering the function
        downloadLink.click();
    }
}
        </script>
<? include 'footer.php'; ?>