asp.netasp.net-mvcexcelinfragisticswebdatagrid

Infragistics WebExcelExporter set max number of rows to export


I use the infragistics WebDataGrid to show a number of elements in an ASP.NET application. Now I use the WebExcelExporter class to create a excel file for the all paged rows. In the WebExcelExporter I can use the DataExportMode Property to set the number of elements, which should be exported. The DataExportMode property can be set to DataExportMode.AllDataInDataSource and DataExportMode.DataInGridOnly.

Now the problem is that I can only show the results from the current page or all pages. Due to performance I want to export only a max number of 4000 rows. Is it possible to set a max number of rows, which should be exported?


Solution

  • By design the grid provides the ability to exoport DataInGridOnly and AllDataInDataSource, yes. Although if you want to limit the exported rows, you can always use GridRecordItemExporting in order to cancel the execution.

    Code snippet:

    protected void excelExporter_GridRecordItemExporting(object sender, GridRecordItemExportingEventArgs e)
    {
        if (e.CurrentRowIndex > 4000)
        {
            e.Cancel = true;
        } 
    }