excelJS is a JavaScript framework for generating Excel *.xlsx files straight from your html tables.
-
Download file exceljs.compiled.min.js from dist directory: [Download exceljs.compiled.min.js here] (https://raw.githubusercontent.com/lemons-io/exceljs/master/dist/exceljs.compiled.min.js)
-
Add the following javascript include tags to your html file:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script type="text/javascript" src="exceljs.compiled.min.js"></script>
-
Add the following javascript to your html head section:
<script type="text/javascript"> $(document).ready(function (data) { $("#downloader").click(function(){ ExcelJS.createHtmlTableExcelFile('#myTable', 'excel-js-demo-export.xlsx'); }); }); </script>
-
Create a HTML table like this
<table id="myTable"> <tr><td>A1</td><td>B1</td><td>C1</td><td>D1</td></tr> <tr><td>A2</td><td>B2</td><td>C2</td><td>D2</td></tr> <tr><td>A3</td><td>B3</td><td>C3</td><td>D3</td></tr> </table>
-
Add a download link for your excel export file:
<a href="#" id="downloader">Download Excel!</a>
You can find the complete getting started example in the demo directory.