Copy/clone 带有 EPPlus 的 Excel 形状到其他工作表?

Copy/clone an Excel shape with EPPlus to other worksheet?

是否可以使用 EPPlus 库为 other Excel 工作表创建一个 copy/clone 形状?

这里显示的同一个 Excel 工作表中已经有一个解决方案:Copy/clone an Excel shape with EPPlus?

但我需要能够将其复制到另一个工作表(从模板到目标)。有人知道解决方法吗?

提前致谢。

其实我找到了解决这个问题的方法。 我将此代码添加到 ExcelDrawings.cs 文件:

    /// <summary>
    /// Add a new shape to the worksheet
    /// </summary>
    /// <param name="Name">Name</param>
    /// <param name="Source">Source shape</param>
    /// <returns>The shape object</returns>

    public ExcelShape AddShape(string Name, ExcelShape Source)
    {
        if (Worksheet is ExcelChartsheet && _drawings.Count > 0)
        {
            throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
        }
        if (_drawingNames.ContainsKey(Name))
        {
            throw new Exception("Name already exists in the drawings collection");
        }
        XmlElement drawNode = CreateDrawingXml();
        drawNode.InnerXml = Source.TopNode.InnerXml;

        ExcelShape shape = new ExcelShape(this, drawNode);
        shape.Name = Name;
        shape.Style = Source.Style;
        _drawings.Add(shape);
        _drawingNames.Add(Name, _drawings.Count - 1);
        return shape;
    }