Base solution for your next web application
Open Closed

Export-To-Excel-Exception-with-v1330-CORE-MVC-and-jQuery #12133


User avatar
0
truist.software created

ASP.NET CORE MVC & jQuery: v13.3.0 .NET 8 Power Tools Version: 4.3.3

After clicking the Export To Excel button an exception is thrown on a Generated Entity using the Power Tool.

Exception:System.NullReferenceException: 'Object reference not set to an instance of an object.' Method: public FileDto ExportToFile(List<GetMyEntityForViewDto> myentities, List<string> selectedColumns) Line:foreach (var selectedColumn in selectedColumns) Issue: selectedColumns is NULL in the foreach statement Entity Base Class: FullAuditedEntity


4 Answer(s)
  • User Avatar
    0
    truist.software created

    Any updates?

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @truist.software,

    Sorry for the late reply. We detected the error. In the next release, it will be fixed.

  • User Avatar
    0
    truist.software created

    Hi @truist.software,

    Sorry for the late reply. We detected the error. In the next release, it will be fixed.

    What are the work arounds in the mean time?

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @truist.software,

    This error happens if you don't select any column. You can choose at least one column.

    You can add following line to _ExcelColumnModal.js

        this.save = function () {
          const exportExcelInput = _modalManager.getArgs();
          exportExcelInput.selectedColumns = _modalManager
            .getModal()
            .find('input[type="checkbox"]:checked')
            .map(function () {
              return $(this).val();
            })
            .get();
          
           // Fix error
          if (exportExcelInput.selectedColumns.length === 0) {
            abp.message.warn(app.localize('PleaseSelectAtLeastOneColumn'));
            return;
          }
    
          _brosService.getBrosToExcel(exportExcelInput).done(function (result) {
            app.downloadTempFile(result);
            _modalManager.close();
          });
        };