EPPlus
EPPlus copied to clipboard
Duplicate index in range - but there are no duplicates.
I can't add column mappings regardless of how many columns I add and regardless of indexes. I triple checked my indexes and they are all correct. Yet, the code says there is a duplicate index in range.
I drilled down to the code. And found this. It is in the DataColumnMappingCollection class under the Add method. Line 190-193.
if (this.Any((DataColumnMapping x) => x.ZeroBasedColumnIndexInRange == zeroBasedIndexInRange))
{
throw new InvalidOperationException("Duplicate index in range: " + zeroBasedIndexInRange);
}
It looks like this Linq expression will always be true. Even when I only add one column to the mapping, it has the same behavior. The error, "Duplicate index in range".
Setting PredefinedMappingsOnly to true solved this issue.
Issue still exists.
Hi,
Is it the ToDataTable function you are using? If so - can you provide some code that replicates the error (see the existing unit tests for this function here: https://github.com/EPPlusSoftware/EPPlus/blob/develop/src/EPPlusTest/Export/ToDataTable/ToDataTableTests.cs).
Alternatively you can upload a workbook and some code to replicate the error here in this issue.
I got around this for the time being by supplying the ToDataTable function with a blank replica table from the database.
I am having a new issue in the same method. But I will open a new issue for it.
Closing this issue, if the issue you mentioned in your last message remains please open a new issue.