EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Duplicate index in range - but there are no duplicates.

Open gassnerj opened this issue 2 years ago • 4 comments

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".

gassnerj avatar Aug 02 '22 22:08 gassnerj

Setting PredefinedMappingsOnly to true solved this issue.

gassnerj avatar Aug 02 '22 23:08 gassnerj

Issue still exists.

gassnerj avatar Aug 02 '22 23:08 gassnerj

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.

swmal avatar Aug 03 '22 09:08 swmal

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.

gassnerj avatar Aug 10 '22 06:08 gassnerj

Closing this issue, if the issue you mentioned in your last message remains please open a new issue.

swmal avatar Aug 31 '22 07:08 swmal