good, i am using this code to link http://brianhann.com/exporting-spreadsheets-from-ui-grid/ export to excel ui-grid from a table, but I skip this mistake, I pass what happens to me. I error occurs in the code where it says:
$rows.forEach(function (row, ri) {
ri +=1;
$scope.gridApi.grid.columns.forEach(function (col, ci) {
var loc = XLSX.utils.encode_cell({r: ri, c: ci});
sheet[loc] = {
v: row[ci].value,
t: 's'
};
endLoc = loc;
});
Regards, and thank you very much.
The code of controller is:
$scope.exportXLSX = function(){
var data = [
[] // header row
];
var rows = uiGridExporterService.getData($scope.gridApi.grid, uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE);
var sheet = {};
$scope.gridApi.grid.columns.forEach(function (col, i) {
if (col.visible) {
var loc = XLSX.utils.encode_cell({r: 0, c: i})
sheet[loc] = {
v: col.displayName
};
}
});
var endLoc;
rows.forEach(function (row, ri) {
ri +=1;
$scope.gridApi.grid.columns.forEach(function (col, ci) {
var loc = XLSX.utils.encode_cell({r: ri, c: ci});
sheet[loc] = {
v: row[ci].value,
t: 's'
};
endLoc = loc;
});
});
sheet['!ref'] = XLSX.utils.encode_range({ s: 'A1', e: endLoc });
var workbook = {
SheetNames: ['Sheet1'],
Sheets: {
Sheet1: sheet
}
};
var wopts = { bookType: 'xlsx', bookSST: false, type: 'binary' };
var wbout = XLSX.write(workbook, wopts);
saveAs(new Blob([s2ab(wbout)], {type: ""}), "test.xlsx");
};