Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tableexport

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tableexport - npm Package Compare versions

Comparing version 3.2.0 to 3.2.2

2

bower.json
{
"name": "tableexport.js",
"version": "3.2.0",
"version": "3.2.2",
"authors": [

@@ -5,0 +5,0 @@ "clarketm <travis.m.clarke@gmail.com>"

/*!
* TableExport.js v3.2.0 (http://www.clarketravis.com)
* TableExport.js v3.2.2 (http://www.clarketravis.com)
* Copyright 2015 Travis Clarke

@@ -18,2 +18,3 @@ * Licensed under the MIT license

ignoreCols = settings.ignoreCols instanceof Array ? settings.ignoreCols : [settings.ignoreCols],
ignoreCSS = settings.ignoreCSS instanceof Array ? settings.ignoreCSS.join(", ") : settings.ignoreCSS,
bootstrapClass, bootstrapTheme, bootstrapSpacing;

@@ -40,6 +41,7 @@

var dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return [$cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
console.log($(val).is(ignoreCSS));
return $(val).text();

@@ -62,6 +64,6 @@ }).get()];

dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return $cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
return $(val).text();

@@ -84,6 +86,6 @@ }).get().join(colD);

dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return $cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
return $(val).text();

@@ -106,6 +108,6 @@ }).get().join(colD);

dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return $cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
return $(val).text();

@@ -144,10 +146,12 @@ }).get().join(colD);

$("button[data-fileblob]").on("click", function () {
var object = $(this).data("fileblob"),
data = object.data,
fileName = object.fileName,
mimeType = object.mimeType,
fileExtension = object.fileExtension;
export2file(data, mimeType, fileName, fileExtension);
});
$("button[data-fileblob]")
.off("click")
.on("click", function () {
var object = $(this).data("fileblob"),
data = object.data,
fileName = object.fileName,
mimeType = object.mimeType,
fileExtension = object.fileExtension;
export2file(data, mimeType, fileName, fileExtension);
});
};

@@ -164,3 +168,4 @@

ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file (default: null)
ignoreCols: null // (Number, Number[]), column indices to exclude from the exported file (default: null)
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file (default: null)
ignoreCSS: ".tableexport-ignore" // (selector, selector[]), selector(s) to exclude from the exported file (default: ".tableexport-ignore")
};

@@ -167,0 +172,0 @@

/*!
* TableExport.js v3.2.0 (http://www.clarketravis.com)
* TableExport.js v3.2.2 (http://www.clarketravis.com)
* Copyright 2015 Travis Clarke
* Licensed under the MIT license
*/
!function(t,e){function n(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.fn.tableExport.entityMap[t]})}function o(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5}function a(t,e){for(var n={},a={s:{c:1e7,r:1e7},e:{c:0,r:0}},r=0;r!=t.length;++r)for(var i=0;i!=t[r].length;++i){a.s.r>r&&(a.s.r=r),a.s.c>i&&(a.s.c=i),a.e.r<r&&(a.e.r=r),a.e.c<i&&(a.e.c=i);var f={v:t[r][i]};if(null!=f.v){var l=XLSX.utils.encode_cell({c:i,r:r});"number"==typeof f.v?f.t="n":"boolean"==typeof f.v?f.t="b":f.v instanceof Date?(f.t="n",f.z=XLSX.SSF._table[14],f.v=o(f.v)):f.t="s",n[l]=f}}return a.s.c<1e7&&(n["!ref"]=XLSX.utils.encode_range(a)),n}function r(){return this instanceof r?(this.SheetNames=[],void(this.Sheets={})):new r}function i(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),o=0;o!=t.length;++o)n[o]=255&t.charCodeAt(o);return e}function f(t,e,n,o){if(".xlsx"===o){var f=new r,s=a(t);f.SheetNames.push(n),f.Sheets[n]=s;var x={bookType:"xlsx",bookSST:!1,type:"binary"},p=XLSX.write(f,x);t=i(p)}saveAs(new Blob([t],{type:e+";"+l.fn.tableExport.charset}),n+o)}var l=t.jQuery;l.fn.tableExport=function(t){var e,o,a,r=l.extend({},l.fn.tableExport.defaults,t),i=l.fn.tableExport.rowDel,s=r.ignoreRows instanceof Array?r.ignoreRows:[r.ignoreRows],x=r.ignoreCols instanceof Array?r.ignoreCols:[r.ignoreCols];r.bootstrap?(e=l.fn.tableExport.bootstrap[0]+" ",o=l.fn.tableExport.bootstrap[1]+" ",a=l.fn.tableExport.bootstrap[2]+" "):(e=l.fn.tableExport.defaultButton+" ",o=a=""),this.each(function(){function t(t){var e=p.find("caption:not(.head)");e.length?e.append(t):p.prepend('<caption class="'+a+r.position+'">'+t+"</caption>")}function f(n,a,r){var i="<button data-fileblob='"+n+"' class='"+e+o+r+"'>"+a+"</button>";t(i)}var p=l(this),u=p.find("tbody").find("tr"),u=r.headings?u.add(p.find("thead>tr")):u,u=r.footers?u.add(p.find("tfoor>tr")):u,b=r.headings?p.find("thead>tr").length:0,d="id"===r.fileName?p.attr("id")?p.attr("id"):l.fn.tableExport.defaultFileName:r.fileName,c={xlsx:function(t,e){var o=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return[n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get()]}}).get(),a=n(JSON.stringify({data:o,fileName:e,mimeType:l.fn.tableExport.xlsx.mimeType,fileExtension:l.fn.tableExport.xlsx.fileExtension})),r=l.fn.tableExport.xlsx.buttonContent,i=l.fn.tableExport.xlsx.defaultClass;f(a,r,i)},xls:function(t,e){var o=l.fn.tableExport.xls.separator,a=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get().join(o)}}).get().join(t),r=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.xls.mimeType,fileExtension:l.fn.tableExport.xls.fileExtension})),i=l.fn.tableExport.xls.buttonContent,p=l.fn.tableExport.xls.defaultClass;f(r,i,p)},csv:function(t,e){var o=l.fn.tableExport.csv.separator,a=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get().join(o)}}).get().join(t),r=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.csv.mimeType,fileExtension:l.fn.tableExport.csv.fileExtension})),i=l.fn.tableExport.csv.buttonContent,p=l.fn.tableExport.csv.defaultClass;f(r,i,p)},txt:function(t,e){var o=l.fn.tableExport.txt.separator,a=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get().join(o)}}).get().join(t),r=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.txt.mimeType,fileExtension:l.fn.tableExport.txt.fileExtension})),i=l.fn.tableExport.txt.buttonContent,p=l.fn.tableExport.txt.defaultClass;f(r,i,p)}};r.formats.forEach(function(t){c[t](i,d)})}),l("button[data-fileblob]").on("click",function(){var t=l(this).data("fileblob"),e=t.data,n=t.fileName,o=t.mimeType,a=t.fileExtension;f(e,o,n,a)})},l.fn.tableExport.defaults={headings:!0,footers:!0,formats:["xls","csv","txt"],fileName:"id",bootstrap:!0,position:"bottom",ignoreRows:null,ignoreCols:null},l.fn.tableExport.charset="charset=utf-8",l.fn.tableExport.xlsx={defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},l.fn.tableExport.xls={defaultClass:"xls",buttonContent:"Export to xls",separator:" ",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},l.fn.tableExport.csv={defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"application/csv",fileExtension:".csv"},l.fn.tableExport.txt={defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},l.fn.tableExport.defaultFileName="myDownload",l.fn.tableExport.defaultButton="button-default",l.fn.tableExport.bootstrap=["btn","btn-default","btn-toolbar"],l.fn.tableExport.rowDel="\r\n",l.fn.tableExport.entityMap={"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47"}}(window);
!function(t,e){function n(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.fn.tableExport.entityMap[t]})}function o(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5}function a(t,e){for(var n={},a={s:{c:1e7,r:1e7},e:{c:0,r:0}},i=0;i!=t.length;++i)for(var r=0;r!=t[i].length;++r){a.s.r>i&&(a.s.r=i),a.s.c>r&&(a.s.c=r),a.e.r<i&&(a.e.r=i),a.e.c<r&&(a.e.c=r);var f={v:t[i][r]};if(null!=f.v){var l=XLSX.utils.encode_cell({c:r,r:i});"number"==typeof f.v?f.t="n":"boolean"==typeof f.v?f.t="b":f.v instanceof Date?(f.t="n",f.z=XLSX.SSF._table[14],f.v=o(f.v)):f.t="s",n[l]=f}}return a.s.c<1e7&&(n["!ref"]=XLSX.utils.encode_range(a)),n}function i(){return this instanceof i?(this.SheetNames=[],void(this.Sheets={})):new i}function r(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),o=0;o!=t.length;++o)n[o]=255&t.charCodeAt(o);return e}function f(t,e,n,o){if(".xlsx"===o){var f=new i,s=a(t);f.SheetNames.push(n),f.Sheets[n]=s;var x={bookType:"xlsx",bookSST:!1,type:"binary"},p=XLSX.write(f,x);t=r(p)}saveAs(new Blob([t],{type:e+";"+l.fn.tableExport.charset}),n+o)}var l=t.jQuery;l.fn.tableExport=function(t){var e,o,a,i=l.extend({},l.fn.tableExport.defaults,t),r=l.fn.tableExport.rowDel,s=i.ignoreRows instanceof Array?i.ignoreRows:[i.ignoreRows],x=i.ignoreCols instanceof Array?i.ignoreCols:[i.ignoreCols],p=i.ignoreCSS instanceof Array?i.ignoreCSS.join(", "):i.ignoreCSS;i.bootstrap?(e=l.fn.tableExport.bootstrap[0]+" ",o=l.fn.tableExport.bootstrap[1]+" ",a=l.fn.tableExport.bootstrap[2]+" "):(e=l.fn.tableExport.defaultButton+" ",o=a=""),this.each(function(){function t(t){var e=u.find("caption:not(.head)");e.length?e.append(t):u.prepend('<caption class="'+a+i.position+'">'+t+"</caption>")}function f(n,a,i){var r="<button data-fileblob='"+n+"' class='"+e+o+i+"'>"+a+"</button>";t(r)}var u=l(this),b=u.find("tbody").find("tr"),b=i.headings?b.add(u.find("thead>tr")):b,b=i.footers?b.add(u.find("tfoor>tr")):b,d=i.headings?u.find("thead>tr").length:0,c="id"===i.fileName?u.attr("id")?u.attr("id"):l.fn.tableExport.defaultFileName:i.fileName,E={xlsx:function(t,e){var o=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return[n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:(console.log(l(e).is(p)),l(e).text())}).get()]}}).get(),a=n(JSON.stringify({data:o,fileName:e,mimeType:l.fn.tableExport.xlsx.mimeType,fileExtension:l.fn.tableExport.xlsx.fileExtension})),i=l.fn.tableExport.xlsx.buttonContent,r=l.fn.tableExport.xlsx.defaultClass;f(a,i,r)},xls:function(t,e){var o=l.fn.tableExport.xls.separator,a=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:l(e).text()}).get().join(o)}}).get().join(t),i=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.xls.mimeType,fileExtension:l.fn.tableExport.xls.fileExtension})),r=l.fn.tableExport.xls.buttonContent,u=l.fn.tableExport.xls.defaultClass;f(i,r,u)},csv:function(t,e){var o=l.fn.tableExport.csv.separator,a=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:l(e).text()}).get().join(o)}}).get().join(t),i=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.csv.mimeType,fileExtension:l.fn.tableExport.csv.fileExtension})),r=l.fn.tableExport.csv.buttonContent,u=l.fn.tableExport.csv.defaultClass;f(i,r,u)},txt:function(t,e){var o=l.fn.tableExport.txt.separator,a=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:l(e).text()}).get().join(o)}}).get().join(t),i=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.txt.mimeType,fileExtension:l.fn.tableExport.txt.fileExtension})),r=l.fn.tableExport.txt.buttonContent,u=l.fn.tableExport.txt.defaultClass;f(i,r,u)}};i.formats.forEach(function(t){E[t](r,c)})}),l("button[data-fileblob]").off("click").on("click",function(){var t=l(this).data("fileblob"),e=t.data,n=t.fileName,o=t.mimeType,a=t.fileExtension;f(e,o,n,a)})},l.fn.tableExport.defaults={headings:!0,footers:!0,formats:["xls","csv","txt"],fileName:"id",bootstrap:!0,position:"bottom",ignoreRows:null,ignoreCols:null,ignoreCSS:".tableexport-ignore"},l.fn.tableExport.charset="charset=utf-8",l.fn.tableExport.xlsx={defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},l.fn.tableExport.xls={defaultClass:"xls",buttonContent:"Export to xls",separator:" ",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},l.fn.tableExport.csv={defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"application/csv",fileExtension:".csv"},l.fn.tableExport.txt={defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},l.fn.tableExport.defaultFileName="myDownload",l.fn.tableExport.defaultButton="button-default",l.fn.tableExport.bootstrap=["btn","btn-default","btn-toolbar"],l.fn.tableExport.rowDel="\r\n",l.fn.tableExport.entityMap={"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47"}}(window);
{
"name": "tableexport",
"version": "3.2.0",
"version": "3.2.2",
"authors": [

@@ -25,2 +25,9 @@ "clarketm <travis.m.clarke@gmail.com>"

},
"repository": {
"type": "git",
"url": "https://github.com/clarketm/TableExport"
},
"bugs": {
"url": "https://github.com/clarketm/TableExport/issues"
},
"dependencies": {

@@ -27,0 +34,0 @@ "Blob": "*",

@@ -91,10 +91,11 @@ [![Build Status](https://travis-ci.org/clarketm/TableExport.svg?branch=master)](https://travis-ci.org/clarketm/TableExport)

$("table").tableExport({
headings: true, // (Boolean), display table headings (th/td elements) in the <thead>
footers: true, // (Boolean), display table footers (th/td elements) in the <tfoot>
formats: ["xls", "csv", "txt"], // (String[]), filetype(s) for the export
fileName: "id", // (id, String), filename for the downloaded file
bootstrap: true, // (Boolean), style buttons using bootstrap
position: "bottom", // (top, bottom), position of the caption element relative to table
ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file
ignoreCols: null // (Number, Number[]), column indices to exclude from the exported file
headings: true, // (Boolean), display table headings (th/td elements) in the <thead>
footers: true, // (Boolean), display table footers (th/td elements) in the <tfoot>
formats: ["xls", "csv", "txt"], // (String[]), filetype(s) for the export
fileName: "id", // (id, String), filename for the downloaded file
bootstrap: true, // (Boolean), style buttons using bootstrap
position: "bottom", // (top, bottom), position of the caption element relative to table
ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file
ignoreCSS: ".tableexport-ignore" // (selector, selector[]), selector(s) to exclude from the exported file
});

@@ -101,0 +102,0 @@ ```

/*!
* TableExport.js v3.2.0 (http://www.clarketravis.com)
* TableExport.js v3.2.2 (http://www.clarketravis.com)
* Copyright 2015 Travis Clarke

@@ -18,2 +18,3 @@ * Licensed under the MIT license

ignoreCols = settings.ignoreCols instanceof Array ? settings.ignoreCols : [settings.ignoreCols],
ignoreCSS = settings.ignoreCSS instanceof Array ? settings.ignoreCSS.join(", ") : settings.ignoreCSS,
bootstrapClass, bootstrapTheme, bootstrapSpacing;

@@ -40,6 +41,7 @@

var dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return [$cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
console.log($(val).is(ignoreCSS));
return $(val).text();

@@ -62,6 +64,6 @@ }).get()];

dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return $cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
return $(val).text();

@@ -84,6 +86,6 @@ }).get().join(colD);

dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return $cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
return $(val).text();

@@ -106,6 +108,6 @@ }).get().join(colD);

dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
var $cols = $(val).find('th, td');
return $cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i)) { return;}
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
return $(val).text();

@@ -144,10 +146,12 @@ }).get().join(colD);

$("button[data-fileblob]").on("click", function () {
var object = $(this).data("fileblob"),
data = object.data,
fileName = object.fileName,
mimeType = object.mimeType,
fileExtension = object.fileExtension;
export2file(data, mimeType, fileName, fileExtension);
});
$("button[data-fileblob]")
.off("click")
.on("click", function () {
var object = $(this).data("fileblob"),
data = object.data,
fileName = object.fileName,
mimeType = object.mimeType,
fileExtension = object.fileExtension;
export2file(data, mimeType, fileName, fileExtension);
});
};

@@ -164,3 +168,4 @@

ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file (default: null)
ignoreCols: null // (Number, Number[]), column indices to exclude from the exported file (default: null)
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file (default: null)
ignoreCSS: ".tableexport-ignore" // (selector, selector[]), selector(s) to exclude from the exported file (default: ".tableexport-ignore")
};

@@ -167,0 +172,0 @@

/*!
* TableExport.js v3.2.0 (http://www.clarketravis.com)
* TableExport.js v3.2.2 (http://www.clarketravis.com)
* Copyright 2015 Travis Clarke
* Licensed under the MIT license
*/
!function(t,e){function n(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.fn.tableExport.entityMap[t]})}function o(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5}function a(t,e){for(var n={},a={s:{c:1e7,r:1e7},e:{c:0,r:0}},r=0;r!=t.length;++r)for(var i=0;i!=t[r].length;++i){a.s.r>r&&(a.s.r=r),a.s.c>i&&(a.s.c=i),a.e.r<r&&(a.e.r=r),a.e.c<i&&(a.e.c=i);var f={v:t[r][i]};if(null!=f.v){var l=XLSX.utils.encode_cell({c:i,r:r});"number"==typeof f.v?f.t="n":"boolean"==typeof f.v?f.t="b":f.v instanceof Date?(f.t="n",f.z=XLSX.SSF._table[14],f.v=o(f.v)):f.t="s",n[l]=f}}return a.s.c<1e7&&(n["!ref"]=XLSX.utils.encode_range(a)),n}function r(){return this instanceof r?(this.SheetNames=[],void(this.Sheets={})):new r}function i(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),o=0;o!=t.length;++o)n[o]=255&t.charCodeAt(o);return e}function f(t,e,n,o){if(".xlsx"===o){var f=new r,s=a(t);f.SheetNames.push(n),f.Sheets[n]=s;var x={bookType:"xlsx",bookSST:!1,type:"binary"},p=XLSX.write(f,x);t=i(p)}saveAs(new Blob([t],{type:e+";"+l.fn.tableExport.charset}),n+o)}var l=t.jQuery;l.fn.tableExport=function(t){var e,o,a,r=l.extend({},l.fn.tableExport.defaults,t),i=l.fn.tableExport.rowDel,s=r.ignoreRows instanceof Array?r.ignoreRows:[r.ignoreRows],x=r.ignoreCols instanceof Array?r.ignoreCols:[r.ignoreCols];r.bootstrap?(e=l.fn.tableExport.bootstrap[0]+" ",o=l.fn.tableExport.bootstrap[1]+" ",a=l.fn.tableExport.bootstrap[2]+" "):(e=l.fn.tableExport.defaultButton+" ",o=a=""),this.each(function(){function t(t){var e=p.find("caption:not(.head)");e.length?e.append(t):p.prepend('<caption class="'+a+r.position+'">'+t+"</caption>")}function f(n,a,r){var i="<button data-fileblob='"+n+"' class='"+e+o+r+"'>"+a+"</button>";t(i)}var p=l(this),u=p.find("tbody").find("tr"),u=r.headings?u.add(p.find("thead>tr")):u,u=r.footers?u.add(p.find("tfoor>tr")):u,b=r.headings?p.find("thead>tr").length:0,d="id"===r.fileName?p.attr("id")?p.attr("id"):l.fn.tableExport.defaultFileName:r.fileName,c={xlsx:function(t,e){var o=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return[n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get()]}}).get(),a=n(JSON.stringify({data:o,fileName:e,mimeType:l.fn.tableExport.xlsx.mimeType,fileExtension:l.fn.tableExport.xlsx.fileExtension})),r=l.fn.tableExport.xlsx.buttonContent,i=l.fn.tableExport.xlsx.defaultClass;f(a,r,i)},xls:function(t,e){var o=l.fn.tableExport.xls.separator,a=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get().join(o)}}).get().join(t),r=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.xls.mimeType,fileExtension:l.fn.tableExport.xls.fileExtension})),i=l.fn.tableExport.xls.buttonContent,p=l.fn.tableExport.xls.defaultClass;f(r,i,p)},csv:function(t,e){var o=l.fn.tableExport.csv.separator,a=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get().join(o)}}).get().join(t),r=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.csv.mimeType,fileExtension:l.fn.tableExport.csv.fileExtension})),i=l.fn.tableExport.csv.buttonContent,p=l.fn.tableExport.csv.defaultClass;f(r,i,p)},txt:function(t,e){var o=l.fn.tableExport.txt.separator,a=u.map(function(t,e){if(!~s.indexOf(t-b)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)?void 0:l(e).text()}).get().join(o)}}).get().join(t),r=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.txt.mimeType,fileExtension:l.fn.tableExport.txt.fileExtension})),i=l.fn.tableExport.txt.buttonContent,p=l.fn.tableExport.txt.defaultClass;f(r,i,p)}};r.formats.forEach(function(t){c[t](i,d)})}),l("button[data-fileblob]").on("click",function(){var t=l(this).data("fileblob"),e=t.data,n=t.fileName,o=t.mimeType,a=t.fileExtension;f(e,o,n,a)})},l.fn.tableExport.defaults={headings:!0,footers:!0,formats:["xls","csv","txt"],fileName:"id",bootstrap:!0,position:"bottom",ignoreRows:null,ignoreCols:null},l.fn.tableExport.charset="charset=utf-8",l.fn.tableExport.xlsx={defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},l.fn.tableExport.xls={defaultClass:"xls",buttonContent:"Export to xls",separator:" ",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},l.fn.tableExport.csv={defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"application/csv",fileExtension:".csv"},l.fn.tableExport.txt={defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},l.fn.tableExport.defaultFileName="myDownload",l.fn.tableExport.defaultButton="button-default",l.fn.tableExport.bootstrap=["btn","btn-default","btn-toolbar"],l.fn.tableExport.rowDel="\r\n",l.fn.tableExport.entityMap={"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47"}}(window);
!function(t,e){function n(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.fn.tableExport.entityMap[t]})}function o(t,e){e&&(t+=1462);var n=Date.parse(t);return(n-new Date(Date.UTC(1899,11,30)))/864e5}function a(t,e){for(var n={},a={s:{c:1e7,r:1e7},e:{c:0,r:0}},i=0;i!=t.length;++i)for(var r=0;r!=t[i].length;++r){a.s.r>i&&(a.s.r=i),a.s.c>r&&(a.s.c=r),a.e.r<i&&(a.e.r=i),a.e.c<r&&(a.e.c=r);var f={v:t[i][r]};if(null!=f.v){var l=XLSX.utils.encode_cell({c:r,r:i});"number"==typeof f.v?f.t="n":"boolean"==typeof f.v?f.t="b":f.v instanceof Date?(f.t="n",f.z=XLSX.SSF._table[14],f.v=o(f.v)):f.t="s",n[l]=f}}return a.s.c<1e7&&(n["!ref"]=XLSX.utils.encode_range(a)),n}function i(){return this instanceof i?(this.SheetNames=[],void(this.Sheets={})):new i}function r(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),o=0;o!=t.length;++o)n[o]=255&t.charCodeAt(o);return e}function f(t,e,n,o){if(".xlsx"===o){var f=new i,s=a(t);f.SheetNames.push(n),f.Sheets[n]=s;var x={bookType:"xlsx",bookSST:!1,type:"binary"},p=XLSX.write(f,x);t=r(p)}saveAs(new Blob([t],{type:e+";"+l.fn.tableExport.charset}),n+o)}var l=t.jQuery;l.fn.tableExport=function(t){var e,o,a,i=l.extend({},l.fn.tableExport.defaults,t),r=l.fn.tableExport.rowDel,s=i.ignoreRows instanceof Array?i.ignoreRows:[i.ignoreRows],x=i.ignoreCols instanceof Array?i.ignoreCols:[i.ignoreCols],p=i.ignoreCSS instanceof Array?i.ignoreCSS.join(", "):i.ignoreCSS;i.bootstrap?(e=l.fn.tableExport.bootstrap[0]+" ",o=l.fn.tableExport.bootstrap[1]+" ",a=l.fn.tableExport.bootstrap[2]+" "):(e=l.fn.tableExport.defaultButton+" ",o=a=""),this.each(function(){function t(t){var e=u.find("caption:not(.head)");e.length?e.append(t):u.prepend('<caption class="'+a+i.position+'">'+t+"</caption>")}function f(n,a,i){var r="<button data-fileblob='"+n+"' class='"+e+o+i+"'>"+a+"</button>";t(r)}var u=l(this),b=u.find("tbody").find("tr"),b=i.headings?b.add(u.find("thead>tr")):b,b=i.footers?b.add(u.find("tfoor>tr")):b,d=i.headings?u.find("thead>tr").length:0,c="id"===i.fileName?u.attr("id")?u.attr("id"):l.fn.tableExport.defaultFileName:i.fileName,E={xlsx:function(t,e){var o=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return[n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:(console.log(l(e).is(p)),l(e).text())}).get()]}}).get(),a=n(JSON.stringify({data:o,fileName:e,mimeType:l.fn.tableExport.xlsx.mimeType,fileExtension:l.fn.tableExport.xlsx.fileExtension})),i=l.fn.tableExport.xlsx.buttonContent,r=l.fn.tableExport.xlsx.defaultClass;f(a,i,r)},xls:function(t,e){var o=l.fn.tableExport.xls.separator,a=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:l(e).text()}).get().join(o)}}).get().join(t),i=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.xls.mimeType,fileExtension:l.fn.tableExport.xls.fileExtension})),r=l.fn.tableExport.xls.buttonContent,u=l.fn.tableExport.xls.defaultClass;f(i,r,u)},csv:function(t,e){var o=l.fn.tableExport.csv.separator,a=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:l(e).text()}).get().join(o)}}).get().join(t),i=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.csv.mimeType,fileExtension:l.fn.tableExport.csv.fileExtension})),r=l.fn.tableExport.csv.buttonContent,u=l.fn.tableExport.csv.defaultClass;f(i,r,u)},txt:function(t,e){var o=l.fn.tableExport.txt.separator,a=b.map(function(t,e){if(!~s.indexOf(t-d)&&!l(e).is(p)){var n=l(e).find("th, td");return n.map(function(t,e){return~x.indexOf(t)||l(e).is(p)?void 0:l(e).text()}).get().join(o)}}).get().join(t),i=n(JSON.stringify({data:a,fileName:e,mimeType:l.fn.tableExport.txt.mimeType,fileExtension:l.fn.tableExport.txt.fileExtension})),r=l.fn.tableExport.txt.buttonContent,u=l.fn.tableExport.txt.defaultClass;f(i,r,u)}};i.formats.forEach(function(t){E[t](r,c)})}),l("button[data-fileblob]").off("click").on("click",function(){var t=l(this).data("fileblob"),e=t.data,n=t.fileName,o=t.mimeType,a=t.fileExtension;f(e,o,n,a)})},l.fn.tableExport.defaults={headings:!0,footers:!0,formats:["xls","csv","txt"],fileName:"id",bootstrap:!0,position:"bottom",ignoreRows:null,ignoreCols:null,ignoreCSS:".tableexport-ignore"},l.fn.tableExport.charset="charset=utf-8",l.fn.tableExport.xlsx={defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},l.fn.tableExport.xls={defaultClass:"xls",buttonContent:"Export to xls",separator:" ",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},l.fn.tableExport.csv={defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"application/csv",fileExtension:".csv"},l.fn.tableExport.txt={defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},l.fn.tableExport.defaultFileName="myDownload",l.fn.tableExport.defaultButton="button-default",l.fn.tableExport.bootstrap=["btn","btn-default","btn-toolbar"],l.fn.tableExport.rowDel="\r\n",l.fn.tableExport.entityMap={"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47"}}(window);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc