diff --git a/Bootstrap.Admin/Views/Admin/Exceptions.cshtml b/Bootstrap.Admin/Views/Admin/Exceptions.cshtml index 4963be52..63d00cda 100644 --- a/Bootstrap.Admin/Views/Admin/Exceptions.cshtml +++ b/Bootstrap.Admin/Views/Admin/Exceptions.cshtml @@ -16,12 +16,16 @@ @section javascript { + + + + diff --git a/Bootstrap.Admin/Views/Admin/Logs.cshtml b/Bootstrap.Admin/Views/Admin/Logs.cshtml index ca009ff5..78c64fb6 100644 --- a/Bootstrap.Admin/Views/Admin/Logs.cshtml +++ b/Bootstrap.Admin/Views/Admin/Logs.cshtml @@ -15,12 +15,16 @@ @section javascript { + + + + diff --git a/Bootstrap.Admin/Views/Shared/_Default.cshtml b/Bootstrap.Admin/Views/Shared/_Default.cshtml index 48412eb0..7899d96b 100644 --- a/Bootstrap.Admin/Views/Shared/_Default.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Default.cshtml @@ -13,13 +13,17 @@ @section javascript { + + + + diff --git a/Bootstrap.Admin/libman.json b/Bootstrap.Admin/libman.json index 94fd54dc..8eca1d02 100644 --- a/Bootstrap.Admin/libman.json +++ b/Bootstrap.Admin/libman.json @@ -55,7 +55,9 @@ "locale/bootstrap-table-zh-CN.min.js", "bootstrap-table.css", "bootstrap-table.js", - "bootstrap-table.min.css" + "bootstrap-table.min.css", + "extensions/export/bootstrap-table-export.js", + "extensions/export/bootstrap-table-export.min.js" ] }, { @@ -182,6 +184,15 @@ "jquery.nestable.js", "jquery.nestable.min.css" ] + }, + { + "provider": "unpkg", + "library": "tableexport.jquery.plugin@1.10.1", + "destination": "wwwroot/lib/tablexport/", + "files": [ + "tableExport.js", + "tableExport.min.js" + ] } ] } \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/js/dicts.js b/Bootstrap.Admin/wwwroot/js/dicts.js index 97253d1d..4bb6d8d9 100644 --- a/Bootstrap.Admin/wwwroot/js/dicts.js +++ b/Bootstrap.Admin/wwwroot/js/dicts.js @@ -18,7 +18,11 @@ { title: "字典名称", field: "Name", sortable: true }, { title: "字典代码", field: "Code", sortable: true }, { title: "字典分类", field: "Define", sortable: true, formatter: function (value) { return value === 0 ? "系统使用" : "自定义"; } } - ] + ], + exportOptions: { + fileName: "数据字典", + ignoreColumn: [0, 1] + } } }); diff --git a/Bootstrap.Admin/wwwroot/js/exceptions.js b/Bootstrap.Admin/wwwroot/js/exceptions.js index 2f551520..0dd3109f 100644 --- a/Bootstrap.Admin/wwwroot/js/exceptions.js +++ b/Bootstrap.Admin/wwwroot/js/exceptions.js @@ -18,7 +18,10 @@ { title: "异常类型", field: "ExceptionType", sortable: false }, { title: "异常描述", field: "Message", sortable: false }, { title: "记录时间", field: "LogTime", sortable: true } - ] + ], + exportOptions: { + fileName: "程序异常数据" + } }); $('#btn_view').on('click', function (row) { diff --git a/Bootstrap.Admin/wwwroot/js/groups.js b/Bootstrap.Admin/wwwroot/js/groups.js index 3be3d97e..f05bdff8 100644 --- a/Bootstrap.Admin/wwwroot/js/groups.js +++ b/Bootstrap.Admin/wwwroot/js/groups.js @@ -69,7 +69,11 @@ columns: [ { title: "部门名称", field: "GroupName", sortable: true }, { title: "部门描述", field: "Description", sortable: false } - ] + ], + exportOptions: { + fileName: "部门数据", + ignoreColumn: [0, 1] + } } }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/js/logs.js b/Bootstrap.Admin/wwwroot/js/logs.js index eee89034..5b3244dd 100644 --- a/Bootstrap.Admin/wwwroot/js/logs.js +++ b/Bootstrap.Admin/wwwroot/js/logs.js @@ -15,6 +15,9 @@ { title: "浏览器", field: "Browser", sortable: true }, { title: "操作系统", field: "OS", sortable: true }, { title: "Url", field: "RequestUrl", sortable: true } - ] + ], + exportOptions: { + fileName: "操作日志数据" + } }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/js/menus.js b/Bootstrap.Admin/wwwroot/js/menus.js index 2679e313..dfe4db5f 100644 --- a/Bootstrap.Admin/wwwroot/js/menus.js +++ b/Bootstrap.Admin/wwwroot/js/menus.js @@ -74,6 +74,10 @@ smartTable: { sortName: 'Order', queryParams: function (params) { return $.extend(params, { parentName: $('#txt_parent_menus_name').val(), name: $("#txt_menus_name").val(), category: $('#sel_menus_category').val(), isresource: $('#sel_menus_res').val() }); }, //传递参数(*) + exportOptions: { + fileName: "菜单数据", + ignoreColumn: [0, 1] + }, columns: [ { title: "父级菜单", field: "ParentName", sortable: true, formatter: function (value, row, index) { diff --git a/Bootstrap.Admin/wwwroot/js/roles.js b/Bootstrap.Admin/wwwroot/js/roles.js index 02f22998..1016292e 100644 --- a/Bootstrap.Admin/wwwroot/js/roles.js +++ b/Bootstrap.Admin/wwwroot/js/roles.js @@ -126,7 +126,11 @@ columns: [ { title: "角色名称", field: "RoleName", sortable: true }, { title: "角色描述", field: "Description", sortable: false } - ] + ], + exportOptions: { + fileName: "角色数据", + ignoreColumn: [0, 1] + } } }); diff --git a/Bootstrap.Admin/wwwroot/js/users.js b/Bootstrap.Admin/wwwroot/js/users.js index 517795ad..b96f2ae9 100644 --- a/Bootstrap.Admin/wwwroot/js/users.js +++ b/Bootstrap.Admin/wwwroot/js/users.js @@ -117,7 +117,11 @@ } } } - ] + ], + exportOptions: { + fileName: "用户数据", + ignoreColumn: [0, 1] + } } }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/lib/bootstrap-table/extensions/export/bootstrap-table-export.js b/Bootstrap.Admin/wwwroot/lib/bootstrap-table/extensions/export/bootstrap-table-export.js new file mode 100644 index 00000000..b1163f4d --- /dev/null +++ b/Bootstrap.Admin/wwwroot/lib/bootstrap-table/extensions/export/bootstrap-table-export.js @@ -0,0 +1,179 @@ +/** + * @author zhixin wen + * extensions: https://github.com/kayalshri/tableExport.jquery.plugin + */ + +(function ($) { + 'use strict'; + var sprintf = $.fn.bootstrapTable.utils.sprintf; + + var TYPE_NAME = { + json: 'JSON', + xml: 'XML', + png: 'PNG', + csv: 'CSV', + txt: 'TXT', + sql: 'SQL', + doc: 'MS-Word', + excel: 'MS-Excel', + xlsx: 'MS-Excel (OpenXML)', + powerpoint: 'MS-Powerpoint', + pdf: 'PDF' + }; + + $.extend($.fn.bootstrapTable.defaults, { + showExport: false, + exportDataType: 'basic', // basic, all, selected + // 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf' + exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'], + exportOptions: {} + }); + + $.extend($.fn.bootstrapTable.defaults.icons, { + export: 'glyphicon-export icon-share' + }); + + $.extend($.fn.bootstrapTable.locales, { + formatExport: function () { + return 'Export data'; + } + }); + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); + + var BootstrapTable = $.fn.bootstrapTable.Constructor, + _initToolbar = BootstrapTable.prototype.initToolbar; + + BootstrapTable.prototype.initToolbar = function () { + this.showToolbar = this.showToolbar || this.options.showExport; + + _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); + + if (this.options.showExport) { + var that = this, + $btnGroup = this.$toolbar.find('>.btn-group'), + $export = $btnGroup.find('div.export'); + + if (!$export.length) { + $export = $([ + '
', + '', + '', + '
'].join('')).appendTo($btnGroup); + + var $menu = $export.find('.dropdown-menu'), + exportTypes = this.options.exportTypes; + + if (typeof this.options.exportTypes === 'string') { + var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(','); + + exportTypes = []; + $.each(types, function (i, value) { + exportTypes.push(value.slice(1, -1)); + }); + } + $.each(exportTypes, function (i, type) { + if (TYPE_NAME.hasOwnProperty(type)) { + $menu.append(['
  • ', + '', + TYPE_NAME[type], + '', + '
  • '].join('')); + } + }); + + $menu.find('li').click(function () { + var type = $(this).data('type'), + doExport = function () { + + if (!!that.options.exportFooter) { + var data = that.getData(); + var $footerRow = that.$tableFooter.find("tr").first(); + + var footerData = { }; + var footerHtml = []; + + $.each($footerRow.children(), function (index, footerCell) { + + var footerCellHtml = $(footerCell).children(".th-inner").first().html(); + footerData[that.columns[index].field] = footerCellHtml == ' ' ? null : footerCellHtml; + + // grab footer cell text into cell index-based array + footerHtml.push(footerCellHtml); + }); + + that.append(footerData); + + var $lastTableRow = that.$body.children().last(); + + $.each($lastTableRow.children(), function (index, lastTableRowCell) { + + $(lastTableRowCell).html(footerHtml[index]); + }); + } + + that.$el.tableExport($.extend({}, that.options.exportOptions, { + type: type, + escape: false + })); + + if (!!that.options.exportFooter) { + that.load(data); + } + }; + + var stateField = that.header.stateField; + + if (that.options.exportDataType === 'all' && that.options.pagination) { + that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () { + if (stateField) { + that.hideColumn(stateField); + } + doExport(); + that.togglePagination(); + }); + that.togglePagination(); + } else if (that.options.exportDataType === 'selected') { + var data = that.getData(), + selectedData = that.getSelections(); + if (!selectedData.length) { + return; + } + + if (that.options.sidePagination === 'server') { + var dataServer = {total: that.options.totalRows}; + dataServer[that.options.dataField] = data; + data = dataServer; + var selectedDataServer = {total: selectedData.length}; + selectedDataServer[that.options.dataField] = selectedData; + selectedData = selectedDataServer; + } + + that.load(selectedData); + if (stateField) { + that.hideColumn(stateField); + } + doExport(); + that.load(data); + } else { + if (stateField) { + that.hideColumn(stateField); + } + doExport(); + } + if (stateField) { + that.showColumn(stateField); + } + }); + } + } + }; +})(jQuery); diff --git a/Bootstrap.Admin/wwwroot/lib/bootstrap-table/extensions/export/bootstrap-table-export.min.js b/Bootstrap.Admin/wwwroot/lib/bootstrap-table/extensions/export/bootstrap-table-export.min.js new file mode 100644 index 00000000..3036646d --- /dev/null +++ b/Bootstrap.Admin/wwwroot/lib/bootstrap-table/extensions/export/bootstrap-table-export.min.js @@ -0,0 +1,7 @@ +/* +* bootstrap-table - v1.12.1 - 2018-03-12 +* https://github.com/wenzhixin/bootstrap-table +* Copyright (c) 2018 zhixin wen +* Licensed MIT License +*/ +!function(a){"use strict";var b=a.fn.bootstrapTable.utils.sprintf,c={json:"JSON",xml:"XML",png:"PNG",csv:"CSV",txt:"TXT",sql:"SQL",doc:"MS-Word",excel:"MS-Excel",xlsx:"MS-Excel (OpenXML)",powerpoint:"MS-Powerpoint",pdf:"PDF"};a.extend(a.fn.bootstrapTable.defaults,{showExport:!1,exportDataType:"basic",exportTypes:["json","xml","csv","txt","sql","excel"],exportOptions:{}}),a.extend(a.fn.bootstrapTable.defaults.icons,{"export":"glyphicon-export icon-share"}),a.extend(a.fn.bootstrapTable.locales,{formatExport:function(){return"Export data"}}),a.extend(a.fn.bootstrapTable.defaults,a.fn.bootstrapTable.locales);var d=a.fn.bootstrapTable.Constructor,e=d.prototype.initToolbar;d.prototype.initToolbar=function(){if(this.showToolbar=this.showToolbar||this.options.showExport,e.apply(this,Array.prototype.slice.apply(arguments)),this.options.showExport){var d=this,f=this.$toolbar.find(">.btn-group"),g=f.find("div.export");if(!g.length){g=a(['
    ','",'","
    "].join("")).appendTo(f);var h=g.find(".dropdown-menu"),i=this.options.exportTypes;if("string"==typeof this.options.exportTypes){var j=this.options.exportTypes.slice(1,-1).replace(/ /g,"").split(",");i=[],a.each(j,function(a,b){i.push(b.slice(1,-1))})}a.each(i,function(a,b){c.hasOwnProperty(b)&&h.append(['
  • ','',c[b],"","
  • "].join(""))}),h.find("li").click(function(){var b=a(this).data("type"),c=function(){if(d.options.exportFooter){var c=d.getData(),e=d.$tableFooter.find("tr").first(),f={},g=[];a.each(e.children(),function(b,c){var e=a(c).children(".th-inner").first().html();f[d.columns[b].field]=" "==e?null:e,g.push(e)}),d.append(f);var h=d.$body.children().last();a.each(h.children(),function(b,c){a(c).html(g[b])})}d.$el.tableExport(a.extend({},d.options.exportOptions,{type:b,escape:!1})),d.options.exportFooter&&d.load(c)},e=d.header.stateField;if("all"===d.options.exportDataType&&d.options.pagination)d.$el.one("server"===d.options.sidePagination?"post-body.bs.table":"page-change.bs.table",function(){e&&d.hideColumn(e),c(),d.togglePagination()}),d.togglePagination();else if("selected"===d.options.exportDataType){var f=d.getData(),g=d.getSelections();if(!g.length)return;if("server"===d.options.sidePagination){var h={total:d.options.totalRows};h[d.options.dataField]=f,f=h;var i={total:g.length};i[d.options.dataField]=g,g=i}d.load(g),e&&d.hideColumn(e),c(),d.load(f)}else e&&d.hideColumn(e),c();e&&d.showColumn(e)})}}}}(jQuery); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js b/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js index 2bb1a66a..6b33d3e2 100644 --- a/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js +++ b/Bootstrap.Admin/wwwroot/lib/longbow/longbow.common.js @@ -283,6 +283,7 @@ pageNumber: 1, //初始化加载第一页,默认第一页 pageSize: 20, //每页的记录行数(*) pageList: [20, 40, 80, 120], //可供选择的每页的行数(*) + showExport: true, showColumns: true, //是否显示所有的列 showRefresh: true, //是否显示刷新按钮 showToggle: true, //是否显示详细视图和列表视图的切换按钮 @@ -413,7 +414,12 @@ $(function () { // fix bug bootstrap-table 1.12.1 showToggle - if ($.fn.bootstrapTable) $.fn.bootstrapTable.Constructor.DEFAULTS.icons.toggle = $.fn.bootstrapTable.Constructor.DEFAULTS.icons.toggleOff; + if ($.fn.bootstrapTable) { + $.extend($.fn.bootstrapTable.defaults.icons, { + toggle: 'fa-toggle-off', + export: 'fa-download' + }); + } if (window.NProgress) { $(document).ajaxStart(function () { diff --git a/Bootstrap.Admin/wwwroot/lib/tablexport/tableExport.js b/Bootstrap.Admin/wwwroot/lib/tablexport/tableExport.js new file mode 100644 index 00000000..5dd0fb3c --- /dev/null +++ b/Bootstrap.Admin/wwwroot/lib/tablexport/tableExport.js @@ -0,0 +1,2367 @@ +/** + * @preserve tableExport.jquery.plugin + * + * Version 1.10.1 + * + * Copyright (c) 2015-2018 hhurz, https://github.com/hhurz + * + * Original Work Copyright (c) 2014 Giri Raj + * + * Licensed under the MIT License + **/ + +'use strict'; + +(function ($) { + $.fn.tableExport = function (options) { + var defaults = { + csvEnclosure: '"', + csvSeparator: ',', + csvUseBOM: true, + displayTableName: false, + escape: false, + exportHiddenCells: false, // true = speed up export of large tables with hidden cells (hidden cells will be exported !) + fileName: 'tableExport', + htmlContent: false, + ignoreColumn: [], + ignoreRow: [], + jsonScope: 'all', // head, data, all + jspdf: { // jsPDF / jsPDF-AutoTable related options + orientation: 'p', + unit: 'pt', + format: 'a4', // One of jsPDF page formats or 'bestfit' for autmatic paper format selection + margins: {left: 20, right: 10, top: 10, bottom: 10}, + onDocCreated: null, + autotable: { + styles: { + cellPadding: 2, + rowHeight: 12, + fontSize: 8, + fillColor: 255, // Color value or 'inherit' to use css background-color from html table + textColor: 50, // Color value or 'inherit' to use css color from html table + fontStyle: 'normal', // normal, bold, italic, bolditalic or 'inherit' to use css font-weight and fonst-style from html table + overflow: 'ellipsize', // visible, hidden, ellipsize or linebreak + halign: 'inherit', // left, center, right or 'inherit' to use css horizontal cell alignment from html table + valign: 'middle' // top, middle, bottom + }, + headerStyles: { + fillColor: [52, 73, 94], + textColor: 255, + fontStyle: 'bold', + halign: 'inherit', // left, center, right or 'inherit' to use css horizontal header cell alignment from html table + valign: 'middle' // top, middle, bottom + }, + alternateRowStyles: { + fillColor: 245 + }, + tableExport: { + doc: null, // jsPDF doc object. If set, an already created doc will be used to export to + onAfterAutotable: null, + onBeforeAutotable: null, + onAutotableText: null, + onTable: null, + outputImages: true + } + } + }, + mso: { // MS Excel and MS Word related options + fileFormat: 'xlshtml', // xlshtml = Excel 2000 html format + // xmlss = XML Spreadsheet 2003 file format (XMLSS) + // xlsx = Excel 2007 Office Open XML format + onMsoNumberFormat: null, // Excel 2000 html format only. See readme.md for more information about msonumberformat + pageFormat: 'a4', // Page format used for page orientation + pageOrientation: 'portrait', // portrait, landscape (xlshtml format only) + rtl: false, // true = Set worksheet option 'DisplayRightToLeft' + styles: [], // E.g. ['border-bottom', 'border-top', 'border-left', 'border-right'] + worksheetName: '' + }, + numbers: { + html: { + decimalMark: '.', + thousandsSeparator: ',' + }, + output: { // Use 'output: false' to keep number format in exported output + decimalMark: '.', + thousandsSeparator: ',' + } + }, + onCellData: null, + onCellHtmlData: null, + onIgnoreRow: null, // onIgnoreRow($tr, rowIndex): function should return true to not export a row + outputMode: 'file', // 'file', 'string', 'base64' or 'window' (experimental) + pdfmake: { + enabled: false, // true: use pdfmake instead of jspdf and jspdf-autotable (experimental) + docDefinition: { + pageOrientation: 'portrait', // 'portrait' or 'landscape' + defaultStyle: { + font: 'Roboto' // Default is 'Roboto', for arabic font set this option to 'Mirza' and include mirza_fonts.js + } + }, + fonts: {} + }, + preserve: { + leadingWS: false, // preserve leading white spaces + trailingWS: false // preserve trailing white spaces + }, + preventInjection: true, + tbodySelector: 'tr', + tfootSelector: 'tr', // Set empty ('') to prevent export of tfoot rows + theadSelector: 'tr', + tableName: 'Table', + type: 'csv' // 'csv', 'tsv', 'txt', 'sql', 'json', 'xml', 'excel', 'doc', 'png' or 'pdf' + }; + + var pageFormats = { // Size in pt of various paper formats. Adopted from jsPDF. + 'a0': [2383.94, 3370.39], 'a1': [1683.78, 2383.94], 'a2': [1190.55, 1683.78], + 'a3': [841.89, 1190.55], 'a4': [595.28, 841.89], 'a5': [419.53, 595.28], + 'a6': [297.64, 419.53], 'a7': [209.76, 297.64], 'a8': [147.40, 209.76], + 'a9': [104.88, 147.40], 'a10': [73.70, 104.88], + 'b0': [2834.65, 4008.19], 'b1': [2004.09, 2834.65], 'b2': [1417.32, 2004.09], + 'b3': [1000.63, 1417.32], 'b4': [708.66, 1000.63], 'b5': [498.90, 708.66], + 'b6': [354.33, 498.90], 'b7': [249.45, 354.33], 'b8': [175.75, 249.45], + 'b9': [124.72, 175.75], 'b10': [87.87, 124.72], + 'c0': [2599.37, 3676.54], + 'c1': [1836.85, 2599.37], 'c2': [1298.27, 1836.85], 'c3': [918.43, 1298.27], + 'c4': [649.13, 918.43], 'c5': [459.21, 649.13], 'c6': [323.15, 459.21], + 'c7': [229.61, 323.15], 'c8': [161.57, 229.61], 'c9': [113.39, 161.57], + 'c10': [79.37, 113.39], + 'dl': [311.81, 623.62], + 'letter': [612, 792], 'government-letter': [576, 756], 'legal': [612, 1008], + 'junior-legal': [576, 360], 'ledger': [1224, 792], 'tabloid': [792, 1224], + 'credit-card': [153, 243] + }; + var FONT_ROW_RATIO = 1.15; + var el = this; + var DownloadEvt = null; + var $hrows = []; + var $rows = []; + var rowIndex = 0; + var trData = ''; + var colNames = []; + var ranges = []; + var blob; + var $hiddenTableElements = []; + var checkCellVisibilty = false; + + $.extend(true, defaults, options); + + // Adopt deprecated options + if (defaults.type === 'xlsx') { + defaults.mso.fileFormat = defaults.type; + defaults.type = 'excel'; + } + if (typeof defaults.excelFileFormat !== 'undefined' && defaults.mso.fileFormat === 'undefined') + defaults.mso.fileFormat = defaults.excelFileFormat; + if (typeof defaults.excelPageFormat !== 'undefined' && defaults.mso.pageFormat === 'undefined') + defaults.mso.pageFormat = defaults.excelPageFormat; + if (typeof defaults.excelPageOrientation !== 'undefined' && defaults.mso.pageOrientation === 'undefined') + defaults.mso.pageOrientation = defaults.excelPageOrientation; + if (typeof defaults.excelRTL !== 'undefined' && defaults.mso.rtl === 'undefined') + defaults.mso.rtl = defaults.excelRTL; + if (typeof defaults.excelstyles !== 'undefined' && defaults.mso.styles === 'undefined') + defaults.mso.styles = defaults.excelstyles; + if (typeof defaults.onMsoNumberFormat !== 'undefined' && defaults.mso.onMsoNumberFormat === 'undefined') + defaults.mso.onMsoNumberFormat = defaults.onMsoNumberFormat; + if (typeof defaults.worksheetName !== 'undefined' && defaults.mso.worksheetName === 'undefined') + defaults.mso.worksheetName = defaults.worksheetName; + + // Check values of some options + defaults.mso.pageOrientation = (defaults.mso.pageOrientation.substr(0, 1) === 'l') ? 'landscape' : 'portrait'; + + colNames = GetColumnNames(el); + + if ( defaults.type === 'csv' || defaults.type === 'tsv' || defaults.type === 'txt' ) { + + var csvData = ""; + var rowlength = 0; + ranges = []; + rowIndex = 0; + + var csvString = function (cell, rowIndex, colIndex) { + var result = ''; + + if ( cell !== null ) { + var dataString = parseString(cell, rowIndex, colIndex); + + var csvValue = (dataString === null || dataString === '') ? '' : dataString.toString(); + + if ( defaults.type === 'tsv' ) { + if ( dataString instanceof Date ) + dataString.toLocaleString(); + + // According to http://www.iana.org/assignments/media-types/text/tab-separated-values + // are fields that contain tabs not allowable in tsv encoding + result = replaceAll(csvValue, '\t', ' '); + } + else { + // Takes a string and encapsulates it (by default in double-quotes) if it + // contains the csv field separator, spaces, or linebreaks. + if ( dataString instanceof Date ) + result = defaults.csvEnclosure + dataString.toLocaleString() + defaults.csvEnclosure; + else { + result = preventInjection(csvValue); + result = replaceAll(result, defaults.csvEnclosure, defaults.csvEnclosure + defaults.csvEnclosure); + + if ( result.indexOf(defaults.csvSeparator) >= 0 || /[\r\n ]/g.test(result) ) + result = defaults.csvEnclosure + result + defaults.csvEnclosure; + } + } + } + + return result; + }; + + var CollectCsvData = function ($rows, rowselector, length) { + + $rows.each(function () { + trData = ""; + ForEachVisibleCell(this, rowselector, rowIndex, length + $rows.length, + function (cell, row, col) { + trData += csvString(cell, row, col) + (defaults.type === 'tsv' ? '\t' : defaults.csvSeparator); + }); + trData = $.trim(trData).substring(0, trData.length - 1); + if ( trData.length > 0 ) { + + if ( csvData.length > 0 ) + csvData += "\n"; + + csvData += trData; + } + rowIndex++; + }); + + return $rows.length; + }; + + rowlength += CollectCsvData($(el).find('thead').first().find(defaults.theadSelector), 'th,td', rowlength); + findTableElements($(el),'tbody').each(function () { + rowlength += CollectCsvData(findTableElements($(this), defaults.tbodySelector), 'td,th', rowlength); + }); + if ( defaults.tfootSelector.length ) + CollectCsvData($(el).find('tfoot').first().find(defaults.tfootSelector), 'td,th', rowlength); + + csvData += "\n"; + + //output + if ( defaults.outputMode === 'string' ) + return csvData; + + if ( defaults.outputMode === 'base64' ) + return base64encode(csvData); + + if ( defaults.outputMode === 'window' ) { + downloadFile(false, 'data:text/' + (defaults.type === 'csv' ? 'csv' : 'plain') + ';charset=utf-8,', csvData); + return; + } + + try { + blob = new Blob([csvData], {type: "text/" + (defaults.type === 'csv' ? 'csv' : 'plain') + ";charset=utf-8"}); + saveAs(blob, defaults.fileName + '.' + defaults.type, (defaults.type !== 'csv' || defaults.csvUseBOM === false)); + } + catch (e) { + downloadFile(defaults.fileName + '.' + defaults.type, + 'data:text/' + (defaults.type === 'csv' ? 'csv' : 'plain') + ';charset=utf-8,' + ((defaults.type === 'csv' && defaults.csvUseBOM) ? '\ufeff' : ''), + csvData); + } + + } else if ( defaults.type === 'sql' ) { + + // Header + rowIndex = 0; + ranges = []; + var tdData = "INSERT INTO `" + defaults.tableName + "` ("; + $hrows = collectHeadRows ($(el)); + $($hrows).each(function () { + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + tdData += "'" + parseString(cell, row, col) + "',"; + }); + rowIndex++; + tdData = $.trim(tdData).substring(0, tdData.length - 1); + }); + tdData += ") VALUES "; + + // Data + $rows = collectRows ($(el)); + $($rows).each(function () { + trData = ""; + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + trData += "'" + parseString(cell, row, col) + "',"; + }); + if ( trData.length > 3 ) { + tdData += "(" + trData; + tdData = $.trim(tdData).substring(0, tdData.length - 1); + tdData += "),"; + } + rowIndex++; + }); + + tdData = $.trim(tdData).substring(0, tdData.length - 1); + tdData += ";"; + + // Output + if ( defaults.outputMode === 'string' ) + return tdData; + + if ( defaults.outputMode === 'base64' ) + return base64encode(tdData); + + try { + blob = new Blob([tdData], {type: "text/plain;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.sql'); + } + catch (e) { + downloadFile(defaults.fileName + '.sql', + 'data:application/sql;charset=utf-8,', + tdData); + } + + } else if ( defaults.type === 'json' ) { + var jsonHeaderArray = []; + ranges = []; + $hrows = collectHeadRows ($(el)); + $($hrows).each(function () { + var jsonArrayTd = []; + + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + jsonArrayTd.push(parseString(cell, row, col)); + }); + jsonHeaderArray.push(jsonArrayTd); + }); + + // Data + var jsonArray = []; + + $rows = collectRows ($(el)); + $($rows).each(function () { + var jsonObjectTd = {}; + var colIndex = 0; + + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + if ( jsonHeaderArray.length ) { + jsonObjectTd[jsonHeaderArray[jsonHeaderArray.length - 1][colIndex]] = parseString(cell, row, col); + } else { + jsonObjectTd[colIndex] = parseString(cell, row, col); + } + colIndex++; + }); + if ( $.isEmptyObject(jsonObjectTd) === false ) + jsonArray.push(jsonObjectTd); + + rowIndex++; + }); + + var sdata = ""; + + if ( defaults.jsonScope === 'head' ) + sdata = JSON.stringify(jsonHeaderArray); + else if ( defaults.jsonScope === 'data' ) + sdata = JSON.stringify(jsonArray); + else // all + sdata = JSON.stringify({header: jsonHeaderArray, data: jsonArray}); + + if ( defaults.outputMode === 'string' ) + return sdata; + + if ( defaults.outputMode === 'base64' ) + return base64encode(sdata); + + try { + blob = new Blob([sdata], {type: "application/json;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.json'); + } + catch (e) { + downloadFile(defaults.fileName + '.json', + 'data:application/json;charset=utf-8;base64,', + sdata); + } + + } else if ( defaults.type === 'xml' ) { + rowIndex = 0; + ranges = []; + var xml = ''; + xml += ''; + + // Header + $hrows = collectHeadRows ($(el)); + $($hrows).each(function () { + + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + xml += "" + parseString(cell, row, col) + ""; + }); + rowIndex++; + }); + xml += ''; + + // Data + var rowCount = 1; + + $rows = collectRows ($(el)); + $($rows).each(function () { + var colCount = 1; + trData = ""; + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + trData += "" + parseString(cell, row, col) + ""; + colCount++; + }); + if ( trData.length > 0 && trData !== "" ) { + xml += '' + trData + ''; + rowCount++; + } + + rowIndex++; + }); + xml += ''; + + // Output + if ( defaults.outputMode === 'string' ) + return xml; + + if ( defaults.outputMode === 'base64' ) + return base64encode(xml); + + try { + blob = new Blob([xml], {type: "application/xml;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.xml'); + } + catch (e) { + downloadFile(defaults.fileName + '.xml', + 'data:application/xml;charset=utf-8;base64,', + xml); + } + } + else if ( defaults.type === 'excel' && defaults.mso.fileFormat === 'xmlss' ) { + var docDatas = []; + var docNames = []; + + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var $table = $(this); + + var ssName = ''; + if ( typeof defaults.mso.worksheetName === 'string' && defaults.mso.worksheetName.length ) + ssName = defaults.mso.worksheetName + ' ' + (docNames.length + 1); + else if ( typeof defaults.mso.worksheetName[docNames.length] !== 'undefined' ) + ssName = defaults.mso.worksheetName[docNames.length]; + if ( ! ssName.length ) + ssName = $table.find('caption').text() || ''; + if ( ! ssName.length ) + ssName = 'Table ' + (docNames.length + 1); + ssName = $.trim(ssName.replace(/[\\\/[\]*:?'"]/g,'').substring(0,31)); + + docNames.push($('
    ').text(ssName).html()); + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $table.find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + rowIndex = 0; + colNames = GetColumnNames(this); + docData = '\r'; + + function CollectXmlssData ($rows, rowselector, length) { + var spans = []; + + $($rows).each(function () { + var ssIndex = 0; + var nCols = 0; + trData = ""; + + ForEachVisibleCell(this, 'td,th', rowIndex, length + $rows.length, + function (cell, row, col) { + if ( cell !== null ) { + var style = ""; + var data = parseString(cell, row, col); + var type = "String"; + + if ( jQuery.isNumeric(data) !== false ) { + type = "Number"; + } + else { + var number = parsePercent(data); + if ( number !== false ) { + data = number; + type = "Number"; + style += ' ss:StyleID="pct1"'; + } + } + + if ( type !== "Number" ) + data = data.replace(/\n/g, '
    '); + + var colspan = getColspan (cell); + var rowspan = getRowspan (cell); + + // Skip spans + $.each(spans, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && nCols >= range.s.c && nCols <= range.e.c ) { + for ( var i = 0; i <= range.e.c - range.s.c; ++i ) { + nCols++; + ssIndex++; + } + } + }); + + // Handle Row Span + if ( rowspan || colspan ) { + rowspan = rowspan || 1; + colspan = colspan || 1; + spans.push({ + s: {r: rowIndex, c: nCols}, + e: {r: rowIndex + rowspan - 1, c: nCols + colspan - 1} + }); + } + + // Handle Colspan + if ( colspan > 1 ) { + style += ' ss:MergeAcross="' + (colspan-1) + '"'; + nCols += (colspan - 1); + } + + if ( rowspan > 1 ) { + style += ' ss:MergeDown="' + (rowspan-1) + '" ss:StyleID="rsp1"'; + } + + if ( ssIndex > 0 ) { + style += ' ss:Index="' + (nCols+1) + '"'; + ssIndex = 0; + } + + trData += '' + + $('
    ').text(data).html() + + '\r'; + nCols++; + } + }); + if ( trData.length > 0 ) + docData += '\r' + trData + '\r'; + rowIndex++; + }); + + return $rows.length; + } + + var rowLength = CollectXmlssData (collectHeadRows ($table), 'th,td', rowLength); + CollectXmlssData (collectRows ($table), 'td,th', rowLength); + + docData += '
    \r'; + docDatas.push(docData); + }); + + var count = {}; + var firstOccurences = {}; + var item, itemCount; + for (var n = 0, c = docNames.length; n < c; n++) + { + item = docNames[n]; + itemCount = count[item]; + itemCount = count[item] = (itemCount == null ? 1 : itemCount + 1); + + if( itemCount === 2 ) + docNames[firstOccurences[item]] = docNames[firstOccurences[item]].substring(0,29) + "-1"; + if( count[ item ] > 1 ) + docNames[n] = docNames[n].substring(0,29) + "-" + count[item]; + else + firstOccurences[item] = n; + } + + var CreationDate = new Date().toISOString(); + var xmlssDocFile = '\r' + + '\r' + + '\r' + + '\r' + + ' ' + CreationDate + '\r' + + '\r' + + '\r' + + ' \r' + + '\r' + + '\r' + + ' 9000\r' + + ' 13860\r' + + ' 0\r' + + ' 0\r' + + ' False\r' + + ' False\r' + + '\r' + + '\r' + + ' \r' + + ' \r' + + ' \r' + + '\r'; + + for ( var j = 0; j < docDatas.length; j++ ) { + xmlssDocFile += '\r' + + docDatas[j]; + if (defaults.mso.rtl) { + xmlssDocFile += '\r' + + '\r' + + '\r'; + } + else + xmlssDocFile += '\r'; + xmlssDocFile += '\r'; + } + + xmlssDocFile += '\r'; + + if ( defaults.outputMode === 'string' ) + return xmlssDocFile; + + if ( defaults.outputMode === 'base64' ) + return base64encode(xmlssDocFile); + + try { + blob = new Blob([xmlssDocFile], {type: "application/xml;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.xml'); + } + catch (e) { + downloadFile(defaults.fileName + '.xml', + 'data:application/xml;charset=utf-8;base64,', + xmlssDocFile); + } + } + else if ( defaults.type === 'excel' && defaults.mso.fileFormat === 'xlsx' ) { + + var data = []; + var spans = []; + rowIndex = 0; + + $rows = collectHeadRows ($(el)); + $rows.push.apply($rows, collectRows ($(el))); + + $($rows).each(function () { + var cols = []; + ForEachVisibleCell(this, 'th,td', rowIndex, $rows.length, + function (cell, row, col) { + if ( typeof cell !== 'undefined' && cell !== null ) { + + var cellValue = parseString(cell, row, col); + + var colspan = getColspan (cell); + var rowspan = getRowspan (cell); + + // Skip span ranges + $.each(spans, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cols.length >= range.s.c && cols.length <= range.e.c ) { + for ( var i = 0; i <= range.e.c - range.s.c; ++i ) + cols.push(null); + } + }); + + // Handle Row Span + if ( rowspan || colspan ) { + rowspan = rowspan || 1; + colspan = colspan || 1; + spans.push({ + s: {r: rowIndex, c: cols.length}, + e: {r: rowIndex + rowspan - 1, c: cols.length + colspan - 1} + }); + } + + // Handle Value + if ( typeof defaults.onCellData !== 'function' ) { + + // Type conversion + if ( cellValue !== "" && cellValue === +cellValue ) + cellValue = +cellValue; + } + cols.push(cellValue !== "" ? cellValue : null); + + // Handle Colspan + if ( colspan ) + for ( var k = 0; k < colspan - 1; ++k ) + cols.push(null); + } + }); + data.push(cols); + rowIndex++; + }); + + //noinspection JSPotentiallyInvalidConstructorUsage + var wb = new jx_Workbook(), + ws = jx_createSheet(data); + + // add span ranges to worksheet + ws['!merges'] = spans; + + // add worksheet to workbook + //wb.SheetNames.push(defaults.mso.worksheetName); + //wb.Sheets[defaults.mso.worksheetName] = ws; + XLSX.utils.book_append_sheet(wb, ws, defaults.mso.worksheetName); + + var wbout = XLSX.write(wb, {type: 'binary', bookType: defaults.mso.fileFormat, bookSST: false}); + + try { + blob = new Blob([jx_s2ab(wbout)], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'}); + saveAs(blob, defaults.fileName + '.' + defaults.mso.fileFormat); + } + catch (e) { + downloadFile(defaults.fileName + '.' + defaults.mso.fileFormat, + 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8,', + jx_s2ab(wbout)); + } + } + else if ( defaults.type === 'excel' || defaults.type === 'xls' || defaults.type === 'word' || defaults.type === 'doc' ) { + + var MSDocType = (defaults.type === 'excel' || defaults.type === 'xls') ? 'excel' : 'word'; + var MSDocExt = (MSDocType === 'excel') ? 'xls' : 'doc'; + var MSDocSchema = 'xmlns:x="urn:schemas-microsoft-com:office:' + MSDocType + '"'; + var docData = ''; + var docName = ''; + + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var $table = $(this); + + if (docName === '') { + docName = defaults.mso.worksheetName || $table.find('caption').text() || 'Table'; + docName = $.trim(docName.replace(/[\\\/[\]*:?'"]/g, '').substring(0, 31)); + } + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $table.find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + rowIndex = 0; + ranges = []; + colNames = GetColumnNames(this); + + // Header + docData += ''; + $hrows = collectHeadRows ($table); + $($hrows).each(function () { + trData = ""; + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + if ( cell !== null ) { + var thstyle = ''; + trData += ' 0 ) + trData += ' colspan="' + tdcolspan + '"'; + + var tdrowspan = getRowspan (cell); + if ( tdrowspan > 0 ) + trData += ' rowspan="' + tdrowspan + '"'; + + trData += '>' + parseString(cell, row, col) + ''; + } + }); + if ( trData.length > 0 ) + docData += '' + trData + ''; + rowIndex++; + }); + docData += ''; + + // Data + $rows = collectRows ($table); + $($rows).each(function () { + var $row = $(this); + trData = ""; + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + if ( cell !== null ) { + var tdvalue = parseString(cell, row, col); + var tdstyle = ''; + var tdcss = $(cell).data("tableexport-msonumberformat"); + + if ( typeof tdcss === 'undefined' && typeof defaults.mso.onMsoNumberFormat === 'function' ) + tdcss = defaults.mso.onMsoNumberFormat(cell, row, col); + + if ( typeof tdcss !== 'undefined' && tdcss !== '' ) + tdstyle = 'style="mso-number-format:\'' + tdcss + '\''; + + for ( var cssStyle in defaults.mso.styles ) { + if ( defaults.mso.styles.hasOwnProperty(cssStyle) ) { + tdcss = $(cell).css(defaults.mso.styles[cssStyle]); + if ( tdcss === '' ) + tdcss = $row.css(defaults.mso.styles[cssStyle]); + + if ( tdcss !== '' && tdcss !== '0px none rgb(0, 0, 0)' && tdcss !== 'rgba(0, 0, 0, 0)' ) { + tdstyle += (tdstyle === '') ? 'style="' : ';'; + tdstyle += defaults.mso.styles[cssStyle] + ':' + tdcss; + } + } + } + trData += ' 0 ) + trData += ' colspan="' + tdcolspan + '"'; + + var tdrowspan = getRowspan (cell); + if ( tdrowspan > 0 ) + trData += ' rowspan="' + tdrowspan + '"'; + + if ( typeof tdvalue === 'string' && tdvalue !== '' ) { + tdvalue = preventInjection(tdvalue); + tdvalue = tdvalue.replace(/\n/g, '
    '); + } + + trData += '>' + tdvalue + ''; + } + }); + if ( trData.length > 0 ) + docData += '
    ' + trData + ''; + rowIndex++; + }); + + if ( defaults.displayTableName ) + docData += ''; + + docData += '
    ' + parseString($('

    ' + defaults.tableName + '

    ')) + '
    '; + }); + + //noinspection XmlUnusedNamespaceDeclaration + var docFile = ''; + docFile += ''; + docFile += ""; + if (MSDocType === 'excel') { + docFile += ""; + } + docFile += ""; + docFile += ""; + docFile += ""; + docFile += "
    "; + docFile += docData; + docFile += "
    "; + docFile += ""; + docFile += ""; + + if ( defaults.outputMode === 'string' ) + return docFile; + + if ( defaults.outputMode === 'base64' ) + return base64encode(docFile); + + try { + blob = new Blob([docFile], {type: 'application/vnd.ms-' + defaults.type}); + saveAs(blob, defaults.fileName + '.' + MSDocExt); + } + catch (e) { + downloadFile(defaults.fileName + '.' + MSDocExt, + 'data:application/vnd.ms-' + MSDocType + ';base64,', + docFile); + } + } + else if ( defaults.type === 'png' ) { + //html2canvas($(el)[0], { + // onrendered: function (canvas) { + html2canvas($(el)[0]).then( + function (canvas) { + + var image = canvas.toDataURL(); + var byteString = atob(image.substring(22)); // remove data stuff + var buffer = new ArrayBuffer(byteString.length); + var intArray = new Uint8Array(buffer); + + for ( var i = 0; i < byteString.length; i++ ) + intArray[i] = byteString.charCodeAt(i); + + if ( defaults.outputMode === 'string' ) + return byteString; + + if ( defaults.outputMode === 'base64' ) + return base64encode(image); + + if ( defaults.outputMode === 'window' ) { + window.open(image); + return; + } + + try { + blob = new Blob([buffer], {type: "image/png"}); + saveAs(blob, defaults.fileName + '.png'); + } + catch (e) { + downloadFile(defaults.fileName + '.png', 'data:image/png,', blob); + } + //} + }); + + } else if ( defaults.type === 'pdf' ) { + + if ( defaults.pdfmake.enabled === true ) { + // pdf output using pdfmake + // https://github.com/bpampuch/pdfmake + + var widths = []; + var body = []; + rowIndex = 0; + ranges = []; + + /** + * @return {number} + */ + var CollectPdfmakeData = function ($rows, colselector, length) { + var rlength = 0; + + $($rows).each(function () { + var r = []; + + ForEachVisibleCell(this, colselector, rowIndex, length, + function (cell, row, col) { + if ( typeof cell !== 'undefined' && cell !== null ) { + + var colspan = getColspan (cell); + var rowspan = getRowspan (cell); + + var cellValue = parseString(cell, row, col) || " "; + + if ( colspan > 1 || rowspan > 1 ) { + colspan = colspan || 1; + rowspan = rowspan || 1; + r.push({colSpan: colspan, rowSpan: rowspan, text: cellValue}); + } + else + r.push(cellValue); + } + else + r.push(" "); + }); + + if ( r.length ) + body.push(r); + + if ( rlength < r.length ) + rlength = r.length; + + rowIndex++; + }); + + return rlength; + }; + + $hrows = collectHeadRows ($(this)); + + var colcount = CollectPdfmakeData($hrows, 'th,td', $hrows.length); + + for ( var i = widths.length; i < colcount; i++ ) + widths.push("*"); + + // Data + $rows = collectRows ($(this)); + + CollectPdfmakeData($rows, 'th,td', $hrows.length + $rows.length); + + var docDefinition = { + content: [{ + table: { + headerRows: $hrows.length, + widths: widths, + body: body + } + }] + }; + + $.extend(true, docDefinition, defaults.pdfmake.docDefinition); + + pdfMake.fonts = { + Roboto: { + normal: 'Roboto-Regular.ttf', + bold: 'Roboto-Medium.ttf', + italics: 'Roboto-Italic.ttf', + bolditalics: 'Roboto-MediumItalic.ttf' + } + }; + + $.extend(true, pdfMake.fonts, defaults.pdfmake.fonts); + + pdfMake.createPdf(docDefinition).getBuffer(function (buffer) { + + try { + var blob = new Blob([buffer], {type: "application/pdf"}); + saveAs(blob, defaults.fileName + '.pdf'); + } + catch (e) { + downloadFile(defaults.fileName + '.pdf', 'application/pdf', buffer); + } + }); + + } + else if ( defaults.jspdf.autotable === false ) { + // pdf output using jsPDF's core html support + + var addHtmlOptions = { + dim: { + w: getPropertyUnitValue($(el).first().get(0), 'width', 'mm'), + h: getPropertyUnitValue($(el).first().get(0), 'height', 'mm') + }, + pagesplit: false + }; + + var doc = new jsPDF(defaults.jspdf.orientation, defaults.jspdf.unit, defaults.jspdf.format); + doc.addHTML($(el).first(), + defaults.jspdf.margins.left, + defaults.jspdf.margins.top, + addHtmlOptions, + function () { + jsPdfOutput(doc, false); + }); + //delete doc; + } + else { + // pdf output using jsPDF AutoTable plugin + // https://github.com/simonbengtsson/jsPDF-AutoTable + + var teOptions = defaults.jspdf.autotable.tableExport; + + // When setting jspdf.format to 'bestfit' tableExport tries to choose + // the minimum required paper format and orientation in which the table + // (or tables in multitable mode) completely fits without column adjustment + if ( typeof defaults.jspdf.format === 'string' && defaults.jspdf.format.toLowerCase() === 'bestfit' ) { + var rk = '', ro = ''; + var mw = 0; + + $(el).each(function () { + if ( isVisible($(this)) ) { + var w = getPropertyUnitValue($(this).get(0), 'width', 'pt'); + + if ( w > mw ) { + if ( w > pageFormats.a0[0] ) { + rk = 'a0'; + ro = 'l'; + } + for ( var key in pageFormats ) { + if ( pageFormats.hasOwnProperty(key) ) { + if ( pageFormats[key][1] > w ) { + rk = key; + ro = 'l'; + if ( pageFormats[key][0] > w ) + ro = 'p'; + } + } + } + mw = w; + } + } + }); + defaults.jspdf.format = (rk === '' ? 'a4' : rk); + defaults.jspdf.orientation = (ro === '' ? 'w' : ro); + } + + // The jsPDF doc object is stored in defaults.jspdf.autotable.tableExport, + // thus it can be accessed from any callback function + if ( teOptions.doc == null ) { + teOptions.doc = new jsPDF(defaults.jspdf.orientation, + defaults.jspdf.unit, + defaults.jspdf.format); + + if ( typeof defaults.jspdf.onDocCreated === 'function' ) + defaults.jspdf.onDocCreated(teOptions.doc); + } + + if ( teOptions.outputImages === true ) + teOptions.images = {}; + + if ( typeof teOptions.images !== 'undefined' ) { + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var rowCount = 0; + ranges = []; + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $(this).find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + $hrows = collectHeadRows ($(this)); + $rows = collectRows ($(this)); + + $($rows).each(function () { + ForEachVisibleCell(this, 'td,th', $hrows.length + rowCount, $hrows.length + $rows.length, + function (cell) { + collectImages(cell, $(cell).children(), teOptions); + }); + rowCount++; + }); + }); + + $hrows = []; + $rows = []; + } + + loadImages(teOptions, function () { + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var colKey; + rowIndex = 0; + ranges = []; + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $(this).find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + colNames = GetColumnNames(this); + + teOptions.columns = []; + teOptions.rows = []; + teOptions.teCells = {}; + + // onTable: optional callback function for every matching table that can be used + // to modify the tableExport options or to skip the output of a particular table + // if the table selector targets multiple tables + if ( typeof teOptions.onTable === 'function' ) + if ( teOptions.onTable($(this), defaults) === false ) + return true; // continue to next iteration step (table) + + // each table works with an own copy of AutoTable options + defaults.jspdf.autotable.tableExport = null; // avoid deep recursion error + var atOptions = $.extend(true, {}, defaults.jspdf.autotable); + defaults.jspdf.autotable.tableExport = teOptions; + + atOptions.margin = {}; + $.extend(true, atOptions.margin, defaults.jspdf.margins); + atOptions.tableExport = teOptions; + + // Fix jsPDF Autotable's row height calculation + if ( typeof atOptions.beforePageContent !== 'function' ) { + atOptions.beforePageContent = function (data) { + if ( data.pageCount === 1 ) { + var all = data.table.rows.concat(data.table.headerRow); + $.each(all, function () { + var row = this; + if ( row.height > 0 ) { + row.height += (2 - FONT_ROW_RATIO) / 2 * row.styles.fontSize; + data.table.height += (2 - FONT_ROW_RATIO) / 2 * row.styles.fontSize; + } + }); + } + }; + } + + if ( typeof atOptions.createdHeaderCell !== 'function' ) { + // apply some original css styles to pdf header cells + atOptions.createdHeaderCell = function (cell, data) { + + // jsPDF AutoTable plugin v2.0.14 fix: each cell needs its own styles object + cell.styles = $.extend({}, data.row.styles); + + if ( typeof teOptions.columns [data.column.dataKey] !== 'undefined' ) { + var col = teOptions.columns [data.column.dataKey]; + + if ( typeof col.rect !== 'undefined' ) { + var rh; + + cell.contentWidth = col.rect.width; + + if ( typeof teOptions.heightRatio === 'undefined' || teOptions.heightRatio === 0 ) { + if ( data.row.raw [data.column.dataKey].rowspan ) + rh = data.row.raw [data.column.dataKey].rect.height / data.row.raw [data.column.dataKey].rowspan; + else + rh = data.row.raw [data.column.dataKey].rect.height; + + teOptions.heightRatio = cell.styles.rowHeight / rh; + } + + rh = data.row.raw [data.column.dataKey].rect.height * teOptions.heightRatio; + if ( rh > cell.styles.rowHeight ) + cell.styles.rowHeight = rh; + } + + cell.styles.halign = (atOptions.headerStyles.halign === 'inherit') ? 'center' : atOptions.headerStyles.halign; + cell.styles.valign = atOptions.headerStyles.valign; + + if ( typeof col.style !== 'undefined' && col.style.hidden !== true ) { + if ( atOptions.headerStyles.halign === 'inherit' ) + cell.styles.halign = col.style.align; + if ( atOptions.styles.fillColor === 'inherit' ) + cell.styles.fillColor = col.style.bcolor; + if ( atOptions.styles.textColor === 'inherit' ) + cell.styles.textColor = col.style.color; + if ( atOptions.styles.fontStyle === 'inherit' ) + cell.styles.fontStyle = col.style.fstyle; + } + } + }; + } + + if ( typeof atOptions.createdCell !== 'function' ) { + // apply some original css styles to pdf table cells + atOptions.createdCell = function (cell, data) { + var tecell = teOptions.teCells [data.row.index + ":" + data.column.dataKey]; + + cell.styles.halign = (atOptions.styles.halign === 'inherit') ? 'center' : atOptions.styles.halign; + cell.styles.valign = atOptions.styles.valign; + + if ( typeof tecell !== 'undefined' && typeof tecell.style !== 'undefined' && tecell.style.hidden !== true ) { + if ( atOptions.styles.halign === 'inherit' ) + cell.styles.halign = tecell.style.align; + if ( atOptions.styles.fillColor === 'inherit' ) + cell.styles.fillColor = tecell.style.bcolor; + if ( atOptions.styles.textColor === 'inherit' ) + cell.styles.textColor = tecell.style.color; + if ( atOptions.styles.fontStyle === 'inherit' ) + cell.styles.fontStyle = tecell.style.fstyle; + } + }; + } + + if ( typeof atOptions.drawHeaderCell !== 'function' ) { + atOptions.drawHeaderCell = function (cell, data) { + var colopt = teOptions.columns [data.column.dataKey]; + + if ( (colopt.style.hasOwnProperty("hidden") !== true || colopt.style.hidden !== true) && + colopt.rowIndex >= 0 ) + return prepareAutoTableText(cell, data, colopt); + else + return false; // cell is hidden + }; + } + + if ( typeof atOptions.drawCell !== 'function' ) { + atOptions.drawCell = function (cell, data) { + var tecell = teOptions.teCells [data.row.index + ":" + data.column.dataKey]; + var draw2canvas = (typeof tecell !== 'undefined' && + typeof tecell.elements !== 'undefined' && tecell.elements.length && + tecell.elements[0].hasAttribute("data-tableexport-canvas")); + if ( draw2canvas !== true ) { + if ( prepareAutoTableText(cell, data, tecell) ) { + + teOptions.doc.rect(cell.x, cell.y, cell.width, cell.height, cell.styles.fillStyle); + + if ( typeof tecell !== 'undefined' && + typeof tecell.elements !== 'undefined' && tecell.elements.length ) { + + var dh = cell.height / tecell.rect.height; + if ( dh > teOptions.dh || typeof teOptions.dh === 'undefined' ) + teOptions.dh = dh; + teOptions.dw = cell.width / tecell.rect.width; + + var y = cell.textPos.y; + drawAutotableElements(cell, tecell.elements, teOptions); + cell.textPos.y = y; + + drawAutotableText(cell, tecell.elements, teOptions); + } + else + drawAutotableText(cell, {}, teOptions); + } + } + else { + var container = tecell.elements[0]; + var imgId = $(container).attr("data-tableexport-canvas"); + jsPdfDrawImage (cell, container, imgId, teOptions); + } + return false; + }; + } + + // collect header and data rows + teOptions.headerrows = []; + $hrows = collectHeadRows ($(this)); + $($hrows).each(function () { + colKey = 0; + teOptions.headerrows[rowIndex] = []; + + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + var obj = getCellStyles(cell); + obj.title = parseString(cell, row, col); + obj.key = colKey++; + obj.rowIndex = rowIndex; + teOptions.headerrows[rowIndex].push(obj); + }); + rowIndex++; + }); + + if ( rowIndex > 0 ) { + // iterate through last row + var lastrow = rowIndex - 1; + while ( lastrow >= 0 ) { + $.each(teOptions.headerrows[lastrow], function () { + var obj = this; + + if ( lastrow > 0 && this.rect === null ) + obj = teOptions.headerrows[lastrow - 1][this.key]; + + if ( obj !== null && obj.rowIndex >= 0 && + (obj.style.hasOwnProperty("hidden") !== true || obj.style.hidden !== true) ) + teOptions.columns.push(obj); + }); + + lastrow = (teOptions.columns.length > 0) ? -1 : lastrow - 1; + } + } + + var rowCount = 0; + $rows = []; + $rows = collectRows ($(this)); + $($rows).each(function () { + var rowData = []; + colKey = 0; + + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + var obj; + + if ( typeof teOptions.columns[colKey] === 'undefined' ) { + // jsPDF-Autotable needs columns. Thus define hidden ones for tables without thead + obj = { + title: '', + key: colKey, + style: { + hidden: true + } + }; + teOptions.columns.push(obj); + } + if ( typeof cell !== 'undefined' && cell !== null ) { + obj = getCellStyles(cell); + obj.elements = cell.hasAttribute("data-tableexport-canvas") ? $(cell) : $(cell).children(); + teOptions.teCells [rowCount + ":" + colKey++] = obj; + } + else { + obj = $.extend(true, {}, teOptions.teCells [rowCount + ":" + (colKey - 1)]); + obj.colspan = -1; + teOptions.teCells [rowCount + ":" + colKey++] = obj; + } + + rowData.push(parseString(cell, row, col)); + }); + if ( rowData.length ) { + teOptions.rows.push(rowData); + rowCount++; + } + rowIndex++; + }); + + // onBeforeAutotable: optional callback function before calling + // jsPDF AutoTable that can be used to modify the AutoTable options + if ( typeof teOptions.onBeforeAutotable === 'function' ) + teOptions.onBeforeAutotable($(this), teOptions.columns, teOptions.rows, atOptions); + + teOptions.doc.autoTable(teOptions.columns, teOptions.rows, atOptions); + + // onAfterAutotable: optional callback function after returning + // from jsPDF AutoTable that can be used to modify the AutoTable options + if ( typeof teOptions.onAfterAutotable === 'function' ) + teOptions.onAfterAutotable($(this), atOptions); + + // set the start position for the next table (in case there is one) + defaults.jspdf.autotable.startY = teOptions.doc.autoTableEndPosY() + atOptions.margin.top; + + }); + + jsPdfOutput(teOptions.doc, (typeof teOptions.images !== 'undefined' && jQuery.isEmptyObject(teOptions.images) === false)); + + if ( typeof teOptions.headerrows !== 'undefined' ) + teOptions.headerrows.length = 0; + if ( typeof teOptions.columns !== 'undefined' ) + teOptions.columns.length = 0; + if ( typeof teOptions.rows !== 'undefined' ) + teOptions.rows.length = 0; + delete teOptions.doc; + teOptions.doc = null; + }); + } + } + + function collectHeadRows ($table) { + var result = []; + findTableElements($table,'thead').each(function () { + result.push.apply(result, findTableElements($(this), defaults.theadSelector).toArray()); + }); + return result; + } + + function collectRows ($table) { + var result = []; + findTableElements($table,'tbody').each(function () { + result.push.apply(result, findTableElements($(this), defaults.tbodySelector).toArray()); + }); + if ( defaults.tfootSelector.length ) { + findTableElements($table,'tfoot').each(function () { + result.push.apply(result, findTableElements($(this), defaults.tfootSelector).toArray()); + }); + } + return result; + } + + function findTableElements ($parent, selector) { + var parentSelector = $parent[0].tagName; + var parentLevel = $parent.parents(parentSelector).length; + return $parent.find(selector).filter (function () { + return parentLevel === $(this).closest(parentSelector).parents(parentSelector).length; + }); + } + + function GetColumnNames (table) { + var result = []; + $(table).find('thead').first().find('th').each(function (index, el) { + if ( $(el).attr("data-field") !== undefined ) + result[index] = $(el).attr("data-field"); + else + result[index] = index.toString(); + }); + return result; + } + + function isVisible ($element) { + var isCell = typeof $element[0].cellIndex !== 'undefined'; + var isRow = typeof $element[0].rowIndex !== 'undefined'; + var isElementVisible = (isCell || isRow) ? isTableElementVisible($element) : $element.is(':visible'); + var tableexportDisplay = $element.data("tableexport-display"); + + if (isCell && tableexportDisplay !== 'none' && tableexportDisplay !== 'always') { + $element = $($element[0].parentNode); + isRow = typeof $element[0].rowIndex !== 'undefined'; + tableexportDisplay = $element.data("tableexport-display"); + } + if (isRow && tableexportDisplay !== 'none' && tableexportDisplay !== 'always') { + tableexportDisplay = $element.closest('table').data("tableexport-display"); + } + + return tableexportDisplay !== 'none' && (isElementVisible === true || tableexportDisplay === 'always'); + } + + function isTableElementVisible ($element) { + var hiddenEls = []; + + if ( checkCellVisibilty ) { + hiddenEls = $hiddenTableElements.filter (function () { + var found = false; + + if (this.nodeType === $element[0].nodeType) { + if (typeof this.rowIndex !== 'undefined' && this.rowIndex === $element[0].rowIndex) + found = true; + else if (typeof this.cellIndex !== 'undefined' && this.cellIndex === $element[0].cellIndex && + typeof this.parentNode.rowIndex !== 'undefined' && + typeof $element[0].parentNode.rowIndex !== 'undefined' && + this.parentNode.rowIndex === $element[0].parentNode.rowIndex) + found = true; + } + return found; + }); + } + return (checkCellVisibilty === false || hiddenEls.length === 0); + } + + function isColumnIgnored ($cell, rowLength, colIndex) { + var result = false; + + if (isVisible($cell)) { + if ( defaults.ignoreColumn.length > 0 ) { + if ( $.inArray(colIndex, defaults.ignoreColumn) !== -1 || + $.inArray(colIndex - rowLength, defaults.ignoreColumn) !== -1 || + (colNames.length > colIndex && typeof colNames[colIndex] !== 'undefined' && + $.inArray(colNames[colIndex], defaults.ignoreColumn) !== -1) ) + result = true; + } + } + else + result = true; + + return result; + } + + function ForEachVisibleCell (tableRow, selector, rowIndex, rowCount, cellcallback) { + if ( typeof (cellcallback) === 'function' ) { + var ignoreRow = false; + + if (typeof defaults.onIgnoreRow === 'function') + ignoreRow = defaults.onIgnoreRow($(tableRow), rowIndex); + + if (ignoreRow === false && + $.inArray(rowIndex, defaults.ignoreRow) === -1 && + $.inArray(rowIndex - rowCount, defaults.ignoreRow) === -1 && + isVisible($(tableRow))) { + + var $cells = findTableElements($(tableRow), selector); + var cellCount = 0; + + $cells.each(function (colIndex) { + var $cell = $(this); + var c; + var colspan = getColspan (this); + var rowspan = getRowspan (this); + + // Skip ranges + $.each(ranges, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cellCount >= range.s.c && cellCount <= range.e.c ) { + for ( c = 0; c <= range.e.c - range.s.c; ++c ) + cellcallback(null, rowIndex, cellCount++); + } + }); + + if ( isColumnIgnored($cell, $cells.length, colIndex) === false ) { + // Handle Row Span + if ( rowspan || colspan ) { + rowspan = rowspan || 1; + colspan = colspan || 1; + ranges.push({ + s: {r: rowIndex, c: cellCount}, + e: {r: rowIndex + rowspan - 1, c: cellCount + colspan - 1} + }); + } + + // Handle Value + cellcallback(this, rowIndex, cellCount++); + } + + // Handle Colspan + if ( colspan ) + for ( c = 0; c < colspan - 1; ++c ) + cellcallback(null, rowIndex, cellCount++); + }); + + // Skip ranges + $.each(ranges, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cellCount >= range.s.c && cellCount <= range.e.c ) { + for ( c = 0; c <= range.e.c - range.s.c; ++c ) + cellcallback(null, rowIndex, cellCount++); + } + }); + } + } + } + + function jsPdfDrawImage (cell, container, imgId, teOptions) { + if ( typeof teOptions.images !== 'undefined' ) { + var image = teOptions.images[imgId]; + + if ( typeof image !== 'undefined' ) { + var arCell = cell.width / cell.height; + var arImg = container.width / container.height; + var imgWidth = cell.width; + var imgHeight = cell.height; + var px2pt = 0.264583 * 72 / 25.4; + var uy = 0; + + if ( arImg <= arCell ) { + imgHeight = Math.min(cell.height, container.height); + imgWidth = container.width * imgHeight / container.height; + } + else if ( arImg > arCell ) { + imgWidth = Math.min(cell.width, container.width); + imgHeight = container.height * imgWidth / container.width; + } + + imgWidth *= px2pt; + imgHeight *= px2pt; + + if ( imgHeight < cell.height ) + uy = (cell.height - imgHeight) / 2; + + try { + teOptions.doc.addImage(image.src, cell.textPos.x, cell.y + uy, imgWidth, imgHeight); + } + catch (e) { + // TODO: IE -> convert png to jpeg + } + cell.textPos.x += imgWidth; + } + } + } + + function jsPdfOutput (doc, hasimages) { + if ( defaults.outputMode === 'string' ) + return doc.output(); + + if ( defaults.outputMode === 'base64' ) + return base64encode(doc.output()); + + if ( defaults.outputMode === 'window' ) { + window.URL = window.URL || window.webkitURL; + window.open(window.URL.createObjectURL(doc.output("blob"))); + return; + } + + try { + var blob = doc.output('blob'); + saveAs(blob, defaults.fileName + '.pdf'); + } + catch (e) { + downloadFile(defaults.fileName + '.pdf', + 'data:application/pdf' + (hasimages ? '' : ';base64') + ',', + hasimages ? doc.output('blob') : doc.output()); + } + } + + function prepareAutoTableText (cell, data, cellopt) { + var cs = 0; + if ( typeof cellopt !== 'undefined' ) + cs = cellopt.colspan; + + if ( cs >= 0 ) { + // colspan handling + var cellWidth = cell.width; + var textPosX = cell.textPos.x; + var i = data.table.columns.indexOf(data.column); + + for ( var c = 1; c < cs; c++ ) { + var column = data.table.columns[i + c]; + cellWidth += column.width; + } + + if ( cs > 1 ) { + if ( cell.styles.halign === 'right' ) + textPosX = cell.textPos.x + cellWidth - cell.width; + else if ( cell.styles.halign === 'center' ) + textPosX = cell.textPos.x + (cellWidth - cell.width) / 2; + } + + cell.width = cellWidth; + cell.textPos.x = textPosX; + + if ( typeof cellopt !== 'undefined' && cellopt.rowspan > 1 ) + cell.height = cell.height * cellopt.rowspan; + + // fix jsPDF's calculation of text position + if ( cell.styles.valign === 'middle' || cell.styles.valign === 'bottom' ) { + var splittedText = typeof cell.text === 'string' ? cell.text.split(/\r\n|\r|\n/g) : cell.text; + var lineCount = splittedText.length || 1; + if ( lineCount > 2 ) + cell.textPos.y -= ((2 - FONT_ROW_RATIO) / 2 * data.row.styles.fontSize) * (lineCount - 2) / 3; + } + return true; + } + else + return false; // cell is hidden (colspan = -1), don't draw it + } + + function collectImages (cell, elements, teOptions) { + if ( typeof cell !== 'undefined' && cell !== null ) { + + if ( cell.hasAttribute("data-tableexport-canvas") ) { + var imgId = new Date().getTime(); + $(cell).attr("data-tableexport-canvas", imgId); + + teOptions.images[imgId] = { + url: '[data-tableexport-canvas="'+imgId+'"]', + src: null + }; + } + else if (elements !== 'undefined' && elements != null) { + elements.each(function () { + if ($(this).is("img")) { + var imgId = strHashCode(this.src); + teOptions.images[imgId] = { + url: this.src, + src: this.src + }; + } + collectImages(cell, $(this).children(), teOptions); + }); + } + } + } + + function loadImages (teOptions, callback) { + var imageCount = 0; + var pendingCount = 0; + + function done () { + callback(imageCount); + } + + function loadImage (image) { + if (image.url) { + if (!image.src) { + var $imgContainer = $(image.url); + if ($imgContainer.length) { + imageCount = ++pendingCount; + + html2canvas($imgContainer[0]).then(function(canvas) { + image.src = canvas.toDataURL("image/png"); + if ( !--pendingCount ) + done(); + }); + } + } + else { + var img = new Image(); + imageCount = ++pendingCount; + img.crossOrigin = 'Anonymous'; + img.onerror = img.onload = function () { + if ( img.complete ) { + + if ( img.src.indexOf('data:image/') === 0 ) { + img.width = image.width || img.width || 0; + img.height = image.height || img.height || 0; + } + + if ( img.width + img.height ) { + var canvas = document.createElement("canvas"); + var ctx = canvas.getContext("2d"); + + canvas.width = img.width; + canvas.height = img.height; + ctx.drawImage(img, 0, 0); + + image.src = canvas.toDataURL("image/png"); + } + } + if ( !--pendingCount ) + done(); + }; + img.src = image.url; + } + } + } + + if ( typeof teOptions.images !== 'undefined' ) { + for ( var i in teOptions.images ) + if ( teOptions.images.hasOwnProperty(i) ) + loadImage(teOptions.images[i]); + } + + return pendingCount || done(); + } + + function drawAutotableElements (cell, elements, teOptions) { + elements.each(function () { + if ( $(this).is("div") ) { + var bcolor = rgb2array(getStyle(this, 'background-color'), [255, 255, 255]); + var lcolor = rgb2array(getStyle(this, 'border-top-color'), [0, 0, 0]); + var lwidth = getPropertyUnitValue(this, 'border-top-width', defaults.jspdf.unit); + + var r = this.getBoundingClientRect(); + var ux = this.offsetLeft * teOptions.dw; + var uy = this.offsetTop * teOptions.dh; + var uw = r.width * teOptions.dw; + var uh = r.height * teOptions.dh; + + teOptions.doc.setDrawColor.apply(undefined, lcolor); + teOptions.doc.setFillColor.apply(undefined, bcolor); + teOptions.doc.setLineWidth(lwidth); + teOptions.doc.rect(cell.x + ux, cell.y + uy, uw, uh, lwidth ? "FD" : "F"); + } + else if ( $(this).is("img") ) { + var imgId = strHashCode(this.src); + jsPdfDrawImage (cell, this, imgId, teOptions); + } + + drawAutotableElements(cell, $(this).children(), teOptions); + }); + } + + function drawAutotableText (cell, texttags, teOptions) { + if ( typeof teOptions.onAutotableText === 'function' ) { + teOptions.onAutotableText(teOptions.doc, cell, texttags); + } + else { + var x = cell.textPos.x; + var y = cell.textPos.y; + var style = {halign: cell.styles.halign, valign: cell.styles.valign}; + + if ( texttags.length ) { + var tag = texttags[0]; + while ( tag.previousSibling ) + tag = tag.previousSibling; + + var b = false, i = false; + + while ( tag ) { + var txt = tag.innerText || tag.textContent || ""; + var leadingspace = (txt.length && txt[0] === " ") ? " " : ""; + var trailingspace = (txt.length > 1 && txt[txt.length - 1] === " ") ? " " : ""; + + if (defaults.preserve.leadingWS !== true) + txt = leadingspace + trimLeft(txt); + if (defaults.preserve.trailingWS !== true) + txt = trimRight(txt) + trailingspace; + + if ( $(tag).is("br") ) { + x = cell.textPos.x; + y += teOptions.doc.internal.getFontSize(); + } + + if ( $(tag).is("b") ) + b = true; + else if ( $(tag).is("i") ) + i = true; + + if ( b || i ) + teOptions.doc.setFontType((b && i) ? "bolditalic" : b ? "bold" : "italic"); + + var w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); + + if ( w ) { + if ( cell.styles.overflow === 'linebreak' && + x > cell.textPos.x && (x + w) > (cell.textPos.x + cell.width) ) { + var chars = ".,!%*;:=-"; + if ( chars.indexOf(txt.charAt(0)) >= 0 ) { + var s = txt.charAt(0); + w = teOptions.doc.getStringUnitWidth(s) * teOptions.doc.internal.getFontSize(); + if ( (x + w) <= (cell.textPos.x + cell.width) ) { + teOptions.doc.autoTableText(s, x, y, style); + txt = txt.substring(1, txt.length); + } + w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); + } + x = cell.textPos.x; + y += teOptions.doc.internal.getFontSize(); + } + + if ( cell.styles.overflow !== 'visible' ) { + while ( txt.length && (x + w) > (cell.textPos.x + cell.width) ) { + txt = txt.substring(0, txt.length - 1); + w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); + } + } + + teOptions.doc.autoTableText(txt, x, y, style); + x += w; + } + + if ( b || i ) { + if ( $(tag).is("b") ) + b = false; + else if ( $(tag).is("i") ) + i = false; + + teOptions.doc.setFontType((!b && !i) ? "normal" : b ? "bold" : "italic"); + } + + tag = tag.nextSibling; + } + cell.textPos.x = x; + cell.textPos.y = y; + } + else { + teOptions.doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, style); + } + } + } + + function escapeRegExp (string) { + return string == null ? "" : string.toString().replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); + } + + function replaceAll (string, find, replace) { + return string == null ? "" : string.toString().replace(new RegExp(escapeRegExp(find), 'g'), replace); + } + + function trimLeft (string) { + return string == null ? "" : string.toString().replace(/^\s+/, ""); + } + + function trimRight (string) { + return string == null ? "" : string.toString().replace(/\s+$/, ""); + } + + function parseNumber (value) { + value = value || "0"; + value = replaceAll(value, defaults.numbers.html.thousandsSeparator, ''); + value = replaceAll(value, defaults.numbers.html.decimalMark, '.'); + + return typeof value === "number" || jQuery.isNumeric(value) !== false ? value : false; + } + + function parsePercent (value) { + if ( value.indexOf("%") > -1 ) { + value = parseNumber(value.replace(/%/g, "")); + if ( value !== false ) + value = value / 100; + } + else + value = false; + return value; + } + + function parseString (cell, rowIndex, colIndex) { + var result = ''; + + if ( cell !== null ) { + var $cell = $(cell); + var htmlData; + + if ( $cell[0].hasAttribute("data-tableexport-canvas") ) { + htmlData = ''; + } + else if ( $cell[0].hasAttribute("data-tableexport-value") ) { + htmlData = $cell.data("tableexport-value"); + htmlData = htmlData ? htmlData + '' : ''; + } + else { + htmlData = $cell.html(); + + if ( typeof defaults.onCellHtmlData === 'function' ) + htmlData = defaults.onCellHtmlData($cell, rowIndex, colIndex, htmlData); + else if ( htmlData !== '' ) { + var html = $.parseHTML(htmlData); + var inputidx = 0; + var selectidx = 0; + + htmlData = ''; + $.each(html, function () { + if ( $(this).is("input") ) + htmlData += $cell.find('input').eq(inputidx++).val(); + else if ( $(this).is("select") ) + htmlData += $cell.find('select option:selected').eq(selectidx++).text(); + else if ( $(this).is("br") ) + htmlData += "
    "; + else { + if ( typeof $(this).html() === 'undefined' ) + htmlData += $(this).text(); + else if ( jQuery().bootstrapTable === undefined || + ($(this).hasClass('filterControl') !== true && + $(cell).parents('.detail-view').length === 0) ) + htmlData += $(this).html(); + } + }); + } + } + + if ( defaults.htmlContent === true ) { + result = $.trim(htmlData); + } + else if ( htmlData && htmlData !== '' ) { + var cellFormat = $(cell).data("tableexport-cellformat"); + + if ( cellFormat !== '' ) { + var text = htmlData.replace(/\n/g, '\u2028').replace(/(<\s*br([^>]*)>)/gi, '\u2060'); + var obj = $('
    ').html(text).contents(); + var number = false; + text = ''; + + $.each(obj.text().split("\u2028"), function (i, v) { + if ( i > 0 ) + text += " "; + + if (defaults.preserve.leadingWS !== true) + v = trimLeft(v); + text += (defaults.preserve.trailingWS !== true) ? trimRight(v) : v; + }); + + $.each(text.split("\u2060"), function (i, v) { + if ( i > 0 ) + result += "\n"; + + if (defaults.preserve.leadingWS !== true) + v = trimLeft(v); + if (defaults.preserve.trailingWS !== true) + v = trimRight(v); + result += v.replace(/\u00AD/g, ""); // remove soft hyphens + }); + + result = result.replace(/\u00A0/g, " "); // replace nbsp's with spaces + + if ( defaults.type === 'json' || + (defaults.type === 'excel' && defaults.mso.fileFormat === 'xmlss') || + defaults.numbers.output === false ) { + number = parseNumber(result); + + if ( number !== false ) + result = Number(number); + } + else if ( defaults.numbers.html.decimalMark !== defaults.numbers.output.decimalMark || + defaults.numbers.html.thousandsSeparator !== defaults.numbers.output.thousandsSeparator ) { + number = parseNumber(result); + + if ( number !== false ) { + var frac = ("" + number.substr(number < 0 ? 1 : 0)).split('.'); + if ( frac.length === 1 ) + frac[1] = ""; + var mod = frac[0].length > 3 ? frac[0].length % 3 : 0; + + result = (number < 0 ? "-" : "") + + (defaults.numbers.output.thousandsSeparator ? ((mod ? frac[0].substr(0, mod) + defaults.numbers.output.thousandsSeparator : "") + frac[0].substr(mod).replace(/(\d{3})(?=\d)/g, "$1" + defaults.numbers.output.thousandsSeparator)) : frac[0]) + + (frac[1].length ? defaults.numbers.output.decimalMark + frac[1] : ""); + } + } + } + else + result = htmlData; + } + + if ( defaults.escape === true ) { + //noinspection JSDeprecatedSymbols + result = escape(result); + } + + if ( typeof defaults.onCellData === 'function' ) { + result = defaults.onCellData($cell, rowIndex, colIndex, result); + } + } + + return result; + } + + function preventInjection (string) { + if ( string.length > 0 && defaults.preventInjection === true ) { + var chars = "=+-@"; + if ( chars.indexOf(string.charAt(0)) >= 0 ) + return ( "'" + string ); + } + return string; + } + + //noinspection JSUnusedLocalSymbols + function hyphenate (a, b, c) { + return b + "-" + c.toLowerCase(); + } + + function rgb2array (rgb_string, default_result) { + var re = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/; + var bits = re.exec(rgb_string); + var result = default_result; + if ( bits ) + result = [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])]; + return result; + } + + function getCellStyles (cell) { + var a = getStyle(cell, 'text-align'); + var fw = getStyle(cell, 'font-weight'); + var fs = getStyle(cell, 'font-style'); + var f = ''; + if ( a === 'start' ) + a = getStyle(cell, 'direction') === 'rtl' ? 'right' : 'left'; + if ( fw >= 700 ) + f = 'bold'; + if ( fs === 'italic' ) + f += fs; + if ( f === '' ) + f = 'normal'; + + var result = { + style: { + align: a, + bcolor: rgb2array(getStyle(cell, 'background-color'), [255, 255, 255]), + color: rgb2array(getStyle(cell, 'color'), [0, 0, 0]), + fstyle: f + }, + colspan: getColspan (cell), + rowspan: getRowspan (cell) + }; + + if ( cell !== null ) { + var r = cell.getBoundingClientRect(); + result.rect = { + width: r.width, + height: r.height + }; + } + + return result; + } + + function getColspan (cell) { + var result = $(cell).data("tableexport-colspan"); + if ( typeof result === 'undefined' && $(cell).is("[colspan]") ) + result = $(cell).attr('colspan'); + + return (parseInt(result) || 0); + } + + function getRowspan (cell) { + var result = $(cell).data("tableexport-rowspan"); + if ( typeof result === 'undefined' && $(cell).is("[rowspan]") ) + result = $(cell).attr('rowspan'); + + return (parseInt(result) || 0); + } + + // get computed style property + function getStyle (target, prop) { + try { + if ( window.getComputedStyle ) { // gecko and webkit + prop = prop.replace(/([a-z])([A-Z])/, hyphenate); // requires hyphenated, not camel + return window.getComputedStyle(target, null).getPropertyValue(prop); + } + if ( target.currentStyle ) { // ie + return target.currentStyle[prop]; + } + return target.style[prop]; + } + catch (e) { + } + return ""; + } + + function getUnitValue (parent, value, unit) { + var baseline = 100; // any number serves + + var temp = document.createElement("div"); // create temporary element + temp.style.overflow = "hidden"; // in case baseline is set too low + temp.style.visibility = "hidden"; // no need to show it + + parent.appendChild(temp); // insert it into the parent for em, ex and % + + temp.style.width = baseline + unit; + var factor = baseline / temp.offsetWidth; + + parent.removeChild(temp); // clean up + + return (value * factor); + } + + function getPropertyUnitValue (target, prop, unit) { + var value = getStyle(target, prop); // get the computed style value + + var numeric = value.match(/\d+/); // get the numeric component + if ( numeric !== null ) { + numeric = numeric[0]; // get the string + + return getUnitValue(target.parentElement, numeric, unit); + } + return 0; + } + + function jx_Workbook () { + if ( !(this instanceof jx_Workbook) ) { + //noinspection JSPotentiallyInvalidConstructorUsage + return new jx_Workbook(); + } + this.SheetNames = []; + this.Sheets = {}; + } + + function jx_s2ab (s) { + var buf = new ArrayBuffer(s.length); + var view = new Uint8Array(buf); + for ( var i = 0; i !== s.length; ++i ) view[i] = s.charCodeAt(i) & 0xFF; + return buf; + } + + function jx_datenum (v, date1904) { + if ( date1904 ) v += 1462; + var epoch = Date.parse(v); + return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000); + } + + function jx_createSheet (data) { + var ws = {}; + var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}}; + for ( var R = 0; R !== data.length; ++R ) { + for ( var C = 0; C !== data[R].length; ++C ) { + if ( range.s.r > R ) range.s.r = R; + if ( range.s.c > C ) range.s.c = C; + if ( range.e.r < R ) range.e.r = R; + if ( range.e.c < C ) range.e.c = C; + var cell = {v: data[R][C]}; + if ( cell.v === null ) continue; + var cell_ref = XLSX.utils.encode_cell({c: C, r: R}); + + if ( typeof cell.v === 'number' ) cell.t = 'n'; + else if ( typeof cell.v === 'boolean' ) cell.t = 'b'; + else if ( cell.v instanceof Date ) { + cell.t = 'n'; + cell.z = XLSX.SSF._table[14]; + cell.v = jx_datenum(cell.v); + } + else cell.t = 's'; + ws[cell_ref] = cell; + } + } + + if ( range.s.c < 10000000 ) ws['!ref'] = XLSX.utils.encode_range(range); + return ws; + } + + function strHashCode (str) { + var hash = 0, i, chr, len; + if ( str.length === 0 ) return hash; + for ( i = 0, len = str.length; i < len; i++ ) { + chr = str.charCodeAt(i); + hash = ((hash << 5) - hash) + chr; + hash |= 0; // Convert to 32bit integer + } + return hash; + } + + function downloadFile (filename, header, data) { + var ua = window.navigator.userAgent; + if ( filename !== false && window.navigator.msSaveOrOpenBlob ) { + //noinspection JSUnresolvedFunction + window.navigator.msSaveOrOpenBlob(new Blob([data]), filename); + } + else if ( filename !== false && (ua.indexOf("MSIE ") > 0 || !!ua.match(/Trident.*rv\:11\./)) ) { + // Internet Explorer (<= 9) workaround by Darryl (https://github.com/dawiong/tableExport.jquery.plugin) + // based on sampopes answer on http://stackoverflow.com/questions/22317951 + // ! Not working for json and pdf format ! + var frame = document.createElement("iframe"); + + if ( frame ) { + document.body.appendChild(frame); + frame.setAttribute("style", "display:none"); + frame.contentDocument.open("txt/plain", "replace"); + frame.contentDocument.write(data); + frame.contentDocument.close(); + frame.contentDocument.focus(); + + var extension = filename.substr((filename.lastIndexOf('.') +1)); + switch(extension) { + case 'doc': case 'json': case 'png': case 'pdf': case 'xls': case 'xlsx': + filename += ".txt"; + break; + } + frame.contentDocument.execCommand("SaveAs", true, filename); + document.body.removeChild(frame); + } + } + else { + var DownloadLink = document.createElement('a'); + + if ( DownloadLink ) { + var blobUrl = null; + + DownloadLink.style.display = 'none'; + if ( filename !== false ) + DownloadLink.download = filename; + else + DownloadLink.target = '_blank'; + + if ( typeof data === 'object' ) { + window.URL = window.URL || window.webkitURL; + var binaryData = []; + binaryData.push(data); + blobUrl = window.URL.createObjectURL(new Blob(binaryData, {type: header})); + DownloadLink.href = blobUrl; + } + else if ( header.toLowerCase().indexOf("base64,") >= 0 ) + DownloadLink.href = header + base64encode(data); + else + DownloadLink.href = header + encodeURIComponent(data); + + document.body.appendChild(DownloadLink); + + if ( document.createEvent ) { + if ( DownloadEvt === null ) + DownloadEvt = document.createEvent('MouseEvents'); + + DownloadEvt.initEvent('click', true, false); + DownloadLink.dispatchEvent(DownloadEvt); + } + else if ( document.createEventObject ) + DownloadLink.fireEvent('onclick'); + else if ( typeof DownloadLink.onclick === 'function' ) + DownloadLink.onclick(); + + setTimeout(function(){ + if ( blobUrl ) + window.URL.revokeObjectURL(blobUrl); + document.body.removeChild(DownloadLink); + }, 100); + } + } + } + + function utf8Encode (text) { + if (typeof text === 'string') { + text = text.replace(/\x0d\x0a/g, "\x0a"); + var utftext = ""; + for ( var n = 0; n < text.length; n++ ) { + var c = text.charCodeAt(n); + if ( c < 128 ) { + utftext += String.fromCharCode(c); + } + else if ( (c > 127) && (c < 2048) ) { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); + } + else { + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); + } + } + return utftext; + } + return text; + } + + function base64encode (input) { + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var output = ""; + var i = 0; + input = utf8Encode(input); + while ( i < input.length ) { + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + if ( isNaN(chr2) ) { + enc3 = enc4 = 64; + } else if ( isNaN(chr3) ) { + enc4 = 64; + } + output = output + + keyStr.charAt(enc1) + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + keyStr.charAt(enc4); + } + return output; + } + + return this; + } +})(jQuery); diff --git a/Bootstrap.Admin/wwwroot/lib/tablexport/tableExport.min.js b/Bootstrap.Admin/wwwroot/lib/tablexport/tableExport.min.js new file mode 100644 index 00000000..3ce75422 --- /dev/null +++ b/Bootstrap.Admin/wwwroot/lib/tablexport/tableExport.min.js @@ -0,0 +1,84 @@ +/* + tableExport.jquery.plugin + + Version 1.10.1 + + Copyright (c) 2015-2018 hhurz, https://github.com/hhurz + + Original Work Copyright (c) 2014 Giri Raj + + Licensed under the MIT License +*/ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,l,u){c instanceof String&&(c=String(c));for(var w=c.length,x=0;xf&&"undefined"!==typeof R[f]&&-1!==c.inArray(R[f],a.ignoreColumn))&&(g=!0):g=!0;return g}function D(b,d,f,g,h){if("function"===typeof h){var k=!1;"function"===typeof a.onIgnoreRow&&(k=a.onIgnoreRow(c(b),f));if(!1===k&&-1===c.inArray(f,a.ignoreRow)&&-1===c.inArray(f-g,a.ignoreRow)&&Q(c(b))){var y=x(c(b),d),q=0;y.each(function(b){var d=c(this),a,g=S(this),k=T(this);c.each(F,function(){if(f>=this.s.r&& +f<=this.e.r&&q>=this.s.c&&q<=this.e.c)for(a=0;a<=this.e.c-this.s.c;++a)h(null,f,q++)});if(!1===Fa(d,y.length,b)){if(k||g)g=g||1,F.push({s:{r:f,c:q},e:{r:f+(k||1)-1,c:q+g-1}});h(this,f,q++)}if(g)for(a=0;a=this.s.r&&f<=this.e.r&&q>=this.s.c&&q<=this.e.c)for(aa=0;aa<=this.e.c-this.s.c;++aa)h(null,f,q++)})}}}function pa(b,d,a,c){if("undefined"!==typeof c.images&&(a=c.images[a],"undefined"!==typeof a)){var h=b.width/b.height,f=d.width/d.height,g=b.width, +q=b.height,e=19.049976/25.4,l=0;f<=h?(q=Math.min(b.height,d.height),g=d.width*q/d.height):f>h&&(g=Math.min(b.width,d.width),q=d.height*g/d.width);g*=e;q*=e;qb.textPos.x&&g+l>b.textPos.x+ +b.width&&(0<=".,!%*;:=-".indexOf(e.charAt(0))&&(m=e.charAt(0),l=f.doc.getStringUnitWidth(m)*f.doc.internal.getFontSize(),g+l<=b.textPos.x+b.width&&(f.doc.autoTableText(m,g,h,k),e=e.substring(1,e.length)),l=f.doc.getStringUnitWidth(e)*f.doc.internal.getFontSize()),g=b.textPos.x,h+=f.doc.internal.getFontSize());if("visible"!==b.styles.overflow)for(;e.length&&g+l>b.textPos.x+b.width;)e=e.substring(0,e.length-1),l=f.doc.getStringUnitWidth(e)*f.doc.internal.getFontSize();f.doc.autoTableText(e,g,h,k);g+= +l}if(y||q)c(d).is("b")?y=!1:c(d).is("i")&&(q=!1),f.doc.setFontType(y||q?y?"bold":"italic":"normal");d=d.nextSibling}b.textPos.x=g;b.textPos.y=h}else f.doc.autoTableText(b.text,b.textPos.x,b.textPos.y,k)}}function da(b,a,c){return null==b?"":b.toString().replace(new RegExp(null==a?"":a.toString().replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),c)}function ha(b){return null==b?"":b.toString().replace(/^\s+/,"")}function ia(b){return null==b?"":b.toString().replace(/\s+$/,"")}function ja(b){b=da(b|| +"0",a.numbers.html.thousandsSeparator,"");b=da(b,a.numbers.html.decimalMark,".");return"number"===typeof b||!1!==jQuery.isNumeric(b)?b:!1}function Ha(b){-1]*)>)/gi,"\u2060"),n=c("
    ").html(m).contents();e=!1;m="";c.each(n.text().split("\u2028"),function(b,d){0e?1:0)).split(".");1===n.length&&(n[1]="");var p=3e?"-":"")+(a.numbers.output.thousandsSeparator?(p?n[0].substr(0,p)+a.numbers.output.thousandsSeparator:"")+n[0].substr(p).replace(/(\d{3})(?=\d)/g, +"$1"+a.numbers.output.thousandsSeparator):n[0])+(n[1].length?a.numbers.output.decimalMark+n[1]:"")}}else g=k;!0===a.escape&&(g=escape(g));"function"===typeof a.onCellData&&(g=a.onCellData(h,d,f,g))}return g}function wa(b){return 0g&&(c.s.r=g);c.s.c>h&& +(c.s.c=h);c.e.rc.s.c&&(a["!ref"]=XLSX.utils.encode_range(c));return a}function ta(b){var a=0,c;if(0===b.length)return a;var g=0;for(c=b.length;gk?h+=String.fromCharCode(k):(127k?h+=String.fromCharCode(k>>6|192):(h+=String.fromCharCode(k>>12|224),h+=String.fromCharCode(k>>6&63|128)),h+=String.fromCharCode(k&63|128))}a=h}for(;g>2;e=(e&3)<<4|h>>4;var q=(h&15)<<2|b>>6;var l=b&63;isNaN(h)?q=l=64:isNaN(b)&&(l=64);c=c+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(k)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(q)+ +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l)}return c}var a={csvEnclosure:'"',csvSeparator:",",csvUseBOM:!0,displayTableName:!1,escape:!1,exportHiddenCells:!1,fileName:"tableExport",htmlContent:!1,ignoreColumn:[],ignoreRow:[],jsonScope:"all",jspdf:{orientation:"p",unit:"pt",format:"a4",margins:{left:20,right:10,top:10,bottom:10},onDocCreated:null,autotable:{styles:{cellPadding:2,rowHeight:12,fontSize:8,fillColor:255,textColor:50,fontStyle:"normal",overflow:"ellipsize", +halign:"inherit",valign:"middle"},headerStyles:{fillColor:[52,73,94],textColor:255,fontStyle:"bold",halign:"inherit",valign:"middle"},alternateRowStyles:{fillColor:245},tableExport:{doc:null,onAfterAutotable:null,onBeforeAutotable:null,onAutotableText:null,onTable:null,outputImages:!0}}},mso:{fileFormat:"xlshtml",onMsoNumberFormat:null,pageFormat:"a4",pageOrientation:"portrait",rtl:!1,styles:[],worksheetName:""},numbers:{html:{decimalMark:".",thousandsSeparator:","},output:{decimalMark:".",thousandsSeparator:","}}, +onCellData:null,onCellHtmlData:null,onIgnoreRow:null,outputMode:"file",pdfmake:{enabled:!1,docDefinition:{pageOrientation:"portrait",defaultStyle:{font:"Roboto"}},fonts:{}},preserve:{leadingWS:!1,trailingWS:!1},preventInjection:!0,tbodySelector:"tr",tfootSelector:"tr",theadSelector:"tr",tableName:"Table",type:"csv"},L={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88, +147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576, +756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]},v=this,ea=null,r=[],t=[],n=0,p="",R=[],F=[],I=[],U=!1;c.extend(!0,a,l);"xlsx"===a.type&&(a.mso.fileFormat=a.type,a.type="excel");"undefined"!==typeof a.excelFileFormat&&"undefined"===a.mso.fileFormat&&(a.mso.fileFormat=a.excelFileFormat);"undefined"!==typeof a.excelPageFormat&&"undefined"===a.mso.pageFormat&&(a.mso.pageFormat=a.excelPageFormat);"undefined"!==typeof a.excelPageOrientation&& +"undefined"===a.mso.pageOrientation&&(a.mso.pageOrientation=a.excelPageOrientation);"undefined"!==typeof a.excelRTL&&"undefined"===a.mso.rtl&&(a.mso.rtl=a.excelRTL);"undefined"!==typeof a.excelstyles&&"undefined"===a.mso.styles&&(a.mso.styles=a.excelstyles);"undefined"!==typeof a.onMsoNumberFormat&&"undefined"===a.mso.onMsoNumberFormat&&(a.mso.onMsoNumberFormat=a.onMsoNumberFormat);"undefined"!==typeof a.worksheetName&&"undefined"===a.mso.worksheetName&&(a.mso.worksheetName=a.worksheetName);a.mso.pageOrientation= +"l"===a.mso.pageOrientation.substr(0,1)?"landscape":"portrait";R=P(v);if("csv"===a.type||"tsv"===a.type||"txt"===a.type){var M="",X=0;F=[];n=0;var la=function(b,d,f){b.each(function(){p="";D(this,d,n,f+b.length,function(b,c,d){var h=p,k="";if(null!==b)if(b=B(b,c,d),c=null===b||""===b?"":b.toString(),"tsv"===a.type)b instanceof Date&&b.toLocaleString(),k=da(c,"\t"," ");else if(b instanceof Date)k=a.csvEnclosure+b.toLocaleString()+a.csvEnclosure;else if(k=wa(c),k=da(k,a.csvEnclosure,a.csvEnclosure+ +a.csvEnclosure),0<=k.indexOf(a.csvSeparator)||/[\r\n ]/g.test(k))k=a.csvEnclosure+k+a.csvEnclosure;p=h+(k+("tsv"===a.type?"\t":a.csvSeparator))});p=c.trim(p).substring(0,p.length-1);0"+ +B(a,c,f)+""});n++});N+="";var za=1;t=w(c(v));c(t).each(function(){var a=1;p="";D(this,"td,th",n,r.length+t.length,function(b,c,g){p+=""+B(b,c,g)+"";a++});0"!==p&&(N+=''+p+"",za++);n++});N+="";if("string"===a.outputMode)return N;if("base64"===a.outputMode)return J(N);try{C=new Blob([N],{type:"application/xml;charset=utf-8"}),saveAs(C,a.fileName+".xml")}catch(b){G(a.fileName+ +".xml","data:application/xml;charset=utf-8;base64,",N)}}else if("excel"===a.type&&"xmlss"===a.mso.fileFormat){var na=[],E=[];c(v).filter(function(){return Q(c(this))}).each(function(){function b(a,b,d){var h=[];c(a).each(function(){var b=0,k=0;p="";D(this,"td,th",n,d+a.length,function(a,d,f){if(null!==a){var g="";d=B(a,d,f);f="String";if(!1!==jQuery.isNumeric(d))f="Number";else{var e=Ha(d);!1!==e&&(d=e,f="Number",g+=' ss:StyleID="pct1"')}"Number"!==f&&(d=d.replace(/\n/g,"
    "));e=S(a);a=T(a);c.each(h, +function(){if(n>=this.s.r&&n<=this.e.r&&k>=this.s.c&&k<=this.e.c)for(var a=0;a<=this.e.c-this.s.c;++a)k++,b++});if(a||e)a=a||1,e=e||1,h.push({s:{r:n,c:k},e:{r:n+a-1,c:k+e-1}});1'+c("
    ").text(d).html()+"\r";k++}});0\r'+p+"\r");n++});return a.length}var d=c(this), +f="";"string"===typeof a.mso.worksheetName&&a.mso.worksheetName.length?f=a.mso.worksheetName+" "+(E.length+1):"undefined"!==typeof a.mso.worksheetName[E.length]&&(f=a.mso.worksheetName[E.length]);f.length||(f=d.find("caption").text()||"");f.length||(f="Table "+(E.length+1));f=c.trim(f.replace(/[\\\/[\]*:?'"]/g,"").substring(0,31));E.push(c("
    ").text(f).html());!1===a.exportHiddenCells&&(I=d.find("tr, th, td").filter(":hidden"),U=0\r";var g=b(u(d),"th,td",g); +b(w(d),"td,th",g);H+="\r";na.push(H)});l={};for(var A={},m,O,W=0,aa=E.length;W\r\r\r\r '+ +(new Date).toISOString()+'\r\r\r \r\r\r 9000\r 13860\r 0\r 0\r False\r False\r\r\r \r \r \r\r'; +for(A=0;A\r'+na[A],l=a.mso.rtl?l+'\r\r\r':l+'\r',l+="\r";l+="\r";if("string"===a.outputMode)return l;if("base64"===a.outputMode)return J(l);try{C=new Blob([l],{type:"application/xml;charset=utf-8"}),saveAs(C,a.fileName+ +".xml")}catch(b){G(a.fileName+".xml","data:application/xml;charset=utf-8;base64,",l)}}else if("excel"===a.type&&"xlsx"===a.mso.fileFormat){var Aa=[],oa=[];n=0;t=u(c(v));t.push.apply(t,w(c(v)));c(t).each(function(){var b=[];D(this,"th,td",n,t.length,function(d,f,g){if("undefined"!==typeof d&&null!==d){g=B(d,f,g);f=S(d);d=T(d);c.each(oa,function(){if(n>=this.s.r&&n<=this.e.r&&b.length>=this.s.c&&b.length<=this.e.c)for(var a=0;a<=this.e.c-this.s.c;++a)b.push(null)});if(d||f)f=f||1,oa.push({s:{r:n,c:b.length}, +e:{r:n+(d||1)-1,c:b.length+f-1}});"function"!==typeof a.onCellData&&""!==g&&g===+g&&(g=+g);b.push(""!==g?g:null);if(f)for(d=0;d";r=u(b);c(r).each(function(){p="";D(this,"th,td",n,r.length,function(b,f,g){if(null!==b){var d="";p+=""}});0"+p+"");n++});H+="";t=w(b);c(t).each(function(){var b=c(this);p="";D(this,"td,th",n,r.length+t.length,function(d,e,h){if(null!==d){var k=B(d,e,h),g="",f=c(d).data("tableexport-msonumberformat");"undefined"===typeof f&&"function"===typeof a.mso.onMsoNumberFormat&&(f=a.mso.onMsoNumberFormat(d,e,h));"undefined"!==typeof f&&""!==f&&(g="style=\"mso-number-format:'"+f+"'");for(var l in a.mso.styles)a.mso.styles.hasOwnProperty(l)&& +(f=c(d).css(a.mso.styles[l]),""===f&&(f=b.css(a.mso.styles[l])),""!==f&&"0px none rgb(0, 0, 0)"!==f&&"rgba(0, 0, 0, 0)"!==f&&(g+=""===g?'style="':";",g+=a.mso.styles[l]+":"+f));p+=""));p+=">"+k+""}});0"+p+"");n++});a.displayTableName&&(H+=""+B(c("

    "+a.tableName+"

    "))+ +"");H+=""});m=''+('')+"";"excel"===l&&(m+="\x3c!--[if gte mso 9]>",m+="",m+="",m+="",m+="",m+="",m+=Y,m+="",m+="",m+="",a.mso.rtl&&(m+=""),m+="", +m+="",m+="",m+="",m+="",m+="";m+="@page { size:"+a.mso.pageOrientation+"; mso-page-orientation:"+a.mso.pageOrientation+"; }";m+="@page Section1 {size:"+L[a.mso.pageFormat][0]+"pt "+L[a.mso.pageFormat][1]+"pt";m+="; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}";m+="div.Section1 {page:Section1;}";m+="@page Section2 {size:"+L[a.mso.pageFormat][1]+"pt "+L[a.mso.pageFormat][0]+ +"pt";m+=";mso-page-orientation:"+a.mso.pageOrientation+";margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}";m+="div.Section2 {page:Section2;}";m+="br {mso-data-placement:same-cell;}";m+="";m+="";m+="";m+='
    ';m+=H;m+="
    ";m+="";m+="";if("string"===a.outputMode)return m;if("base64"===a.outputMode)return J(m);try{C=new Blob([m],{type:"application/vnd.ms-"+ +a.type}),saveAs(C,a.fileName+"."+A)}catch(b){G(a.fileName+"."+A,"data:application/vnd.ms-"+l+";base64,",m)}}else if("png"===a.type)html2canvas(c(v)[0]).then(function(b){b=b.toDataURL();for(var c=atob(b.substring(22)),e=new ArrayBuffer(c.length),g=new Uint8Array(e),h=0;hDa){a>L.a0[0]&&(fa="a0",Z= +"l");for(var d in L)L.hasOwnProperty(d)&&L[d][1]>a&&(fa=d,Z="l",L[d][0]>a&&(Z="p"));Da=a}}});a.jspdf.format=""===fa?"a4":fa;a.jspdf.orientation=""===Z?"w":Z}if(null==e.doc&&(e.doc=new jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format),"function"===typeof a.jspdf.onDocCreated))a.jspdf.onDocCreated(e.doc);!0===e.outputImages&&(e.images={});"undefined"!==typeof e.images&&(c(v).filter(function(){return Q(c(this))}).each(function(){var b=0;F=[];!1===a.exportHiddenCells&&(I=c(this).find("tr, th, td").filter(":hidden"), +U=0a.styles.rowHeight&&(a.styles.rowHeight=k)}a.styles.halign= +"inherit"===d.headerStyles.halign?"center":d.headerStyles.halign;a.styles.valign=d.headerStyles.valign;"undefined"!==typeof h.style&&!0!==h.style.hidden&&("inherit"===d.headerStyles.halign&&(a.styles.halign=h.style.align),"inherit"===d.styles.fillColor&&(a.styles.fillColor=h.style.bcolor),"inherit"===d.styles.textColor&&(a.styles.textColor=h.style.color),"inherit"===d.styles.fontStyle&&(a.styles.fontStyle=h.style.fstyle))}});"function"!==typeof d.createdCell&&(d.createdCell=function(a,b){b=e.teCells[b.row.index+ +":"+b.column.dataKey];a.styles.halign="inherit"===d.styles.halign?"center":d.styles.halign;a.styles.valign=d.styles.valign;"undefined"!==typeof b&&"undefined"!==typeof b.style&&!0!==b.style.hidden&&("inherit"===d.styles.halign&&(a.styles.halign=b.style.align),"inherit"===d.styles.fillColor&&(a.styles.fillColor=b.style.bcolor),"inherit"===d.styles.textColor&&(a.styles.textColor=b.style.color),"inherit"===d.styles.fontStyle&&(a.styles.fontStyle=b.style.fstyle))});"function"!==typeof d.drawHeaderCell&& +(d.drawHeaderCell=function(a,b){var c=e.columns[b.column.dataKey];return(!0!==c.style.hasOwnProperty("hidden")||!0!==c.style.hidden)&&0<=c.rowIndex?ra(a,b,c):!1});"function"!==typeof d.drawCell&&(d.drawCell=function(a,b){var d=e.teCells[b.row.index+":"+b.column.dataKey];if(!0!==("undefined"!==typeof d&&"undefined"!==typeof d.elements&&d.elements.length&&d.elements[0].hasAttribute("data-tableexport-canvas"))){if(ra(a,b,d))if(e.doc.rect(a.x,a.y,a.width,a.height,a.styles.fillStyle),"undefined"!==typeof d&& +"undefined"!==typeof d.elements&&d.elements.length){b=a.height/d.rect.height;if(b>e.dh||"undefined"===typeof e.dh)e.dh=b;e.dw=a.width/d.rect.width;b=a.textPos.y;ua(a,d.elements,e);a.textPos.y=b;va(a,d.elements,e)}else va(a,{},e)}else d=d.elements[0],b=c(d).attr("data-tableexport-canvas"),pa(a,d,b,e);return!1});e.headerrows=[];r=u(c(this));c(r).each(function(){b=0;e.headerrows[n]=[];D(this,"th,td",n,r.length,function(a,c,d){var f=xa(a);f.title=B(a,c,d);f.key=b++;f.rowIndex=n;e.headerrows[n].push(f)}); +n++});if(0