Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
Export to Excel - Throwing an Error
posted

Hi,

We are using ExportAsync(DataPresenterBase, Workbook) method of DataPresenterExcelExporter to export a huge datagrid to excel. While exporting, if there is an addition or update of the XamDataGrid, infragistics is throwing an error "An exception of type 'System.InvalidOperationException' occurred in InfragisticsWPF4.DataPresenter.v15.2.dll" . "Additional Information: The DataSource property cannot be assigned to on the cloned DataPresenter being used for exporting." Is there way where infragistics can work with the snapshot of the grid and can allow updates to the grid while export is going on?

Thanks

Parents
No Data
Reply
  • 34830
    Verified Answer
    Offline posted

    Hello RJ,

    The error that you are currently seeing is expected, as we intentionally disallow changing the DataSource property of the XamDataGrid when the DataPresenterExcelExporter is exporting a particular XamDataGrid. This is because changing the DataSource essentially changes the entirety of the grid, as it will repopulate the existing grid with all-new DataRecord instances and it could reinitialize new FieldLayout elements for the grid while the existing FieldLayouts are currently in use for exporting the current grid.

    It is worth noting that we do allow changes to the existing records and data items, as this will change the data in the cloned grid, but this new data will not show up in the Excel workbook after an export option has started. As such, and if possible, if you must make changes to the data source while exporting, I would recommend making your changes to the existing collection and data items that are used.

    Alternatively, perhaps you could consider deferring the change to the DataSource property until after the DataPresenterExcelExporter finishes exporting. The DataPresenterExcelExporter element has an ExportEnded event, which signals the end of the export to Excel operation. If you change your DataSource here, instead, you should not receive this error.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

Children
No Data