Skip to content
This repository has been archived by the owner on Jul 25, 2021. It is now read-only.

Commit

Permalink
added ignoreCSS property
Browse files Browse the repository at this point in the history
  • Loading branch information
clarketm committed May 11, 2016
1 parent 7bec76e commit 9ebfa13
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 50 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ Notice that by default, TableExport will create export buttons for three differe
```js
/* Defaults */
$("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
});
```
> **Note:** to use the xlsx filetype, you must include the third-party scripts listed in the Dependencies section.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tableexport.js",
"version": "3.2.0",
"version": "3.2.1",
"authors": [
"clarketm <[email protected]>"
],
Expand Down
41 changes: 23 additions & 18 deletions dist/js/tableexport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TableExport.js v3.2.0 (http://www.clarketravis.com)
* TableExport.js v3.2.1 (http://www.clarketravis.com)
* Copyright 2015 Travis Clarke
* Licensed under the MIT license
*/
Expand All @@ -15,6 +15,7 @@
rowD = $.fn.tableExport.rowDel,
ignoreRows = settings.ignoreRows instanceof Array ? settings.ignoreRows : [settings.ignoreRows],
ignoreCols = settings.ignoreCols instanceof Array ? settings.ignoreCols : [settings.ignoreCols],
ignoreCSS = settings.ignoreCSS instanceof Array ? settings.ignoreCSS.join(", ") : settings.ignoreCSS,
bootstrapClass, bootstrapTheme, bootstrapSpacing;

if (settings.bootstrap) {
Expand All @@ -36,10 +37,11 @@
exporters = {
xlsx: function (rDel, name) {
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();
}).get()];
}).get(),
Expand All @@ -57,10 +59,10 @@
xls: function (rdel, name) {
var colD = $.fn.tableExport.xls.separator,
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();
}).get().join(colD);
}).get().join(rdel),
Expand All @@ -78,10 +80,10 @@
csv: function (rdel, name) {
var colD = $.fn.tableExport.csv.separator,
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();
}).get().join(colD);
}).get().join(rdel),
Expand All @@ -99,10 +101,10 @@
txt: function (rdel, name) {
var colD = $.fn.tableExport.txt.separator,
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();
}).get().join(colD);
}).get().join(rdel),
Expand Down Expand Up @@ -136,14 +138,16 @@
}
});

$("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);
});
};

// Define the plugin default properties.
Expand All @@ -155,7 +159,8 @@
bootstrap: true, // (Boolean), style buttons using bootstrap, (default: true)
position: "bottom", // (top, bottom), position of the caption element relative to table, (default: "bottom")
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")
};

$.fn.tableExport.charset = "charset=utf-8";
Expand Down
4 changes: 2 additions & 2 deletions dist/js/tableexport.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tableexport",
"version": "3.2.0",
"version": "3.2.1",
"authors": [
"clarketm <[email protected]>"
],
Expand Down
Loading

0 comments on commit 9ebfa13

Please sign in to comment.