When I try to export to excel the following message appears: Cannot read property 'styles' of null. I'm following the documentation ui-grid-docs. enter image description here
1 Answer
I am using ui-grid v4.4.11. This is a bit of a hack, but I found that docDefinition was being set to null at line 20343. I commented it out and it now works. See code same of prepareAsExcel function where I commented out docDefinition.
prepareAsExcel: function(grid, workbook, sheet) {
var docDefinition = {
styles: {
}
};
if ( grid.options.exporterExcelCustomFormatters ){
//docDefinition = grid.options.exporterExcelCustomFormatters( grid, workbook, docDefinition );
}
if ( grid.options.exporterExcelHeader ) {
if (angular.isFunction( grid.options.exporterExcelHeader )) {
grid.options.exporterExcelHeader(grid, workbook, sheet, docDefinition);
} else {
var headerText = grid.options.exporterExcelHeader.text;
var style = grid.options.exporterExcelHeader.style;
sheet.data.push([{value: headerText, metadata: {style: docDefinition.styles[style].id}}]);
}
}
return docDefinition;
},