I do not want to use worksheet.Selection to set a range that needs to be exported to a datatable. Instead, I want to use something like: worksheet.Range("TSS!A17:N125").
However, the export range (of populated data) might be ("TSS!A17:N30") or ("TSS!A17:N120") or something similar, but variable.
I am using exporter.Options.SkipEmptyRows = True, so any empty rows are skipped within the range which is great.
But how do I skip the empty rows between the last populated row and last range row? For example, the Range above ends at row 125. If the last populated row is at 120, I get “An unhandled exception of type 'System.Data.ConstraintException' occurred in System.Data.dll. Additional information: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Empty rows with formatting are exported to DataTable even if the SkipEmptyRows property is true
Answers approved by DevExpress Support
We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.
Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.
- v15.2.4Download Official Update
- v15.1.8Download Official Update
Hello,
I've tried to reproduce this behavior, but without success. Perhaps, I am missing something.
In the attachment, you will find a sample project and video demonstrating how everything works on my side.
Would you please modify the project to illustrate the issue?
I am looking forward to hearing from you.
Andrey, thank you for the response and sample project. My problem appears to be with the primary key. In this case, rows 55 and 56 are at the end of the range and are empty, so it throws the exception. I was hoping the Options.SkipEmptyRows = True would handle this. My application looks like this:
Hello,
I have reproduced the issue when empty rows are exported to DataTable in the case when row cells contain formatting but do not contain values. I have passed this ticket to our developers for further research. Please bear with us.
We will notify you as soon as we make any progress.
Andrey, I cannot thank you enough for your very prompt support.
The hotfix allows me to set the range and update.
Thank you again.
You're always welcome, Larry.
Feel free to contact us if you need further assistance.