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

Commit

Permalink
v3.2.8 - added basic colspan/rowspan support
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Clarke authored and clarketm committed Aug 18, 2016
1 parent 3ebaebe commit 21a0bba
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 30 deletions.
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.7",
"version": "3.2.8",
"authors": [
"clarketm <[email protected]>"
],
Expand Down
2 changes: 1 addition & 1 deletion dist/css/tableexport.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TableExport.js v3.2.7 (https://www.travismclarke.com)
* TableExport.js v3.2.8 (https://www.travismclarke.com)
* Copyright 2016 Travis Clarke
* Licensed under the MIT license
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/css/tableexport.min.css

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

47 changes: 37 additions & 10 deletions dist/js/tableexport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TableExport.js v3.2.7 (https://www.travismclarke.com)
* TableExport.js v3.2.8 (https://www.travismclarke.com)
* Copyright 2016 Travis Clarke
* Licensed under the MIT license
*/
Expand Down Expand Up @@ -69,15 +69,29 @@
fileName = self.settings.fileName === "id" ? ($el.attr('id') ? $el.attr('id') : TableExport.prototype.defaultFileName) : self.settings.fileName,
exporters = {
xlsx: function (rDel, name) {
var dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i - thAdj) || $(val).is(ignoreCSS)) {
var rcMap = {},
dataURL = $rows.map(function (ir, val) {
if (!!~ignoreRows.indexOf(ir - thAdj) || $(val).is(ignoreCSS)) {
return;
}
var $cols = $(val).find('th, td');
return [$cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) {
return [$cols.map(function (ic, val) {
if (!!~ignoreCols.indexOf(ic) || $(val).is(ignoreCSS)) {
return;
}
if (rcMap[ir] && rcMap[ir][ic]) {
return new Array(rcMap[ir][ic]).concat($(val).text());
}
if (val.hasAttribute('colspan')) {
rcMap[ir] = rcMap[ir] || {};
rcMap[ir][ic+1] = val.getAttribute('colspan') - 1
}
if (val.hasAttribute('rowspan')) {
for(var i = 1; i < val.getAttribute('rowspan'); i++) {
rcMap[ir+i] = rcMap[ir+i] || {};
rcMap[ir+i][ic] = 1
}
}
return $(val).text();
}).get()];
}).get(),
Expand All @@ -93,15 +107,29 @@
createObjButton(dataObject, myContent, myClass);
},
xlsm: function (rDel, name) {
var dataURL = $rows.map(function (i, val) {
if (!!~ignoreRows.indexOf(i - thAdj) || $(val).is(ignoreCSS)) {
var rcMap = {},
dataURL = $rows.map(function (ir, val) {
if (!!~ignoreRows.indexOf(ir - thAdj) || $(val).is(ignoreCSS)) {
return;
}
var $cols = $(val).find('th, td');
return [$cols.map(function (i, val) {
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) {
return [$cols.map(function (ic, val) {
if (!!~ignoreCols.indexOf(ic) || $(val).is(ignoreCSS)) {
return;
}
if (rcMap[ir] && rcMap[ir][ic]) {
return new Array(rcMap[ir][ic]).concat($(val).text());
}
if (val.hasAttribute('colspan')) {
rcMap[ir] = rcMap[ir] || {};
rcMap[ir][ic+1] = val.getAttribute('colspan') - 1
}
if (val.hasAttribute('rowspan')) {
for(var i = 1; i < val.getAttribute('rowspan'); i++) {
rcMap[ir+i] = rcMap[ir+i] || {};
rcMap[ir+i][ic] = 1
}
}
return $(val).text();
}).get()];
}).get(),
Expand Down Expand Up @@ -198,7 +226,6 @@
XLSX && key === 'xls' ? key ='xlsm' : false;
!XLSX && key === 'xlsx' ? key = null : false;
key && exporters[key](rowD, fileName);
console.log(key);
}
);

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.

Loading

0 comments on commit 21a0bba

Please sign in to comment.