Search code examples
javascriptangulartypescriptexportej2-syncfusion

Can't export to excel a Syncfusion pivot table with enableVirtualization = true in Angular


Here is the component.html code.

<ejs-pivotview #pivotview id='PivotView'
[dataSourceSettings]=dataSourceSettings
allowExcelExport='true'
allowConditionalFormatting='false'
allowPdfExport='true'
showToolbar='true'
allowCalculatedField='true'
showFieldList='true'
showGroupingBar='true'
[chartSettings]='chartSettings'
expandAll='true'
exportAllPages='true'
enableVirtualization='true'
height='500'
[gridSettings]='gridSettings'
[displayOption]='displayOption'
locale='es'
[toolbar]='toolbarOptions'
width="getWidth()"
>

And in component.ts

import {
    FieldListService, CalculatedFieldService,
    ToolbarService, ConditionalFormattingService,
   ToolbarItems, DisplayOption, GroupingBarService,
   IDataOptions, VirtualScrollService
} from '@syncfusion/ej2-angular-pivotview';
//...
//...
declare var require: any;
@Component({
  selector: 'app-repo-pivote',
  templateUrl: './repo-pivote.component.html',
  //encapsulation: ViewEncapsulation.None,
  styleUrls: ['./repo-pivote.component.css'],
  providers: [CalculatedFieldService, ToolbarService, ConditionalFormattingService, FieldListService, GroupingBarService,VirtualScrollService]
})

Data is over 30K rows.

With this error.

enter image description here

When I drop the enableVirtualization parameter it exports well.

UPDATE

This is a simple project that shows the problem.

https://stackblitz.com/edit/angular-ivy-747r19?file=src/app/app.component.html


Solution

  • I could resolve it with this

    import {
      ExcelExportService,
      PDFExportService,
    } from '@syncfusion/ej2-angular-pivotview';
    
    @Component({
      selector: 'app-root',
      templateUrl: 'app.component.html',
      encapsulation: ViewEncapsulation.None,
      styleUrls: ['app.component.css'],
      providers: [
        ExcelExportService,
        PDFExportService,
      ],
    })
    

    In the import I added ExcelExportService and PDFExportService, also in the component providers too.