Skip to content

Commit 0cf43ca

Browse files
committed
v3.2.7 - xls rendered as xlsm with tdv fallback
1 parent 128441b commit 0cf43ca

10 files changed

Lines changed: 73 additions & 20 deletions

File tree

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.6",
3+
"version": "3.2.7",
44
"authors": [
55
"clarketm <travis.m.clarke@gmail.com>"
66
],

dist/css/tableexport.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* TableExport.js v4.0.0-beta (https://www.travismclarke.com)
2+
* TableExport.js v3.2.7 (https://www.travismclarke.com)
33
* Copyright 2016 Travis Clarke
44
* Licensed under the MIT license
55
*/

dist/css/tableexport.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/tableexport.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* TableExport.js v4.0.0-beta (https://www.travismclarke.com)
2+
* TableExport.js v3.2.7 (https://www.travismclarke.com)
33
* Copyright 2016 Travis Clarke
44
* Licensed under the MIT license
55
*/
@@ -92,6 +92,30 @@
9292
myClass = TableExport.prototype.xlsx.defaultClass;
9393
createObjButton(dataObject, myContent, myClass);
9494
},
95+
xlsm: function (rDel, name) {
96+
var dataURL = $rows.map(function (i, val) {
97+
if (!!~ignoreRows.indexOf(i - thAdj) || $(val).is(ignoreCSS)) {
98+
return;
99+
}
100+
var $cols = $(val).find('th, td');
101+
return [$cols.map(function (i, val) {
102+
if (!!~ignoreCols.indexOf(i) || $(val).is(ignoreCSS)) {
103+
return;
104+
}
105+
return $(val).text();
106+
}).get()];
107+
}).get(),
108+
dataObject = TableExport.prototype.escapeHtml(
109+
JSON.stringify({
110+
data: dataURL,
111+
fileName: name,
112+
mimeType: TableExport.prototype.xls.mimeType,
113+
fileExtension: TableExport.prototype.xls.fileExtension
114+
})),
115+
myContent = TableExport.prototype.xls.buttonContent,
116+
myClass = TableExport.prototype.xls.defaultClass;
117+
createObjButton(dataObject, myContent, myClass);
118+
},
95119
xls: function (rdel, name) {
96120
var colD = TableExport.prototype.xls.separator,
97121
dataURL = $rows.map(function (i, val) {
@@ -171,7 +195,10 @@
171195

172196
self.settings.formats.forEach(
173197
function (key) {
174-
exporters[key](rowD, fileName);
198+
XLSX && key === 'xls' ? key ='xlsm' : false;
199+
!XLSX && key === 'xlsx' ? key = null : false;
200+
key && exporters[key](rowD, fileName);
201+
console.log(key);
175202
}
176203
);
177204

@@ -373,14 +400,13 @@
373400
* @param extension {String} file extension
374401
*/
375402
export2file: function (data, mime, name, extension) {
376-
if (extension === ".xlsx") {
403+
if (XLSX && extension.startsWith(".xls")) {
377404
var wb = new this.Workbook(),
378405
ws = this.createSheet(data);
379406

380407
wb.SheetNames.push(name);
381408
wb.Sheets[name] = ws;
382-
383-
var wopts = {bookType: 'xlsx', bookSST: false, type: 'binary'},
409+
var wopts = {bookType: extension.substr(1, 3) + (extension.substr(4) || 'm'), bookSST: false, type: 'binary'},
384410
wbout = XLSX.write(wb, wopts);
385411

386412
data = this.string2ArrayBuffer(wbout);

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tableexport",
3-
"version": "3.2.6",
3+
"version": "3.2.7",
44
"authors": [
55
"clarketm <travis.m.clarke@gmail.com>"
66
],
@@ -44,6 +44,7 @@
4444
"gulp": "^3.9.1",
4545
"gulp-clean-css": "^2.0.7",
4646
"gulp-rename": "^1.2.2",
47+
"gulp-replace": "^0.5.4",
4748
"gulp-uglify": "^1.5.3",
4849
"jasmine": "^2.4.1"
4950
},

src/stable/css/tableexport.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* TableExport.js v4.0.0-beta (https://www.travismclarke.com)
2+
* TableExport.js v3.2.7 (https://www.travismclarke.com)
33
* Copyright 2016 Travis Clarke
44
* Licensed under the MIT license
55
*/

src/stable/css/tableexport.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)