JSFiddle - React, Tailwind, and code Playground
by Michael Prosser
HTML
<script src="https://unpkg.com/[email protected]/dist/xlsx.full.min.js"></script>
<table id="exportTable" border="0" cellspacing="0" cellpadding="5" style="font-family:helvetica;font-size:15px;"><tbody><caption>agGEAR Equipment & PPE</caption><tr> <th>Facility</th> <th>Type</th> <th>Name</th> <th>Model</th> <th>Serial Number</th> <th>Work Area</th> <th>Description</th> <th>Manufacturer</th> <th>System Designator</th> <th>In Service</th> <th>Created</th> <th colspan="8"></th> </tr><tr> <td>Mattoon</td> <td>2000T Series System</td> <td></td> <td>Fgyff</td> <td>Ggrfgh</td> <td>Emergency Lighting</td> <td></td> <td></td> <td>Receiving System</td> <td>YES</td> <td>2023-04-12 23:21:54</td> <td colspan="8"></td> </tr><tr> <td>Mattoon</td> <td>Access Control System</td> <td></td> <td>BC1</td> <td>2142142142</td> <td>Atmospheric Testing Monitor</td> <td></td> <td></td> <td>Receiving</td> <td>YES</td> <td>2023-04-05 11:13:49</td> <td colspan="8"></td> </tr><tr> <td>Mattoon</td> <td>Access Control System</td> <td></td> <td>BC1</td> <td>2142142142</td> <td>Atmospheric Testing Monitor</td> <td></td> <td></td> <td>Receiving</td> <td>YES</td> <td>2023-04-06 10:05:16</td> <td colspan="8"></td> </tr><tr> <td>Mattoon</td> <td>Access Control System</td> <td></td> <td>Model A</td> <td>123456</td> <td>Atmospheric Testing Monitor</td> <td></td> <td></td> <td>Receiving</td> <td>YES</td> <td>2023-04-06 15:45:40</td> <td colspan="8"></td> </tr><tr> <td>Mattoon</td> <td>14INCH Curve Section & Extensions</td> <td></td> <td>wqewqewqe</td> <td>qwewqewqewqewqe</td> <td>Atmospheric Testing Monitor</td> <td></td> <td></td> <td>Scale</td> <td>YES</td> <td>2023-04-12 00:09:47</td> <td colspan="8"></td> </tr><tr> <td>Mattoon</td> ...
JavaScript
function ExportToExcel(type,fn)
{
var elt = document.getElementById('exportTable');
var wb = XLSX.utils.table_to_book(elt, {sheet:"Sheet JS"});
XLSX.writeFile(wb, fn || ('Sample Export.' + (type || 'xlsx')));
}
ExportToExcel('xlsx');