EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

ExcelWorkbook.Worksheets.Add() copy Worksheet colliding images

Open LanziRoberto22 opened this issue 3 years ago • 3 comments

Hi, I noticed a strange behaviour when I copy a worksheet: I used the version 5.8.3 and I noticed that the bug found in this old open issue: https://github.com/JanKallman/EPPlus/issues/394. is still true. I tried to update the version to 6.0.3 but now (with the same code) every time that I copy the worksheet return error "System.Collections.Generic.KeyNotFoundException", I checked with debug and the sheet with the correct name is present.

LanziRoberto22 avatar May 06 '22 08:05 LanziRoberto22

Hi, I tried images in the linked issue, and it seems to work as expected in 6.0.3...

        [TestMethod]
        public void i638()
        {
            using (var p1 = OpenTemplatePackage("green.xlsx"))
            {
                var ws = p1.Workbook.Worksheets[0];
                using (var p2 = OpenTemplatePackage("red.xlsx"))
                {
                    p2.Workbook.Worksheets.Add("Green", ws);
                    SaveAndCleanup(p2);
                }
            }
        }

Can you attach a sample to reproducible the issue you get.

JanKallman avatar May 09 '22 13:05 JanKallman

Hi, I noticed that in the version 5.8.3 the issue was due to two image with the same name in excel and I fixed it changing the name of the images. In the version 6.0.3 i'm tring to use the command wb.Workbook.Worksheets.Copy("Sheet1", "CopyOfSheet1"); and always returns "System.Collections.Generic.KeyNotFoundException"

LanziRoberto22 avatar May 10 '22 07:05 LanziRoberto22

OK, seems to work when I try. Can you provide a sample?

JanKallman avatar May 10 '22 12:05 JanKallman

Closed due to inactivity/lack of testability.

OssianEPPlus avatar Feb 08 '24 10:02 OssianEPPlus