0

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 1

1

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;
    },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.