I want to export huge amount of html table data around 5 lakhs from table to excel the code is working for small amount of data but when records get much more it gives error Maximum call stack size exceeded. The code :
$scope.export= function () {
if ($scope.u.Data.did== 1) {
$scope.temp = $scope.list;
if ($scope.temp.length > 0) {
var table = GenerateHTMLTable($scope.temp);
$(table).table2excel({
filename: $window.location.hash.substring(3)
});
}
}
else if ($scope.u.Data.did!= 1) {
$scope.temp = $scope.list;
if ($scope.temp.length > 0) {
var table = GenerateHTMLTable($scope.temp);
$(table).table2excel({
filename: $window.location.hash.substring(3)
});
}
}
}
function GenerateHTMLTable(json) {
var table = document.createElement("TABLE");
var col = [];
for (var key in json[0]) {
if (key !== "$$hashKey") {
col.push(key);
}
}
var row = table.insertRow(-1);
for (var i = 0; i < col.length; i++) {
var headerCell = document.createElement("TH");
headerCell.innerHTML = col[i];
row.appendChild(headerCell);
}
for (var i = 0; i < json.length; i++) {
row = table.insertRow(-1);
for (var j = 0; j < col.length; j++) {
var cell = row.insertCell(-1);
cell.innerHTML = json[i][col[j]];
}
}
return table;
}
suggest if any change required in the code.Thanks