Skip to content

Latest commit

 

History

History
131 lines (105 loc) · 2.87 KB

README.md

File metadata and controls

131 lines (105 loc) · 2.87 KB

tableToExcel

Light weight jQuery plugin for export table to excel file

Demos

Website and demo here:

http://tanvirpro.com/all_project/jQueryTableToExcel

Get started

Include jQuery and the plugin.

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="js/jquery.tableToExcel.js"></script>

Create Excel file form HTML table

Add plugin any table with CSS selector


Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Centro comercial Moctezuma Francisco Chang Mexico
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy

Apply the plugin to HTML table element on your HTML page and get excel file as like the table.

<script>

    $(selector).tblToExcel();
    
    //... or
    
    $('button').click(function () {
        $('table').tblToExcel();
    });
    
</script>

Results

Download xlx file

  

Settings

  • complete — Callback function trigged after the detection is completed

      	
    complete: function () {
    	// ...
    }
    

Custom File Name

If you want to change or custom file excel name, you need add parameter in function(parameter) at line 2 jquery.tableToExcel.js file.

  
    $.fn.tblToExcel = function (parameter) {
        ....

And then change this code


window.location.href = uri + base64(format(template, ctx));

with this :


var link = document.createElement("a");
link.download = parameter;
link.href = uri + base64(format(template, ctx));
link.click();

On your view just call the function with parameter as a file name, like a tableToExcel('my_excel_file.xls')