I've encountered an issue while trying to generate an .xlsx
file using the XLSX library. The error message I received is as follows:
TypeError: n.t.match is not a function
at Ps (xlsx.full.min.js:14)
at Jd (xlsx.full.min.js:18)
at Sv (xlsx.full.min.js:21)
at Fv (xlsx.full.min.js:21)
at Object.Uv [as write] (xlsx.full.min.js:21)
at n.scope.download (excelExport.js:100)
at fn (eval at compile (angular.js:212), <anonymous>:4:215)
at f (angular.js:253)
at n.$eval (angular.js:133)
at n.$apply (angular.js:133)
This part of my code is where the issue occurs :
function getSheet(data, opts) {
var ws = {};
var range = {s: {c:10000000, r:10000000}, e: {c:0, r:0 }};
for(var R = 0; R != data.length; ++R) {
for(var C = 0; C != data[R].length; ++C) {
if(range.s.r > R) range.s.r = R;
if(range.s.c > C) range.s.c = C;
if(range.e.r < R) range.e.r = R;
if(range.e.c < C) range.e.c = C;
var cell = {v: data[R][C] };
if(cell.v == null) continue;
var cell_address = {c:C,r:R}
var cell_ref = XLSX.utils.encode_cell(cell_address);
if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {
cell.t = 'n'; cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v);
}
else {cell.t = 's';}
ws[cell_ref] = cell;
}
}
if(range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
return ws;
};
function Workbook(){
if(!(this instanceof Workbook)) return new Workbook();
this.SheetNames = [];
this.Sheets = {}
}
The error occurred in the following section of the code:
94 var wb = new Workbook(), ws = getSheet(scope.data(), scope.options);
95 /* add worksheet to workbook */
96 wb.SheetNames.push(scope.fileName);
97 wb.Sheets[scope.fileName] = ws;
100 var wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'});
Has anyone encountered this error before or knows how to resolve it? I have searched for solutions without success.