<div class="container"> <h1>Employee Data</h1> <p class="subtitle">Export your data to Excel with one click</p> <button class="export-btn" onclick="exportToExcel()"> 📊 Export to Excel </button> <div class="table-wrapper"> <table id="dataTable"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Department</th> <th>Position</th> <th>Salary</th> </tr> </thead> <tbody> <tr> <td>001</td> <td>John Smith</td> <td>Engineering</td> <td>Senior Developer</td> <td>$95,000</td> </tr> <tr> <td>002</td> <td>Sarah Johnson</td> <td>Marketing</td> <td>Marketing Manager</td> <td>$85,000</td> </tr> <tr> <td>003</td> <td>Michael Chen</td> <td>Engineering</td> <td>DevOps Engineer</td> <td>$90,000</td> </tr> <tr> <td>004</td> <td>Emily Davis</td> <td>Sales</td> <td>Sales Representative</td> <td>$70,000</td> </tr> <tr> <td>005</td> <td>Robert Wilson</td> <td>Finance</td> <td>Financial Analyst</td> <td>$80,000</td> </tr> </tbody> </table> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #E9D66B 0%, #d4c05a 100%); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; } .container { background: white; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1); padding: 40px; max-width: 900px; width: 100%; } h1 { color: #333; margin-bottom: 10px; font-size: 28px; } .subtitle { color: #666; margin-bottom: 30px; font-size: 14px; } .export-btn { background: linear-gradient(135deg, #E9D66B 0%, #d4c05a 100%); color: #333; border: none; padding: 12px 30px; border-radius: 6px; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; margin-bottom: 20px; } .export-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(233, 214, 107, 0.4); } .export-btn:active { transform: translateY(0); } .table-wrapper { overflow-x: auto; border-radius: 8px; border: 1px solid #e0e0e0; } table { width: 100%; border-collapse: collapse; background: white; } thead { background: linear-gradient(135deg, #E9D66B 0%, #d4c05a 100%); } th { padding: 15px; text-align: left; font-weight: 600; color: #333; border-bottom: 2px solid #d4c05a; } td { padding: 12px 15px; border-bottom: 1px solid #f0f0f0; color: #555; } tbody tr:hover { background-color: #fafafa; } tbody tr:last-child td { border-bottom: none; } @media (max-width: 600px) { .container { padding: 20px; } h1 { font-size: 24px; } table { font-size: 14px; } th, td { padding: 10px; } }
function exportToExcel() { const table = document.getElementById('dataTable'); const wb = XLSX.utils.table_to_book(table, {sheet: "Employee Data"}); XLSX.writeFile(wb, 'employee_data.xlsx'); }
Login to leave a comment
No comments yet. Be the first!
No comments yet. Be the first!