EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Copying Charts with Attached Pictures Results in Corrupted Excel Files

Open grubersimon opened this issue 1 year ago • 2 comments

EPPlus usage

Commercial use (I have a commercial license)

Environment

Windows 11

Epplus version

7.5

Spreadsheet application

Excel

Description

When copying charts (or other drawings), the process works as expected. However, if there is a picture attached to the chart, it results in a corrupted Excel file.

When you select a chart and paste a picture of clipboard, the picture becomes locked within the borders of the chart (see attached file for reference).

It's unclear whether this is a bug or a feature request. If the intended behavior is to allow copying attached pictures along with the chart, this functionality may require proper implementation. Otherwise, if copying attached pictures is not supported, the process should gracefully skip such pictures to avoid file corruption.

Thanks for considering this issue!

var firstWs = xlsxPackage.Workbook.Worksheets["Table1"];
var secondWs = xlsxPackage.Workbook.Worksheets["Table2"];

int rowShift = 1;
foreach (var chart in firstWs.Drawings.Where(x => x.DrawingType == eDrawingType.Chart))
{
    chart.Copy(secondWs, rowShift, 10);
    rowShift += 10;
}

sample.xlsx

grubersimon avatar Nov 18 '24 22:11 grubersimon

User Shapes in Charts is yet not supported by EPPlus. The problem occurs as the copied chart does not have the relation to the drawing in the <c:userShapes r:id="rId3"/>. This is on our enhancement list, see https://github.com/EPPlusSoftware/EPPlus/issues/714 . We will likely add this feature in coming versions.

JanKallman avatar Nov 19 '24 08:11 JanKallman

Support for shapes in charts will be released with EPPlus 8.1.

AdrianEPPlus avatar Apr 16 '25 11:04 AdrianEPPlus