简体   繁体   中英

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?

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;
    } 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM