In this article I will explain with an example, how to use table2excel jQuery plugin in HTML.
This article will explain how to convert (export) HTML Table to Excel file with the help of the jQuery table2excel plugin.
HTML Markup
The following HTML Markup consists of an HTML Table and a Button.
Inside the jQuery document ready event handler, the Export Button has been assigned a jQuery Click event handler.
When the Export Button is clicked, the jQuery table2excel plugin is applied to the HTML Table and it is converted (exported) to Excel file.
The jQuery table2excel plugin accepts filename parameter which sets the name of the Excel file.
<table id="tblCustomers" cellspacing="0" cellpadding="0">
        <th>Customer Id</th>
        <td>John Hammond</td>
        <td>United States</td>
        <td>Mudassar Khan</td>
        <td>Suzanne Mathews</td>
        <td>Robert Schidner</td>
<br />
<input type="button" id="btnExport" value="Export" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="table2excel.js"></script>
<script type="text/javascript">
    $(function () {
        $("#btnExport").click(function () {
                filename: "Table.xls"
The HTML Table
Using table2excel jQuery plugin in HTML
Excel file being downloaded when Export Button is clicked
Using table2excel jQuery plugin in HTML
The generated Excel file
Using table2excel jQuery plugin in HTML
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.