/*
* 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
*
* 江鸿宾(QQ:33080907)修改过
* 最后修改日期:2019.02.26
*/
(function ($, window, document) {
var pluginName = 'table2excel',
defaults = {
exclude: '.no-xls',
name: 'Table2Excel',
filename: 'table2excel',
exclude_img: true,
exclude_links: true,
exclude_inputs: true
}
// The actual plugin constructor
function Plugin(element, filename) {
this.element = element
// jQuery has an extend method which merges the contents of two or
// more objects, storing the result in the first object. The first object
// is generally empty as we don't want to alter the default options for
// future instances of the plugin
//
this.settings = $.extend({}, defaults, { filename: filename })
this._defaults = defaults
this._name = pluginName
this.init()
}
Plugin.prototype = {
init: function () {
var e = this
var utf8Heading = ''
e.template = {
head: '' + utf8Heading + '
',
table: {
head: '
',
tail: '
'
},
foot: ''
}
e.tableRows = []
// get contents of table except for exclude
$(e.element).each(function (i, o) {
var tempRows = ''
$(o).find('tr').not(e.settings.exclude).filter(':visible').each(function (i, p) {
tempRows += '
'
$(p).find('td,th').not(e.settings.exclude).filter(':visible').each(function (i, q) { // p did not exist, I corrected
var rc = {
rows: $(this).attr('rowspan'),
cols: $(this).attr('colspan'),
flag: $(q).find(e.settings.exclude),
style: $(this).attr('style')
}
if (rc.flag.length > 0) {
tempRows += '