Closed chsoft-rbi closed 1 month ago
We do not really have support for this currently as the ExcelImage class operates based on having loaded in the actual file data. However it certainly should not get an exception at copy. I took a look and it seems relatively simple to do. We'll work on it and I'll get back to you when we know more.
Thanks for reporting and thanks for the file and a clear issue description!
EPPlus usage
Personal use
Environment
Windows
Epplus version
7.3.1
Spreadsheet application
Excel
Description
If you call Worksheets.Copy to copy a worksheet that contains a picture that is a link to an image outside of the file, you get a null pointer exception in WorksheetCopyHelper.CopyPicture because pic.Image is null. I'd need it for a case where the image file doesn't necessarily exist at the linked location, but the issue even exists if the linked file exists.
You can insert a linked picture to Excel with Insert > Pictures > Place Over Cells > From This Device, then selecting an image file and instead of clicking the "Insert" button, click on the arrow and select "Link to File".
I attached an example Excel file, it links to a file "C:\Temp\reporting\black.png". Calling package.Workbook.Worksheets.Copy("Sheet1", "Copy") will cause the mentioned exception.
test.xlsx