Skip to content

Commit

Permalink
add rawConvertData method
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorLesnevskiy committed Jan 9, 2017
1 parent 5025f05 commit f05b7ed
Show file tree
Hide file tree
Showing 2 changed files with 3,028 additions and 34 deletions.
2,985 changes: 2,983 additions & 2 deletions dist/table2excel.js

Large diffs are not rendered by default.

77 changes: 45 additions & 32 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class Table2Excel {
this.decodeRange = decodeRange;
this.encodeCell = encodeCell;
this.encodeRange = encodeRange;
this.saveAs = saveAs;
}

/**
Expand All @@ -78,6 +79,18 @@ export default class Table2Excel {
this.download(this.getWorkbook(tables), fileName, beforeDownloadedCallback);
}


exportLikeRawData(tables) {
return this.getRawConvertData(this.getWorkbook(tables));
}

getRawConvertData(workbook) {
return window.XLSX.write(workbook, {
bookType: 'xlsx',
type: 'base64',
});
}

/**
* Get the XLSX-Workbook object of an array of tables.
*
Expand Down Expand Up @@ -315,7 +328,7 @@ export default class Table2Excel {
beforeDownloadedCallback();
}

saveAs(blob, `${fileName}.xlsx`);
this.saveAs(blob, `${fileName}.xlsx`);
}
}

Expand All @@ -340,34 +353,34 @@ Table2Excel.extend = function extendCellTypes(typeHandler) {
typeHandlers.unshift(typeHandler);
};


if (![].includes) {
Array.prototype.includes = function(searchElement/*, fromIndex*/) {
'use strict';
var O = Object(this);
var len = parseInt(O.length) || 0;
if (len === 0) {
return false;
}
var n = parseInt(arguments[1]) || 0;
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
}
}
while (k < len) {
var currentElement = O[k];
if (searchElement === currentElement ||
(searchElement !== searchElement && currentElement !== currentElement)
) {
return true;
}
k++;
}
return false;
};
}
//
// if (![].includes) {
// Array.prototype.includes = function(searchElement/*, fromIndex*/) {
// 'use strict';
// var O = Object(this);
// var len = parseInt(O.length) || 0;
// if (len === 0) {
// return false;
// }
// var n = parseInt(arguments[1]) || 0;
// var k;
// if (n >= 0) {
// k = n;
// } else {
// k = len + n;
// if (k < 0) {
// k = 0;
// }
// }
// while (k < len) {
// var currentElement = O[k];
// if (searchElement === currentElement ||
// (searchElement !== searchElement && currentElement !== currentElement)
// ) {
// return true;
// }
// k++;
// }
// return false;
// };
// }

0 comments on commit f05b7ed

Please sign in to comment.