How to export html table to excel using jQuery Plugin

Hello Friends, I hope you are doing great, Today’s tutorial I am going to show you How to export html table to excel using jQuery Plugin, Jquery is a great tools for UI developer you can do many more this using jquery because there is huge plugin written in jquery to simplify development , So here we’ll learn about table2excel.js plugin written in javascript to export html table to excel quickly.
Let’s start the tutorial.

Fist of all include required libraries on page, Note: don’t forget to include jquery code library before table2excel.js because this is dependent on jquery.

<script src=""></script>
<script src="jquery.table2excel.js"></script>

Here is the sample html table, which we are going to export in excel.

<table class="tb2excel" border=1>
<tr><th>S.No.</th><th> Name</th><th> Email</th><th> Phone</th><tr>
<tr><td>1</td><td> Rohit Kumar</td><td></td><td> 1000000000</td><tr>
<tr><td>3</td><td> Manish Kumar</td><td></td><td> 1000000001</td><tr>
<tr><td>3</td><td> Mohit Kumar</td><td></td><td> 1000000011</td><tr>
<tr class="noExl"><td>..</td><td> ..</td><td> ..</td><td> ..</td><tr>
<h3><a href="#" class="download">Export Excel</a></h3>

In the above table there is class name tb2excel which we’ll use in table2excel function to export table by clicking on Export Excel link.

Finally add table2excel function on click event and make your code actionable.

$(function() {  
   $(".download").click(function() {  
				        exclude: ".noExl",
				        name: "Excel Document Name",
					filename: "file_name",
					fileext: ".xls",
					exclude_img: true,
					exclude_links: true,
					exclude_inputs: true

You can also exclude selected rows of the table by assigning a simple class to those rows which you don’t want to include in exported excel file, like in my case i assigned .noExl to last rows and pass this class to table2excel function as exclude properties.

See live demo and download sample source code.