Export HTML table to Excel - using jQuery or Java

前端 未结 9 1689
慢半拍i
慢半拍i 2020-12-06 07:13

I\'ve a HTML table on my JSP page, that I want to be exported to Excel on a button click.

What would be the best way of going about this?

(For ex., how would

9条回答
  •  醉梦人生
    2020-12-06 07:28

    I have been using the jQuery plugin table2excel. It works very well and no serverside coding is needed.

    Using it is easy. Simply include jQuery

    
    

    Now include the table2excel script (Remember to change the src destination to match yours)

    
    

    Now simply call the script on the table you want exportet.

    $("#yourHtmTable").table2excel({
        exclude: ".excludeThisClass",
        name: "Worksheet Name",
        filename: "SomeFile" //do not include extension
    });
    

    It's also easy to attach to a button like so:

    $("button").click(function(){
        $("#table2excel").table2excel({
        // exclude CSS class
        exclude: ".noExl",
        name: "Excel Document Name"
        }); 
    });
    

    All examples are taken directly from the authors github page and from jqueryscript.net

提交回复
热议问题