有时候用table2excel导出excel的时候,希望不导出某一些列,除了可以用指定不导出类名之外,还可以这样
function ExportExcel(DivName, fileName, cols) {
$("" + DivName).table2excel({
exclude: ".noExl", //过滤位置的 css 类名
filename: "" + fileName + ".xls", //文件名称
name: "Excel Document Name.xls",
columns: cols,//指定不导出列 实例:columns: "0,1,2,3",下标从0开始,代表不导出第一列--第四列
exclude_img: true,
exclude_links: true,
exclude_inputs: true
});
}
table2excel.js 下载地址:
网址:https://pan.baidu.com/s/1mjNnZWc 密码:jr5l
/*table2excel.js */红色地方代表对原js修改的地方
/*
* jQuery table2excel - v1.1.1
* jQuery plugin to export an .xls file in browser from an HTML table
* https://github.com/rainabba/jquery-table2excel
*
* Made by rainabba
* Under MIT License
*/
!function (a, b, c, d)
{
function e(b, c)
{
this.element = b, this.settings = a.extend({}, k, c), this._defaults = k, this._name = j, this.init()
}
function f(a)
{
return a.filename ? a.filename : "table2excel"
}
function g(a)
{
var b = /(\s+alt\s*=\s*"([^"]*)"|\s+alt\s*=\s*'([^']*)')/i; return a.replace(/]*>/gi, function (a) { var c = b.exec(a); return null !== c && c.length >= 2 ? c[2] : "" })
}
function h(a)
{
return a.replace(/]*>|<\/a>/gi, "")
}
function i(a) {
var b = /(\s+value\s*=\s*"([^"]*)"|\s+value\s*=\s*'([^']*)')/i; return a.replace(/]*>|<\/input>/gi, function (a) { var c = b.exec(a); return null !== c && c.length >= 2 ? c[2] : "" })
}
var j = "table2excel",
k = {
exclude: ".noExl", name: "Table2Excel", filename: "table2excel", fileext: ".xls", exclude_img: !0, exclude_links: !0, exclude_inputs: !0
, columns: ""
};
e.prototype =
{
init: function () {
var b = this;
b.template = {
head: '\x3c!--[if gte mso 9]>
sheet: { head: "
table: { head: "