Skip to content

Commit 9ebfa13

Browse files
committed
added ignoreCSS property
1 parent 7bec76e commit 9ebfa13

9 files changed

Lines changed: 348 additions & 50 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ Notice that by default, TableExport will create export buttons for three differe
8888
```js
8989
/* Defaults */
9090
$("table").tableExport({
91-
headings: true, // (Boolean), display table headings (th/td elements) in the <thead>
92-
footers: true, // (Boolean), display table footers (th/td elements) in the <tfoot>
93-
formats: ["xls", "csv", "txt"], // (String[]), filetype(s) for the export
94-
fileName: "id", // (id, String), filename for the downloaded file
95-
bootstrap: true, // (Boolean), style buttons using bootstrap
96-
position: "bottom", // (top, bottom), position of the caption element relative to table
97-
ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file
98-
ignoreCols: null // (Number, Number[]), column indices to exclude from the exported file
91+
headings: true, // (Boolean), display table headings (th/td elements) in the <thead>
92+
footers: true, // (Boolean), display table footers (th/td elements) in the <tfoot>
93+
formats: ["xls", "csv", "txt"], // (String[]), filetype(s) for the export
94+
fileName: "id", // (id, String), filename for the downloaded file
95+
bootstrap: true, // (Boolean), style buttons using bootstrap
96+
position: "bottom", // (top, bottom), position of the caption element relative to table
97+
ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file
98+
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file
99+
ignoreCSS: ".tableexport-ignore" // (selector, selector[]), selector(s) to exclude from the exported file
99100
});
100101
```
101102
> **Note:** to use the xlsx filetype, you must include the third-party scripts listed in the Dependencies section.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tableexport.js",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"authors": [
55
"clarketm <travis.m.clarke@gmail.com>"
66
],

dist/js/tableexport.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* TableExport.js v3.2.0 (http://www.clarketravis.com)
2+
* TableExport.js v3.2.1 (http://www.clarketravis.com)
33
* Copyright 2015 Travis Clarke
44
* Licensed under the MIT license
55
*/
@@ -15,6 +15,7 @@
1515
rowD = $.fn.tableExport.rowDel,
1616
ignoreRows = settings.ignoreRows instanceof Array ? settings.ignoreRows : [settings.ignoreRows],
1717
ignoreCols = settings.ignoreCols instanceof Array ? settings.ignoreCols : [settings.ignoreCols],
18+
ignoreCSS = settings.ignoreCSS instanceof Array ? settings.ignoreCSS.join(", ") : settings.ignoreCSS,
1819
bootstrapClass, bootstrapTheme, bootstrapSpacing;
1920

2021
if (settings.bootstrap) {
@@ -36,10 +37,11 @@
3637
exporters = {
3738
xlsx: function (rDel, name) {
3839
var dataURL = $rows.map(function (i, val) {
39-
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
40+
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
4041
var $cols = $(val).find('th, td');
4142
return [$cols.map(function (i, val) {
42-
if (!!~ignoreCols.indexOf(i)) { return;}
43+
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
44+
console.log($(val).is(ignoreCSS));
4345
return $(val).text();
4446
}).get()];
4547
}).get(),
@@ -57,10 +59,10 @@
5759
xls: function (rdel, name) {
5860
var colD = $.fn.tableExport.xls.separator,
5961
dataURL = $rows.map(function (i, val) {
60-
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
62+
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
6163
var $cols = $(val).find('th, td');
6264
return $cols.map(function (i, val) {
63-
if (!!~ignoreCols.indexOf(i)) { return;}
65+
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
6466
return $(val).text();
6567
}).get().join(colD);
6668
}).get().join(rdel),
@@ -78,10 +80,10 @@
7880
csv: function (rdel, name) {
7981
var colD = $.fn.tableExport.csv.separator,
8082
dataURL = $rows.map(function (i, val) {
81-
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
83+
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
8284
var $cols = $(val).find('th, td');
8385
return $cols.map(function (i, val) {
84-
if (!!~ignoreCols.indexOf(i)) { return;}
86+
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
8587
return $(val).text();
8688
}).get().join(colD);
8789
}).get().join(rdel),
@@ -99,10 +101,10 @@
99101
txt: function (rdel, name) {
100102
var colD = $.fn.tableExport.txt.separator,
101103
dataURL = $rows.map(function (i, val) {
102-
if (!!~ignoreRows.indexOf(i-thAdj)) { return;}
104+
if (!!~ignoreRows.indexOf(i-thAdj) || $(val).is(ignoreCSS)) { return;}
103105
var $cols = $(val).find('th, td');
104106
return $cols.map(function (i, val) {
105-
if (!!~ignoreCols.indexOf(i)) { return;}
107+
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) { return;}
106108
return $(val).text();
107109
}).get().join(colD);
108110
}).get().join(rdel),
@@ -136,14 +138,16 @@
136138
}
137139
});
138140

139-
$("button[data-fileblob]").on("click", function () {
140-
var object = $(this).data("fileblob"),
141-
data = object.data,
142-
fileName = object.fileName,
143-
mimeType = object.mimeType,
144-
fileExtension = object.fileExtension;
145-
export2file(data, mimeType, fileName, fileExtension);
146-
});
141+
$("button[data-fileblob]")
142+
.off("click")
143+
.on("click", function () {
144+
var object = $(this).data("fileblob"),
145+
data = object.data,
146+
fileName = object.fileName,
147+
mimeType = object.mimeType,
148+
fileExtension = object.fileExtension;
149+
export2file(data, mimeType, fileName, fileExtension);
150+
});
147151
};
148152

149153
// Define the plugin default properties.
@@ -155,7 +159,8 @@
155159
bootstrap: true, // (Boolean), style buttons using bootstrap, (default: true)
156160
position: "bottom", // (top, bottom), position of the caption element relative to table, (default: "bottom")
157161
ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file (default: null)
158-
ignoreCols: null // (Number, Number[]), column indices to exclude from the exported file (default: null)
162+
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file (default: null)
163+
ignoreCSS: ".tableexport-ignore" // (selector, selector[]), selector(s) to exclude from the exported file (default: ".tableexport-ignore")
159164
};
160165

161166
$.fn.tableExport.charset = "charset=utf-8";

dist/js/tableexport.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tableexport",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"authors": [
55
"clarketm <travis.m.clarke@gmail.com>"
66
],

0 commit comments

Comments
 (0)